Implement contact form backend
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user