You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0 KiB

import {Injectable, Migration, Inject, DatabaseService, FieldType} from '@extollo/lib'
/**
* CreateSettingsTableMigration
* ----------------------------------
* Create a table to store random one-off settings.
*/
@Injectable()
export default class CreateSettingsTableMigration extends Migration {
@Inject()
protected readonly db!: DatabaseService
/**
* Apply the migration.
*/
async up(): Promise<void> {
const schema = this.db.get().schema()
const table = await schema.table('p5x_settings')
table.primaryKey('id')
table.column('setting_key')
.type(FieldType.varchar)
.required()
table.column('setting_json')
.type(FieldType.text)
.required()
await schema.commit(table)
}
/**
* Undo the migration.
*/
async down(): Promise<void> {
const schema = this.db.get().schema()
const table = await schema.table('p5x_settings')
table.dropIfExists()
await schema.commit(table)
}
}