I'm not sure what is the problem with migration. I'm using knex to connect sqlite3 DB. I'm totally new to this.
Created table in migration file and then added a column in table using separate migration. But that file failed.
Logs shown above and I didn't diagnose why it's getting failed.
Migration for table creation is
import { Knex } from 'knex';
import { Bag } from '../../src/models';
export const up = (knex: Knex): Promise<void> =>
knex.schema.createTable(Bag.tableName, (table: Knex.TableBuilder) => {
table.increments();
table.timestamps();
table.integer('volume');
});
export const down = (knex: Knex): Promise<void> =>
knex.schema.dropTable(Bag.tableName);
Migration for adding column is
import { Knex } from 'knex';
import { Bag } from '../../src/models';
export const up = (knex: Knex): Promise<void> =>
knex.schema.alterTable(Bag.tableName, (table: Knex.TableBuilder) => {
table.string('title');
});
export const down = (knex: Knex): Promise<void> =>
knex.schema.alterTable(Bag.tableName, (table: Knex.TableBuilder) => {
table.dropColumn('title');
});
NOTE: I tried adding column in table creation migration but it also fails and gave me error.
Also when command to show completed migrations. It listed all migrations including new addedColumn one.