35 lines
843 B
TypeScript
35 lines
843 B
TypeScript
import { Knex } from 'knex';
|
|
|
|
export async function up(knex: Knex): Promise<void> {
|
|
return knex.schema.createTable('user_tokens', (table) => {
|
|
table.increments('id').primary();
|
|
|
|
table.text('token').notNullable();
|
|
table.text('nonce').nullable();
|
|
table
|
|
.enum('type', [
|
|
'generic',
|
|
'activation',
|
|
'deactivation',
|
|
'password',
|
|
'login',
|
|
'gdpr',
|
|
'totp',
|
|
'public_key',
|
|
'recovery',
|
|
])
|
|
.notNullable();
|
|
|
|
table.uuid('user_id').notNullable();
|
|
|
|
table.timestamp('expires_at').nullable();
|
|
table.timestamp('created_at').notNullable().defaultTo('now()');
|
|
|
|
table.foreign('user_id').references('users.id').onDelete('CASCADE');
|
|
});
|
|
}
|
|
|
|
export async function down(knex: Knex): Promise<void> {
|
|
return knex.schema.dropTable('user_tokens');
|
|
}
|