import BaseSchema from 'sosise-core/build/Database/BaseSchema'; /** * For more information, refer to: http://knexjs.org/#Schema */ export default class %name% extends BaseSchema { protected tableName = 'table_name_comes_here'; /** * Run the migrations. */ public async up(): Promise { await this.dbConnection.schema.alterTable(this.tableName, (table) => { // Add column table.string('new_field').defaultTo(null); // Alter column, add index table.integer('existing_int_field').index().alter(); // Rename column table.renameColumn('new_field', 'new_field_renamed'); }); } /** * Reverse the migrations. */ public async down(): Promise { await this.dbConnection.schema.alterTable(this.tableName, (table) => { // Drop column table.dropColumn('new_field'); // Drop index table.dropIndex('existing_int_field'); // Rename column table.renameColumn('new_field_renamed', 'new_field'); }); } }