packages/optimise-core/src/db/available_visit_sections.table.js
import visitSections from './defaults_v1/visitSections.json';
export const TABLE_NAME = 'AVAILABLE_VISIT_SECTIONS';
export const PRIORITY = 0;
export default async (dbcon, version) => {
switch (version) {
case 1:
await dbcon().schema.createTable(TABLE_NAME, (table) => {
table.increments('id').primary();
table.text('name').notNullable();
table.text('module').nullable();
table.text('deleted').notNullable().defaultTo('-');
table.unique(['name', 'module', 'deleted'], `UNIQUE_${Date.now()}_${TABLE_NAME}`);
});
await dbcon()(TABLE_NAME).insert(visitSections);
break;
default:
break;
}
};