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.
www/src/app/migrations/2022-04-04T19:22:30.795Z_Cr...

50 lines
1.1 KiB

import {DatabaseService, FieldType, Inject, Injectable, Migration} from '@extollo/lib'
/**
* CreateGolinksTableMigration
* ----------------------------------
* Create Table to store URL redirections
*/
@Injectable()
export default class CreateGolinksTableMigration 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('go_links')
table.primaryKey('go_link_id').required()
table.column('active')
.type(FieldType.bool)
.default(true)
table.column('short')
.type(FieldType.varchar)
.required()
.unique()
table.column('url')
.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('go_links')
table.dropIfExists()
await schema.commit(table)
}
}