1+ CREATE TABLE
2+ " base" ." user_activity" (
3+ " id" text PRIMARY KEY NOT NULL ,
4+ " user_id" text NOT NULL ,
5+ " event_type" varchar (50 ) NOT NULL ,
6+ " entity_id" varchar ,
7+ " metadata" jsonb,
8+ " created_at" timestamp
9+ with
10+ time zone DEFAULT now () NOT NULL
11+ );
12+
13+ CREATE TABLE "base "." user_notifications" (
14+ " user_id" text PRIMARY KEY NOT NULL ,
15+ " settings" jsonb DEFAULT ' {"email":{"task_assigned":true,"mentions":true,"daily_summary":false},"push":{"task_assigned":true,"reminders":true}}' ::jsonb NOT NULL
16+ );
17+
18+ CREATE TABLE
19+ " base" ." user_preferences" (
20+ " user_id" text PRIMARY KEY NOT NULL ,
21+ " theme" text DEFAULT ' system' ,
22+ " timezone" varchar (50 ) DEFAULT ' UTC' NOT NULL ,
23+ " language" varchar (5 ) DEFAULT ' ru' NOT NULL
24+ );
25+
26+ CREATE TABLE
27+ " base" ." user_security" (
28+ " user_id" text PRIMARY KEY NOT NULL ,
29+ " password_hash" varchar (255 ),
30+ " recovery_email" varchar (255 ),
31+ " is_2fa_enabled" boolean DEFAULT false NOT NULL ,
32+ " two_factor_secret" text ,
33+ " last_login_at" timestamp
34+ with
35+ time zone,
36+ " last_password_change" timestamp
37+ with
38+ time zone DEFAULT now () NOT NULL
39+ );
40+
41+ CREATE TABLE
42+ " base" ." users" (
43+ " id" text PRIMARY KEY NOT NULL ,
44+ " username" varchar (50 ),
45+ " headline" varchar (200 ),
46+ " location" varchar (255 ),
47+ " first_name" varchar (50 ) NOT NULL ,
48+ " last_name" varchar (50 ) NOT NULL ,
49+ " middle_name" varchar (50 ),
50+ " email" varchar (255 ) NOT NULL ,
51+ " bio" text ,
52+ " phone" varchar (20 ),
53+ " vacation_start" timestamp
54+ with
55+ time zone,
56+ " vacation_end" timestamp
57+ with
58+ time zone,
59+ " vacation_message" varchar (255 ),
60+ " gender" text DEFAULT ' none' ,
61+ " pronouns" text DEFAULT ' none' ,
62+ " pronouns_custom" varchar (50 ),
63+ " avatar_url" varchar (512 ),
64+ " email_verified" boolean DEFAULT false NOT NULL ,
65+ " email_verified_at" timestamp
66+ with
67+ time zone,
68+ " last_team_id" text ,
69+ " deleted_at" timestamp
70+ with
71+ time zone,
72+ " created_at" timestamp
73+ with
74+ time zone DEFAULT now () NOT NULL ,
75+ " updated_at" timestamp
76+ with
77+ time zone DEFAULT now () NOT NULL ,
78+ CONSTRAINT " users_username_unique" UNIQUE (" username" ),
79+ CONSTRAINT " users_email_unique" UNIQUE (" email" )
80+ );
81+
82+ CREATE TABLE
83+ " base" ." user_identities" (
84+ " id" text PRIMARY KEY NOT NULL ,
85+ " user_id" text NOT NULL ,
86+ " provider" varchar (50 ) NOT NULL ,
87+ " provider_user_id" varchar (255 ) NOT NULL ,
88+ " email" varchar (255 ) NOT NULL ,
89+ " avatar_url" varchar (255 ),
90+ " created_at" timestamp
91+ with
92+ time zone DEFAULT now () NOT NULL ,
93+ CONSTRAINT " provider_user_id_idx" UNIQUE (" provider" , " provider_user_id" )
94+ );
95+
96+ ALTER TABLE " base" ." user_activity" ADD CONSTRAINT " user_activity_user_id_users_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " base" ." users" (" id" ) ON DELETE cascade ON UPDATE no action;
97+
98+ ALTER TABLE " base" ." user_notifications" ADD CONSTRAINT " user_notifications_user_id_users_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " base" ." users" (" id" ) ON DELETE cascade ON UPDATE no action;
99+
100+ ALTER TABLE " base" ." user_preferences" ADD CONSTRAINT " user_preferences_user_id_users_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " base" ." users" (" id" ) ON DELETE cascade ON UPDATE no action;
101+
102+ ALTER TABLE " base" ." user_security" ADD CONSTRAINT " user_security_user_id_users_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " base" ." users" (" id" ) ON DELETE cascade ON UPDATE no action;
103+
104+ ALTER TABLE " base" ." user_identities" ADD CONSTRAINT " user_identities_user_id_users_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " base" ." users" (" id" ) ON DELETE cascade ON UPDATE no action;
0 commit comments