Implement contact form backend

This commit is contained in:
2022-04-05 14:24:36 -05:00
parent e643bf6df0
commit e3c3b93818
12 changed files with 399 additions and 11 deletions

View File

@@ -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)
}
}