2020-04-03 00:35:25 +05:00
module . exports . up = ( knex ) =>
2020-02-03 18:42:31 +05:00
knex . schema
2020-04-03 00:35:25 +05:00
. createTable ( 'user_account' , ( table ) => {
2020-02-03 18:42:31 +05:00
/* Columns */
2019-08-31 04:07:25 +05:00
2020-04-03 00:35:25 +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 ( ) ;
2020-04-03 00:35:25 +05:00
table . text ( 'username' ) ;
2020-04-21 05:04:34 +05:00
table . text ( 'avatar_dirname' ) ;
2020-04-09 18:27:28 +05:00
table . text ( 'phone' ) ;
table . text ( 'organization' ) ;
2020-04-10 00:11:34 +05:00
table . boolean ( 'subscribe_to_own_cards' ) . notNullable ( ) ;
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-04-03 00:35:25 +05:00
)
. raw (
'ALTER TABLE "user_account" ADD CONSTRAINT "user_username_unique" EXCLUDE ("username" WITH =) WHERE ("username" IS NOT NULL AND "deleted_at" IS NULL)' ,
2020-02-03 18:42:31 +05:00
) ;
2019-08-31 04:07:25 +05:00
2020-04-03 00:35:25 +05:00
module . exports . down = ( knex ) => knex . schema . dropTable ( 'user_account' ) ;