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.
52 lines
1.2 KiB
52 lines
1.2 KiB
import {Injectable, Migration, Inject, DatabaseService, FieldType, raw} from '@extollo/lib'
|
|
|
|
/**
|
|
* CreateContactSubmissionsTableMigration
|
|
* ----------------------------------
|
|
* Put some description here.
|
|
*/
|
|
@Injectable()
|
|
export default class CreateContactSubmissionsTableMigration 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('contact_submissions')
|
|
|
|
table.primaryKey('contact_submission_id').required()
|
|
|
|
table.column('email')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('name')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('message')
|
|
.type(FieldType.text)
|
|
|
|
table.column('sent_at')
|
|
.type(FieldType.timestamp)
|
|
.default(raw('NOW()'))
|
|
|
|
await schema.commit(table)
|
|
}
|
|
|
|
/**
|
|
* Undo the migration.
|
|
*/
|
|
async down(): Promise<void> {
|
|
const schema = this.db.get().schema()
|
|
const table = await schema.table('contact_submissions')
|
|
|
|
table.dropIfExists()
|
|
|
|
await schema.commit(table)
|
|
}
|
|
}
|