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.
api/src/app/migrations/2022-04-10T08:03:01.479Z_Cr...

45 lines
1.0 KiB

import {Injectable, Migration, Inject, DatabaseService, FieldType} from '@extollo/lib'
/**
* CreateEditorPagesTableMigration
* ----------------------------------
* Put some description here.
*/
@Injectable()
export default class CreateEditorPagesTableMigration 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('editor_pages')
table.primaryKey('page_id').required()
table.column('user_id')
.type(FieldType.varchar)
.required()
table.column('serial_data')
.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('editor_pages')
table.dropIfExists()
await schema.commit(table)
}
}