npm run test
npm run compile
Add following commands into the package.json scripts structure:
{
"scripts": {
"nergal": "node_modules/.bin/ts-node console.ts",
"migrate": "node_modules/db-migrate/bin/db-migrate",
"start": "node_modules/.bin/ts-node run.ts",
"compile": "node_modules/typescript/bin/tsc --listEmittedFiles",
"test": "node_modules/.bin/ts-node test/startup.ts && node_modules/.bin/mocha \"./test/*.test.ts\""
},
}
Then init the project:
node node_modules/nergal/init
To create new migration run
npm run migrate create <migration name>
Creating new table:
await db.createTable('votes', {
id: { type: 'int', primaryKey: true, autoIncrement: true},
participant_id: 'int',
voter_discord_id: 'string',
});
Adding indexes:
db.addIndex('votes', 'unique_voter_and_participant', ['participant_id', 'voter_discord_id'], true);
Dropping table
return db.dropTable('votes');
Adding column
await db.addColumn('votes', 'voter_discord_name', 'string');
Removing column
db.removeColumn('votes');
Running migrations
npm run migrate up
npm run start
npm run console