1+ CREATE TYPE "public "." user_role" AS ENUM(' user' , ' admin' );-- > statement-breakpoint
2+ CREATE TABLE "users " (
3+ " id" text PRIMARY KEY NOT NULL ,
4+ " email" text NOT NULL ,
5+ " name" text NOT NULL ,
6+ " image" text ,
7+ " role" " user_role" DEFAULT ' user' NOT NULL ,
8+ " email_verified" boolean DEFAULT false NOT NULL ,
9+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
10+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
11+ CONSTRAINT " users_email_unique" UNIQUE(" email" )
12+ );
13+ -- > statement-breakpoint
14+ CREATE TABLE "accounts " (
15+ " id" text PRIMARY KEY NOT NULL ,
16+ " user_id" text NOT NULL ,
17+ " account_id" text NOT NULL ,
18+ " provider_id" text NOT NULL ,
19+ " access_token" text ,
20+ " refresh_token" text ,
21+ " access_token_expires_at" timestamp with time zone ,
22+ " refresh_token_expires_at" timestamp with time zone ,
23+ " scope" text ,
24+ " password" text ,
25+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
26+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL
27+ );
28+ -- > statement-breakpoint
29+ CREATE TABLE "sessions " (
30+ " id" text PRIMARY KEY NOT NULL ,
31+ " user_id" text NOT NULL ,
32+ " token" text NOT NULL ,
33+ " expires_at" timestamp with time zone NOT NULL ,
34+ " ip_address" text ,
35+ " user_agent" text ,
36+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
37+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
38+ CONSTRAINT " sessions_token_unique" UNIQUE(" token" )
39+ );
40+ -- > statement-breakpoint
41+ CREATE TABLE "verifications " (
42+ " id" text PRIMARY KEY NOT NULL ,
43+ " identifier" text NOT NULL ,
44+ " value" text NOT NULL ,
45+ " expires_at" timestamp with time zone NOT NULL ,
46+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
47+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL
48+ );
49+ -- > statement-breakpoint
50+ ALTER TABLE " accounts" ADD CONSTRAINT " accounts_user_id_users_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " public" ." users" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
51+ ALTER TABLE " sessions" ADD CONSTRAINT " sessions_user_id_users_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " public" ." users" (" id" ) ON DELETE cascade ON UPDATE no action;
0 commit comments