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.
59 lines
1.4 KiB
59 lines
1.4 KiB
import {DatabaseService, FieldType, Inject, Injectable, Migration} from '@extollo/lib'
|
|
|
|
/**
|
|
* CreateWorkItemsTableMigration
|
|
* ----------------------------------
|
|
* Create the work_items table to track project history.
|
|
*/
|
|
@Injectable()
|
|
export default class CreateWorkItemsTableMigration 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('work_items')
|
|
|
|
table.primaryKey('work_item_id').required()
|
|
|
|
table.column('visible')
|
|
.type(FieldType.bool)
|
|
.required()
|
|
.default(false)
|
|
|
|
table.column('name')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('description')
|
|
.type(FieldType.text)
|
|
.required()
|
|
.default('')
|
|
|
|
table.column('start_date')
|
|
.type(FieldType.timestamp)
|
|
.required()
|
|
|
|
table.column('end_date')
|
|
.type(FieldType.timestamp)
|
|
.nullable()
|
|
|
|
await schema.commit(table)
|
|
}
|
|
|
|
/**
|
|
* Undo the migration.
|
|
*/
|
|
async down(): Promise<void> {
|
|
const schema = this.db.get().schema()
|
|
const table = await schema.table('work_items')
|
|
|
|
table.dropIfExists()
|
|
|
|
await schema.commit(table)
|
|
}
|
|
}
|