2020-02-03 18:42:31 +05:00
|
|
|
module.exports.up = knex =>
|
|
|
|
knex.schema
|
2020-02-25 01:31:52 +05:00
|
|
|
.createTable('user_account', table => {
|
2020-02-03 18:42:31 +05:00
|
|
|
/* Columns */
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
table
|
|
|
|
.bigInteger('id')
|
|
|
|
.primary()
|
|
|
|
.defaultTo(knex.raw('next_id()'));
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
table.text('email').notNullable();
|
|
|
|
table.text('password').notNullable();
|
|
|
|
table.boolean('is_admin').notNullable();
|
|
|
|
table.text('name').notNullable();
|
|
|
|
table.text('avatar');
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
table.timestamp('created_at', true);
|
|
|
|
table.timestamp('updated_at', true);
|
|
|
|
table.timestamp('deleted_at', true);
|
|
|
|
})
|
|
|
|
.raw(
|
2020-02-25 01:31:52 +05:00
|
|
|
'ALTER TABLE "user_account" ADD CONSTRAINT "user_email_unique" EXCLUDE ("email" WITH =) WHERE ("deleted_at" IS NULL)',
|
2020-02-03 18:42:31 +05:00
|
|
|
);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2020-02-25 01:31:52 +05:00
|
|
|
module.exports.down = knex => knex.schema.dropTable('user_account');
|