You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Current sql file was generated after introspecting the database
2
+
-- If you want to run this migration please uncomment this code before executing migrations
3
+
/*
4
+
CREATE TABLE "file_attachments" (
5
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
6
+
"note_id" uuid,
7
+
"filename" text NOT NULL,
8
+
"original_name" text NOT NULL,
9
+
"mime_type" text NOT NULL,
10
+
"size" integer NOT NULL,
11
+
"encrypted_data" text NOT NULL,
12
+
"iv" text NOT NULL,
13
+
"salt" text NOT NULL,
14
+
"uploaded_at" timestamp with time zone DEFAULT now(),
15
+
"encrypted_title" text DEFAULT 'encrypted_placeholder' NOT NULL
16
+
);
17
+
--> statement-breakpoint
18
+
CREATE TABLE "folders" (
19
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
20
+
"user_id" text NOT NULL,
21
+
"name" text NOT NULL,
22
+
"color" text DEFAULT '#6b7280',
23
+
"parent_id" uuid,
24
+
"is_default" boolean DEFAULT false,
25
+
"created_at" timestamp DEFAULT now() NOT NULL,
26
+
"updated_at" timestamp DEFAULT now() NOT NULL,
27
+
"sort_order" integer DEFAULT 0 NOT NULL
28
+
);
29
+
--> statement-breakpoint
30
+
CREATE TABLE "users" (
31
+
"id" text PRIMARY KEY NOT NULL,
32
+
"email" text NOT NULL,
33
+
"first_name" text,
34
+
"last_name" text,
35
+
"created_at" timestamp DEFAULT now() NOT NULL,
36
+
"updated_at" timestamp DEFAULT now() NOT NULL
37
+
);
38
+
--> statement-breakpoint
39
+
CREATE TABLE "notes" (
40
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
41
+
"user_id" text NOT NULL,
42
+
"folder_id" uuid,
43
+
"title" text NOT NULL,
44
+
"content" text DEFAULT '',
45
+
"starred" boolean DEFAULT false,
46
+
"archived" boolean DEFAULT false,
47
+
"deleted" boolean DEFAULT false,
48
+
"tags" text[] DEFAULT '{""}',
49
+
"created_at" timestamp DEFAULT now() NOT NULL,
50
+
"updated_at" timestamp DEFAULT now() NOT NULL,
51
+
"encrypted_title" text,
52
+
"encrypted_content" text,
53
+
"iv" text,
54
+
"salt" varchar(255),
55
+
"hidden_at" timestamp,
56
+
"hidden" boolean DEFAULT false
57
+
);
58
+
--> statement-breakpoint
59
+
ALTER TABLE "file_attachments" ADD CONSTRAINT "file_attachments_note_id_fkey" FOREIGN KEY ("note_id") REFERENCES "public"."notes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
60
+
ALTER TABLE "folders" ADD CONSTRAINT "folders_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
61
+
ALTER TABLE "folders" ADD CONSTRAINT "folders_parent_id_folders_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."folders"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
62
+
ALTER TABLE "notes" ADD CONSTRAINT "notes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
63
+
ALTER TABLE "notes" ADD CONSTRAINT "notes_folder_id_folders_id_fk" FOREIGN KEY ("folder_id") REFERENCES "public"."folders"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
64
+
CREATE INDEX "idx_file_attachments_note_id" ON "file_attachments" USING btree ("note_id" uuid_ops);
0 commit comments