1+ CREATE TABLE "account " (
2+ " id" text PRIMARY KEY NOT NULL ,
3+ " account_id" text NOT NULL ,
4+ " provider_id" text NOT NULL ,
5+ " user_id" text NOT NULL ,
6+ " access_token" text ,
7+ " refresh_token" text ,
8+ " id_token" text ,
9+ " access_token_expires_at" timestamp with time zone ,
10+ " refresh_token_expires_at" timestamp with time zone ,
11+ " scope" text ,
12+ " password" text ,
13+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
14+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL
15+ );
16+ -- > statement-breakpoint
17+ CREATE TABLE "article " (
18+ " id" text PRIMARY KEY NOT NULL ,
19+ " slug" text NOT NULL ,
20+ " title" text NOT NULL ,
21+ " content" text NOT NULL ,
22+ " excerpt" text ,
23+ " cover_url" text ,
24+ " author_id" text ,
25+ " published" boolean DEFAULT false NOT NULL ,
26+ " published_at" timestamp with time zone ,
27+ " view_count" integer DEFAULT 0 NOT NULL ,
28+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
29+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
30+ CONSTRAINT " article_slug_unique" UNIQUE(" slug" )
31+ );
32+ -- > statement-breakpoint
33+ CREATE TABLE "member " (
34+ " id" text PRIMARY KEY NOT NULL ,
35+ " user_id" text ,
36+ " slug" text NOT NULL ,
37+ " name" text NOT NULL ,
38+ " bio" text ,
39+ " image_url" text ,
40+ " page_content" text ,
41+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
42+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
43+ CONSTRAINT " member_user_id_unique" UNIQUE(" user_id" ),
44+ CONSTRAINT " member_slug_unique" UNIQUE(" slug" )
45+ );
46+ -- > statement-breakpoint
47+ CREATE TABLE "project " (
48+ " id" text PRIMARY KEY NOT NULL ,
49+ " slug" text NOT NULL ,
50+ " name" text NOT NULL ,
51+ " description" text ,
52+ " content" text ,
53+ " cover_url" text ,
54+ " repo_url" text ,
55+ " demo_url" text ,
56+ " category" text DEFAULT ' active' NOT NULL ,
57+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
58+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
59+ CONSTRAINT " project_slug_unique" UNIQUE(" slug" )
60+ );
61+ -- > statement-breakpoint
62+ CREATE TABLE "project_member " (
63+ " project_id" text NOT NULL ,
64+ " member_id" text NOT NULL ,
65+ " role" text DEFAULT ' member' NOT NULL
66+ );
67+ -- > statement-breakpoint
68+ CREATE TABLE "session " (
69+ " id" text PRIMARY KEY NOT NULL ,
70+ " expires_at" timestamp with time zone NOT NULL ,
71+ " token" text NOT NULL ,
72+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
73+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
74+ " ip_address" text ,
75+ " user_agent" text ,
76+ " user_id" text NOT NULL ,
77+ CONSTRAINT " session_token_unique" UNIQUE(" token" )
78+ );
79+ -- > statement-breakpoint
80+ CREATE TABLE "user " (
81+ " id" text PRIMARY KEY NOT NULL ,
82+ " name" text NOT NULL ,
83+ " email" text NOT NULL ,
84+ " email_verified" boolean DEFAULT false NOT NULL ,
85+ " image" text ,
86+ " utcode_member_at" timestamp with time zone ,
87+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
88+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL ,
89+ CONSTRAINT " user_email_unique" UNIQUE(" email" )
90+ );
91+ -- > statement-breakpoint
92+ CREATE TABLE "verification " (
93+ " id" text PRIMARY KEY NOT NULL ,
94+ " identifier" text NOT NULL ,
95+ " value" text NOT NULL ,
96+ " expires_at" timestamp with time zone NOT NULL ,
97+ " created_at" timestamp with time zone DEFAULT now() NOT NULL ,
98+ " updated_at" timestamp with time zone DEFAULT now() NOT NULL
99+ );
100+ -- > statement-breakpoint
101+ ALTER TABLE " account" ADD CONSTRAINT " account_user_id_user_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " public" ." user" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
102+ ALTER TABLE " article" ADD CONSTRAINT " article_author_id_member_id_fk" FOREIGN KEY (" author_id" ) REFERENCES " public" ." member" (" id" ) ON DELETE set null ON UPDATE no action;-- > statement-breakpoint
103+ ALTER TABLE " member" ADD CONSTRAINT " member_user_id_user_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " public" ." user" (" id" ) ON DELETE set null ON UPDATE no action;-- > statement-breakpoint
104+ ALTER TABLE " project_member" ADD CONSTRAINT " project_member_project_id_project_id_fk" FOREIGN KEY (" project_id" ) REFERENCES " public" ." project" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
105+ ALTER TABLE " project_member" ADD CONSTRAINT " project_member_member_id_member_id_fk" FOREIGN KEY (" member_id" ) REFERENCES " public" ." member" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
106+ ALTER TABLE " session" ADD CONSTRAINT " session_user_id_user_id_fk" FOREIGN KEY (" user_id" ) REFERENCES " public" ." user" (" id" ) ON DELETE cascade ON UPDATE no action;-- > statement-breakpoint
107+ CREATE INDEX "account_userId_idx " ON " account" USING btree (" user_id" );-- > statement-breakpoint
108+ CREATE INDEX "article_authorId_idx " ON " article" USING btree (" author_id" );-- > statement-breakpoint
109+ CREATE INDEX "member_userId_idx " ON " member" USING btree (" user_id" );-- > statement-breakpoint
110+ CREATE INDEX "projectMember_pk " ON " project_member" USING btree (" project_id" ," member_id" );-- > statement-breakpoint
111+ CREATE INDEX "session_userId_idx " ON " session" USING btree (" user_id" );-- > statement-breakpoint
112+ CREATE INDEX "verification_identifier_idx " ON " verification" USING btree (" identifier" );
0 commit comments