feat: Convert migration files to JS
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { knexSnakeCaseMappers } from 'objection';
|
import { knexSnakeCaseMappers } from 'objection';
|
||||||
import appConfig from './src/config/app';
|
import appConfig from './src/config/app';
|
||||||
|
|
||||||
const fileExtension = appConfig.isDev || appConfig.isTest ? 'ts' : 'js';
|
const fileExtension = 'js';
|
||||||
|
|
||||||
const knexConfig = {
|
const knexConfig = {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('users', (table) => {
|
return knex.schema.createTable('users', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('email').unique().notNullable();
|
table.string('email').unique().notNullable();
|
||||||
@@ -10,6 +8,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('users');
|
return knex.schema.dropTable('users');
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('credentials', (table) => {
|
return knex.schema.createTable('credentials', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('key').notNullable();
|
table.string('key').notNullable();
|
||||||
@@ -13,6 +11,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('credentials');
|
return knex.schema.dropTable('credentials');
|
||||||
}
|
}
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('credentials', (table) => {
|
return knex.schema.table('credentials', (table) => {
|
||||||
table.dropColumn('display_name');
|
table.dropColumn('display_name');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('credentials', (table) => {
|
return knex.schema.table('credentials', (table) => {
|
||||||
table.string('display_name');
|
table.string('display_name');
|
||||||
});
|
});
|
@@ -0,0 +1,7 @@
|
|||||||
|
export async function up(knex) {
|
||||||
|
return knex.schema.renameTable('credentials', 'connections');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex) {
|
||||||
|
return knex.schema.renameTable('connections', 'credentials');
|
||||||
|
}
|
@@ -1,9 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.renameTable('credentials', 'connections');
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.renameTable('connections', 'credentials');
|
|
||||||
}
|
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('steps', (table) => {
|
return knex.schema.createTable('steps', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('key').notNullable();
|
table.string('key').notNullable();
|
||||||
@@ -13,6 +11,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('steps');
|
return knex.schema.dropTable('steps');
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('flows', (table) => {
|
return knex.schema.createTable('flows', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('name');
|
table.string('name');
|
||||||
@@ -10,6 +8,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('flows');
|
return knex.schema.dropTable('flows');
|
||||||
}
|
}
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.uuid('flow_id').references('id').inTable('flows');
|
table.uuid('flow_id').references('id').inTable('flows');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.dropColumn('flow_id');
|
table.dropColumn('flow_id');
|
||||||
});
|
});
|
@@ -1,13 +1,11 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.alterTable('steps', (table) => {
|
return knex.schema.alterTable('steps', (table) => {
|
||||||
table.string('key').nullable().alter();
|
table.string('key').nullable().alter();
|
||||||
table.string('app_key').nullable().alter();
|
table.string('app_key').nullable().alter();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.alterTable('steps', (table) => {
|
return knex.schema.alterTable('steps', (table) => {
|
||||||
table.string('key').notNullable().alter();
|
table.string('key').notNullable().alter();
|
||||||
table.string('app_key').notNullable().alter();
|
table.string('app_key').notNullable().alter();
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('flows', (table) => {
|
return knex.schema.table('flows', (table) => {
|
||||||
table.boolean('active').defaultTo(false);
|
table.boolean('active').defaultTo(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('flows', (table) => {
|
return knex.schema.table('flows', (table) => {
|
||||||
table.dropColumn('active');
|
table.dropColumn('active');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.integer('position').notNullable();
|
table.integer('position').notNullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.dropColumn('position');
|
table.dropColumn('position');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.string('status').notNullable().defaultTo('incomplete');
|
table.string('status').notNullable().defaultTo('incomplete');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.dropColumn('status');
|
table.dropColumn('status');
|
||||||
});
|
});
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('executions', (table) => {
|
return knex.schema.createTable('executions', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.uuid('flow_id').references('id').inTable('flows');
|
table.uuid('flow_id').references('id').inTable('flows');
|
||||||
@@ -10,6 +8,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('executions');
|
return knex.schema.dropTable('executions');
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('execution_steps', (table) => {
|
return knex.schema.createTable('execution_steps', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.uuid('execution_id').references('id').inTable('executions');
|
table.uuid('execution_id').references('id').inTable('executions');
|
||||||
@@ -13,6 +11,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('execution_steps');
|
return knex.schema.dropTable('execution_steps');
|
||||||
}
|
}
|
@@ -1,13 +1,11 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.alterTable('execution_steps', (table) => {
|
return knex.schema.alterTable('execution_steps', (table) => {
|
||||||
table.jsonb('data_in').alter();
|
table.jsonb('data_in').alter();
|
||||||
table.jsonb('data_out').alter();
|
table.jsonb('data_out').alter();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.alterTable('execution_steps', (table) => {
|
return knex.schema.alterTable('execution_steps', (table) => {
|
||||||
table.text('data_in').alter();
|
table.text('data_in').alter();
|
||||||
table.text('data_out').alter();
|
table.text('data_out').alter();
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.alterTable('steps', (table) => {
|
return knex.schema.alterTable('steps', (table) => {
|
||||||
table.jsonb('parameters').defaultTo('{}').alter();
|
table.jsonb('parameters').defaultTo('{}').alter();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.alterTable('steps', (table) => {
|
return knex.schema.alterTable('steps', (table) => {
|
||||||
table.text('parameters').alter();
|
table.text('parameters').alter();
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('connections', (table) => {
|
return knex.schema.table('connections', (table) => {
|
||||||
table.boolean('draft').defaultTo(true);
|
table.boolean('draft').defaultTo(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('connections', (table) => {
|
return knex.schema.table('connections', (table) => {
|
||||||
table.dropColumn('draft');
|
table.dropColumn('draft');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('flows', (table) => {
|
return knex.schema.table('flows', (table) => {
|
||||||
table.timestamp('published_at').nullable();
|
table.timestamp('published_at').nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('flows', (table) => {
|
return knex.schema.table('flows', (table) => {
|
||||||
table.dropColumn('published_at');
|
table.dropColumn('published_at');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('executions', (table) => {
|
return knex.schema.table('executions', (table) => {
|
||||||
table.string('internal_id');
|
table.string('internal_id');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('executions', (table) => {
|
return knex.schema.table('executions', (table) => {
|
||||||
table.dropColumn('internal_id');
|
table.dropColumn('internal_id');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('execution_steps', (table) => {
|
return knex.schema.table('execution_steps', (table) => {
|
||||||
table.jsonb('error_details');
|
table.jsonb('error_details');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('execution_steps', (table) => {
|
return knex.schema.table('execution_steps', (table) => {
|
||||||
table.dropColumn('error_details');
|
table.dropColumn('error_details');
|
||||||
});
|
});
|
@@ -1,18 +1,16 @@
|
|||||||
import { Knex } from 'knex';
|
async function addDeletedColumn(knex, tableName) {
|
||||||
|
|
||||||
async function addDeletedColumn(knex: Knex, tableName: string) {
|
|
||||||
return await knex.schema.table(tableName, (table) => {
|
return await knex.schema.table(tableName, (table) => {
|
||||||
table.timestamp('deleted_at').nullable();
|
table.timestamp('deleted_at').nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dropDeletedColumn(knex: Knex, tableName: string) {
|
async function dropDeletedColumn(knex, tableName) {
|
||||||
return await knex.schema.table(tableName, (table) => {
|
return await knex.schema.table(tableName, (table) => {
|
||||||
table.dropColumn('deleted_at');
|
table.dropColumn('deleted_at');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
await addDeletedColumn(knex, 'steps');
|
await addDeletedColumn(knex, 'steps');
|
||||||
await addDeletedColumn(knex, 'flows');
|
await addDeletedColumn(knex, 'flows');
|
||||||
await addDeletedColumn(knex, 'executions');
|
await addDeletedColumn(knex, 'executions');
|
||||||
@@ -21,7 +19,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
await addDeletedColumn(knex, 'connections');
|
await addDeletedColumn(knex, 'connections');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
await dropDeletedColumn(knex, 'steps');
|
await dropDeletedColumn(knex, 'steps');
|
||||||
await dropDeletedColumn(knex, 'flows');
|
await dropDeletedColumn(knex, 'flows');
|
||||||
await dropDeletedColumn(knex, 'executions');
|
await dropDeletedColumn(knex, 'executions');
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('flows', (table) => {
|
return knex.schema.table('flows', (table) => {
|
||||||
table.string('remote_webhook_id');
|
table.string('remote_webhook_id');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('flows', (table) => {
|
return knex.schema.table('flows', (table) => {
|
||||||
table.dropColumn('remote_webhook_id');
|
table.dropColumn('remote_webhook_id');
|
||||||
});
|
});
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('users', async (table) => {
|
return knex.schema.table('users', async (table) => {
|
||||||
table.string('role');
|
table.string('role');
|
||||||
|
|
||||||
@@ -8,7 +6,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
||||||
table.dropColumn('role');
|
table.dropColumn('role');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.alterTable('users', (table) => {
|
return knex.schema.alterTable('users', (table) => {
|
||||||
table.string('role').notNullable().alter();
|
table.string('role').notNullable().alter();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.alterTable('users', (table) => {
|
return knex.schema.alterTable('users', (table) => {
|
||||||
table.string('role').nullable().alter();
|
table.string('role').nullable().alter();
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
||||||
table.string('reset_password_token');
|
table.string('reset_password_token');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
||||||
table.dropColumn('reset_password_token');
|
table.dropColumn('reset_password_token');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
||||||
table.timestamp('reset_password_token_sent_at');
|
table.timestamp('reset_password_token_sent_at');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
||||||
table.dropColumn('reset_password_token_sent_at');
|
table.dropColumn('reset_password_token_sent_at');
|
||||||
});
|
});
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('users', async (table) => {
|
return knex.schema.table('users', async (table) => {
|
||||||
table.string('full_name');
|
table.string('full_name');
|
||||||
|
|
||||||
@@ -8,7 +6,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
||||||
table.dropColumn('full_name');
|
table.dropColumn('full_name');
|
||||||
});
|
});
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.createTable('payment_plans', (table) => {
|
return knex.schema.createTable('payment_plans', (table) => {
|
||||||
@@ -18,7 +17,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
return knex.schema.dropTable('payment_plans');
|
return knex.schema.dropTable('payment_plans');
|
||||||
}
|
}
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.createTable('usage_data', (table) => {
|
return knex.schema.createTable('usage_data', (table) => {
|
||||||
@@ -14,7 +13,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
return knex.schema.dropTable('usage_data');
|
return knex.schema.dropTable('usage_data');
|
||||||
}
|
}
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.alterTable('usage_data', (table) => {
|
return knex.schema.alterTable('usage_data', (table) => {
|
||||||
@@ -9,7 +8,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.alterTable('usage_data', (table) => {
|
return knex.schema.alterTable('usage_data', (table) => {
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
||||||
@@ -9,7 +8,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.table('users', (table) => {
|
return knex.schema.table('users', (table) => {
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.createTable('subscriptions', (table) => {
|
return knex.schema.createTable('subscriptions', (table) => {
|
||||||
@@ -20,7 +19,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.dropTable('subscriptions');
|
return knex.schema.dropTable('subscriptions');
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.alterTable('subscriptions', (table) => {
|
return knex.schema.alterTable('subscriptions', (table) => {
|
||||||
@@ -9,7 +8,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.alterTable('subscriptions', (table) => {
|
return knex.schema.alterTable('subscriptions', (table) => {
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.table('usage_data', (table) => {
|
return knex.schema.table('usage_data', (table) => {
|
||||||
@@ -9,7 +8,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.table('usage_data', (table) => {
|
return knex.schema.table('usage_data', (table) => {
|
@@ -1,7 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.table('subscriptions', (table) => {
|
return knex.schema.table('subscriptions', (table) => {
|
||||||
@@ -9,7 +8,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.table('subscriptions', (table) => {
|
return knex.schema.table('subscriptions', (table) => {
|
@@ -1,13 +1,12 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.dropTable('payment_plans');
|
return knex.schema.dropTable('payment_plans');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
if (!appConfig.isCloud) return;
|
if (!appConfig.isCloud) return;
|
||||||
|
|
||||||
return knex.schema.createTable('payment_plans', (table) => {
|
return knex.schema.createTable('payment_plans', (table) => {
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.string('webhook_path');
|
table.string('webhook_path');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.table('steps', (table) => {
|
return knex.schema.table('steps', (table) => {
|
||||||
table.dropColumn('webhook_path');
|
table.dropColumn('webhook_path');
|
||||||
});
|
});
|
@@ -0,0 +1,23 @@
|
|||||||
|
export async function up(knex) {
|
||||||
|
return await knex('steps')
|
||||||
|
.where('type', 'trigger')
|
||||||
|
.whereIn('app_key', [
|
||||||
|
'gitlab',
|
||||||
|
'typeform',
|
||||||
|
'twilio',
|
||||||
|
'flowers-software',
|
||||||
|
'webhook',
|
||||||
|
])
|
||||||
|
.update({
|
||||||
|
webhook_path: knex.raw('? || ??', [
|
||||||
|
'/webhooks/flows/',
|
||||||
|
knex.ref('flow_id'),
|
||||||
|
]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex) {
|
||||||
|
return await knex('steps').update({
|
||||||
|
webhook_path: null,
|
||||||
|
});
|
||||||
|
}
|
@@ -1,16 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return await knex('steps')
|
|
||||||
.where('type', 'trigger')
|
|
||||||
.whereIn('app_key', ['gitlab', 'typeform', 'twilio', 'flowers-software', 'webhook'])
|
|
||||||
.update({
|
|
||||||
webhook_path: knex.raw('? || ??', ['/webhooks/flows/', knex.ref('flow_id')]),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
|
||||||
return await knex('steps').update({
|
|
||||||
webhook_path: null
|
|
||||||
});
|
|
||||||
}
|
|
@@ -1,8 +1,7 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import capitalize from 'lodash/capitalize';
|
import capitalize from 'lodash/capitalize';
|
||||||
import lowerCase from 'lodash/lowerCase';
|
import lowerCase from 'lodash/lowerCase';
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
await knex.schema.createTable('roles', (table) => {
|
await knex.schema.createTable('roles', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('name').notNullable();
|
table.string('name').notNullable();
|
||||||
@@ -12,9 +11,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
table.timestamps(true, true);
|
table.timestamps(true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
const uniqueUserRoles = await knex('users')
|
const uniqueUserRoles = await knex('users').select('role').groupBy('role');
|
||||||
.select('role')
|
|
||||||
.groupBy('role');
|
|
||||||
|
|
||||||
let shouldCreateAdminRole = true;
|
let shouldCreateAdminRole = true;
|
||||||
for (const { role } of uniqueUserRoles) {
|
for (const { role } of uniqueUserRoles) {
|
||||||
@@ -41,6 +38,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('roles');
|
return knex.schema.dropTable('roles');
|
||||||
}
|
}
|
@@ -1,14 +1,12 @@
|
|||||||
import { Knex } from 'knex';
|
const getPermissionForRole = (roleId, subject, actions, conditions = []) =>
|
||||||
|
actions.map((action) => ({
|
||||||
const getPermissionForRole = (roleId: string, subject: string, actions: string[], conditions: string[] = []) => actions
|
|
||||||
.map(action => ({
|
|
||||||
role_id: roleId,
|
role_id: roleId,
|
||||||
subject,
|
subject,
|
||||||
action,
|
action,
|
||||||
conditions,
|
conditions,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
await knex.schema.createTable('permissions', (table) => {
|
await knex.schema.createTable('permissions', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.uuid('role_id').references('id').inTable('roles');
|
table.uuid('role_id').references('id').inTable('roles');
|
||||||
@@ -19,7 +17,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
table.timestamps(true, true);
|
table.timestamps(true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
const roles = await knex('roles').select(['id', 'key']) as { id: string, key: string }[];
|
const roles = await knex('roles').select(['id', 'key']);
|
||||||
|
|
||||||
for (const role of roles) {
|
for (const role of roles) {
|
||||||
// `admin` role should have no conditions unlike others by default
|
// `admin` role should have no conditions unlike others by default
|
||||||
@@ -28,21 +26,41 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
|
|
||||||
// default permissions
|
// default permissions
|
||||||
await knex('permissions').insert([
|
await knex('permissions').insert([
|
||||||
...getPermissionForRole(role.id, 'Connection', ['create', 'read', 'delete', 'update'], roleConditions),
|
...getPermissionForRole(
|
||||||
|
role.id,
|
||||||
|
'Connection',
|
||||||
|
['create', 'read', 'delete', 'update'],
|
||||||
|
roleConditions
|
||||||
|
),
|
||||||
...getPermissionForRole(role.id, 'Execution', ['read'], roleConditions),
|
...getPermissionForRole(role.id, 'Execution', ['read'], roleConditions),
|
||||||
...getPermissionForRole(role.id, 'Flow', ['create', 'delete', 'publish', 'read', 'update'], roleConditions),
|
...getPermissionForRole(
|
||||||
|
role.id,
|
||||||
|
'Flow',
|
||||||
|
['create', 'delete', 'publish', 'read', 'update'],
|
||||||
|
roleConditions
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// admin specific permission
|
// admin specific permission
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
await knex('permissions').insert([
|
await knex('permissions').insert([
|
||||||
...getPermissionForRole(role.id, 'User', ['create', 'read', 'delete', 'update']),
|
...getPermissionForRole(role.id, 'User', [
|
||||||
...getPermissionForRole(role.id, 'Role', ['create', 'read', 'delete', 'update']),
|
'create',
|
||||||
|
'read',
|
||||||
|
'delete',
|
||||||
|
'update',
|
||||||
|
]),
|
||||||
|
...getPermissionForRole(role.id, 'Role', [
|
||||||
|
'create',
|
||||||
|
'read',
|
||||||
|
'delete',
|
||||||
|
'update',
|
||||||
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('permissions');
|
return knex.schema.dropTable('permissions');
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('users', async (table) => {
|
await knex.schema.table('users', async (table) => {
|
||||||
table.uuid('role_id').references('id').inTable('roles');
|
table.uuid('role_id').references('id').inTable('roles');
|
||||||
});
|
});
|
||||||
@@ -11,10 +9,10 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
for (const role of roles) {
|
for (const role of roles) {
|
||||||
await knex('users')
|
await knex('users')
|
||||||
.where({
|
.where({
|
||||||
role: role.key
|
role: role.key,
|
||||||
})
|
})
|
||||||
.update({
|
.update({
|
||||||
role_id: role.id
|
role_id: role.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +20,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
await knex('users').whereNull('role_id').update({ role_id: theRole.id });
|
await knex('users').whereNull('role_id').update({ role_id: theRole.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return await knex.schema.table('users', (table) => {
|
return await knex.schema.table('users', (table) => {
|
||||||
table.dropColumn('role_id');
|
table.dropColumn('role_id');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('users', async (table) => {
|
await knex.schema.table('users', async (table) => {
|
||||||
table.dropColumn('role');
|
table.dropColumn('role');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return await knex.schema.table('users', (table) => {
|
return await knex.schema.table('users', (table) => {
|
||||||
table.string('role').defaultTo('user');
|
table.string('role').defaultTo('user');
|
||||||
});
|
});
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('saml_auth_providers', (table) => {
|
return knex.schema.createTable('saml_auth_providers', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('name').notNullable();
|
table.string('name').notNullable();
|
||||||
@@ -19,6 +17,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('saml_auth_providers');
|
return knex.schema.dropTable('saml_auth_providers');
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('identities', (table) => {
|
return knex.schema.createTable('identities', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.uuid('user_id').references('id').inTable('users');
|
table.uuid('user_id').references('id').inTable('users');
|
||||||
@@ -12,6 +10,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('identities');
|
return knex.schema.dropTable('identities');
|
||||||
}
|
}
|
@@ -1,11 +1,9 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return await knex.schema.alterTable('users', (table) => {
|
return await knex.schema.alterTable('users', (table) => {
|
||||||
table.string('password').nullable().alter();
|
table.string('password').nullable().alter();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(): Promise<void> {
|
export async function down() {
|
||||||
// void
|
// void
|
||||||
}
|
}
|
@@ -1,10 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
const getPermissionForRole = (roleId, subject, actions) =>
|
||||||
|
|
||||||
const getPermissionForRole = (
|
|
||||||
roleId: string,
|
|
||||||
subject: string,
|
|
||||||
actions: string[]
|
|
||||||
) =>
|
|
||||||
actions.map((action) => ({
|
actions.map((action) => ({
|
||||||
role_id: roleId,
|
role_id: roleId,
|
||||||
subject,
|
subject,
|
||||||
@@ -12,11 +6,11 @@ const getPermissionForRole = (
|
|||||||
conditions: [],
|
conditions: [],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex) {
|
||||||
const role = (await knex('roles')
|
const role = await knex('roles')
|
||||||
.first(['id', 'key'])
|
.first(['id', 'key'])
|
||||||
.where({ key: 'admin' })
|
.where({ key: 'admin' })
|
||||||
.limit(1)) as { id: string; key: string };
|
.limit(1);
|
||||||
|
|
||||||
await knex('permissions').insert(
|
await knex('permissions').insert(
|
||||||
getPermissionForRole(role.id, 'SamlAuthProvider', [
|
getPermissionForRole(role.id, 'SamlAuthProvider', [
|
||||||
@@ -28,6 +22,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
await knex('permissions').where({ subject: 'SamlAuthProvider' }).delete();
|
await knex('permissions').where({ subject: 'SamlAuthProvider' }).delete();
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('config', (table) => {
|
return knex.schema.createTable('config', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('key').unique().notNullable();
|
table.string('key').unique().notNullable();
|
||||||
@@ -10,6 +8,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('config');
|
return knex.schema.dropTable('config');
|
||||||
}
|
}
|
@@ -0,0 +1,22 @@
|
|||||||
|
const getPermissionForRole = (roleId, subject, actions) =>
|
||||||
|
actions.map((action) => ({
|
||||||
|
role_id: roleId,
|
||||||
|
subject,
|
||||||
|
action,
|
||||||
|
conditions: [],
|
||||||
|
}));
|
||||||
|
|
||||||
|
export async function up(knex) {
|
||||||
|
const role = await knex('roles')
|
||||||
|
.first(['id', 'key'])
|
||||||
|
.where({ key: 'admin' })
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
await knex('permissions').insert(
|
||||||
|
getPermissionForRole(role.id, 'Config', ['update'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex) {
|
||||||
|
await knex('permissions').where({ subject: 'Config' }).delete();
|
||||||
|
}
|
@@ -1,30 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
const getPermissionForRole = (
|
|
||||||
roleId: string,
|
|
||||||
subject: string,
|
|
||||||
actions: string[]
|
|
||||||
) =>
|
|
||||||
actions.map((action) => ({
|
|
||||||
role_id: roleId,
|
|
||||||
subject,
|
|
||||||
action,
|
|
||||||
conditions: [],
|
|
||||||
}));
|
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
const role = (await knex('roles')
|
|
||||||
.first(['id', 'key'])
|
|
||||||
.where({ key: 'admin' })
|
|
||||||
.limit(1)) as { id: string; key: string };
|
|
||||||
|
|
||||||
await knex('permissions').insert(
|
|
||||||
getPermissionForRole(role.id, 'Config', [
|
|
||||||
'update',
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
|
||||||
await knex('permissions').where({ subject: 'Config' }).delete();
|
|
||||||
}
|
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable(
|
return knex.schema.createTable(
|
||||||
'saml_auth_providers_role_mappings',
|
'saml_auth_providers_role_mappings',
|
||||||
(table) => {
|
(table) => {
|
||||||
@@ -19,6 +17,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('saml_auth_providers_role_mappings');
|
return knex.schema.dropTable('saml_auth_providers_role_mappings');
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('app_configs', (table) => {
|
return knex.schema.createTable('app_configs', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('key').unique().notNullable();
|
table.string('key').unique().notNullable();
|
||||||
@@ -12,6 +10,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('app_configs');
|
return knex.schema.dropTable('app_configs');
|
||||||
}
|
}
|
@@ -1,10 +1,12 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
return knex.schema.createTable('app_auth_clients', (table) => {
|
return knex.schema.createTable('app_auth_clients', (table) => {
|
||||||
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()'));
|
||||||
table.string('name').unique().notNullable();
|
table.string('name').unique().notNullable();
|
||||||
table.uuid('app_config_id').notNullable().references('id').inTable('app_configs');
|
table
|
||||||
|
.uuid('app_config_id')
|
||||||
|
.notNullable()
|
||||||
|
.references('id')
|
||||||
|
.inTable('app_configs');
|
||||||
table.text('auth_defaults').notNullable();
|
table.text('auth_defaults').notNullable();
|
||||||
table.boolean('active').notNullable().defaultTo(false);
|
table.boolean('active').notNullable().defaultTo(false);
|
||||||
|
|
||||||
@@ -12,6 +14,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return knex.schema.dropTable('app_auth_clients');
|
return knex.schema.dropTable('app_auth_clients');
|
||||||
}
|
}
|
@@ -0,0 +1,14 @@
|
|||||||
|
export async function up(knex) {
|
||||||
|
await knex.schema.table('connections', async (table) => {
|
||||||
|
table
|
||||||
|
.uuid('app_auth_client_id')
|
||||||
|
.references('id')
|
||||||
|
.inTable('app_auth_clients');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex) {
|
||||||
|
return await knex.schema.table('connections', (table) => {
|
||||||
|
table.dropColumn('app_auth_client_id');
|
||||||
|
});
|
||||||
|
}
|
@@ -1,13 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('connections', async (table) => {
|
|
||||||
table.uuid('app_auth_client_id').references('id').inTable('app_auth_clients');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
|
||||||
return await knex.schema.table('connections', (table) => {
|
|
||||||
table.dropColumn('app_auth_client_id');
|
|
||||||
});
|
|
||||||
}
|
|
@@ -0,0 +1,22 @@
|
|||||||
|
const getPermissionForRole = (roleId, subject, actions) =>
|
||||||
|
actions.map((action) => ({
|
||||||
|
role_id: roleId,
|
||||||
|
subject,
|
||||||
|
action,
|
||||||
|
conditions: [],
|
||||||
|
}));
|
||||||
|
|
||||||
|
export async function up(knex) {
|
||||||
|
const role = await knex('roles')
|
||||||
|
.first(['id', 'key'])
|
||||||
|
.where({ key: 'admin' })
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
await knex('permissions').insert(
|
||||||
|
getPermissionForRole(role.id, 'App', ['create', 'read', 'delete', 'update'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex) {
|
||||||
|
await knex('permissions').where({ subject: 'App' }).delete();
|
||||||
|
}
|
@@ -1,33 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
const getPermissionForRole = (
|
|
||||||
roleId: string,
|
|
||||||
subject: string,
|
|
||||||
actions: string[]
|
|
||||||
) =>
|
|
||||||
actions.map((action) => ({
|
|
||||||
role_id: roleId,
|
|
||||||
subject,
|
|
||||||
action,
|
|
||||||
conditions: [],
|
|
||||||
}));
|
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
const role = (await knex('roles')
|
|
||||||
.first(['id', 'key'])
|
|
||||||
.where({ key: 'admin' })
|
|
||||||
.limit(1)) as { id: string; key: string };
|
|
||||||
|
|
||||||
await knex('permissions').insert(
|
|
||||||
getPermissionForRole(role.id, 'App', [
|
|
||||||
'create',
|
|
||||||
'read',
|
|
||||||
'delete',
|
|
||||||
'update',
|
|
||||||
])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
|
||||||
await knex('permissions').where({ subject: 'App' }).delete();
|
|
||||||
}
|
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
const role = await knex('roles')
|
const role = await knex('roles')
|
||||||
.select('id')
|
.select('id')
|
||||||
.whereIn('key', ['user', 'admin'])
|
.whereIn('key', ['user', 'admin'])
|
||||||
@@ -18,7 +16,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
return await knex.schema.alterTable('users', (table) => {
|
return await knex.schema.alterTable('users', (table) => {
|
||||||
table.uuid('role_id').nullable().alter();
|
table.uuid('role_id').nullable().alter();
|
||||||
});
|
});
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
const users = await knex('users').whereNotNull('deleted_at');
|
const users = await knex('users').whereNotNull('deleted_at');
|
||||||
const userIds = users.map((user) => user.id);
|
const userIds = users.map((user) => user.id);
|
||||||
|
|
||||||
@@ -30,6 +28,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(): Promise<void> {
|
export async function down() {
|
||||||
// void
|
// void
|
||||||
}
|
}
|
@@ -1,11 +1,9 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex('permissions')
|
await knex('permissions')
|
||||||
.where(knex.raw('conditions::text'), '=', knex.raw("'{}'::text"))
|
.where(knex.raw('conditions::text'), '=', knex.raw("'{}'::text"))
|
||||||
.update('conditions', JSON.stringify([]));
|
.update('conditions', JSON.stringify([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(): Promise<void> {
|
export async function down() {
|
||||||
// void
|
// void
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex('users')
|
await knex('users')
|
||||||
.whereRaw('email != LOWER(email)')
|
.whereRaw('email != LOWER(email)')
|
||||||
.update({
|
.update({
|
||||||
@@ -8,6 +6,6 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(): Promise<void> {
|
export async function down() {
|
||||||
// void
|
// void
|
||||||
}
|
}
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('executions', (table) => {
|
await knex.schema.table('executions', (table) => {
|
||||||
table.index('flow_id');
|
table.index('flow_id');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
await knex.schema.table('executions', (table) => {
|
await knex.schema.table('executions', (table) => {
|
||||||
table.dropIndex('flow_id');
|
table.dropIndex('flow_id');
|
||||||
});
|
});
|
@@ -1,12 +1,10 @@
|
|||||||
import { Knex } from 'knex';
|
export async function up(knex) {
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
|
||||||
await knex.schema.table('executions', (table) => {
|
await knex.schema.table('executions', (table) => {
|
||||||
table.index('updated_at');
|
table.index('updated_at');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex) {
|
||||||
await knex.schema.table('executions', (table) => {
|
await knex.schema.table('executions', (table) => {
|
||||||
table.dropIndex('updated_at');
|
table.dropIndex('updated_at');
|
||||||
});
|
});
|
Reference in New Issue
Block a user