web-service/apps/auth/src/database/migrations/20230629153343_user.ts

27 lines
817 B
TypeScript

import { Knex } from 'knex';
export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable('users', (table) => {
table.uuid('id').primary().defaultTo(knex.raw('uuid_generate_v4()'));
table.string('username', 255).notNullable();
table.string('email', 255).notNullable();
table.string('phone', 255).nullable();
table.string('country', 2).nullable();
table.string('language', 2).notNullable().defaultTo('en');
table.text('password').notNullable();
table.text('display_name').nullable();
table.boolean('verified').defaultTo(false);
table.boolean('activated').defaultTo(true);
table.timestamps(true, true);
table.timestamp('login_at');
});
}
export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable('users');
}