39 lines
1004 B
JavaScript
39 lines
1004 B
JavaScript
/**
|
|
* Store PIS/ICF consent submissions for physician users.
|
|
* @param {import('knex').Knex} knex
|
|
*/
|
|
export async function up(knex) {
|
|
await knex.schema.createTable('consents', (table) => {
|
|
table.charset('utf8mb4');
|
|
table.collate('utf8mb4_unicode_ci');
|
|
table.increments('id').primary();
|
|
table
|
|
.integer('user_id')
|
|
.unsigned()
|
|
.notNullable()
|
|
.unique()
|
|
.references('id')
|
|
.inTable('users')
|
|
.onDelete('CASCADE');
|
|
table
|
|
.integer('application_id')
|
|
.unsigned()
|
|
.notNullable()
|
|
.references('id')
|
|
.inTable('applications')
|
|
.onDelete('CASCADE');
|
|
table.string('participant_name', 255).notNullable();
|
|
table.date('consent_date').notNullable();
|
|
table.json('answers').notNullable();
|
|
table.datetime('submitted_at').notNullable();
|
|
table.timestamps(true, true);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param {import('knex').Knex} knex
|
|
*/
|
|
export async function down(knex) {
|
|
await knex.schema.dropTableIfExists('consents');
|
|
}
|