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