Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions drizzle/0019_fixed_power_man.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CREATE TABLE "budget_balance" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"user_id" uuid NOT NULL,
"amount" text NOT NULL,
"currency" text DEFAULT 'CZK' NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "budget_balance_user_id_unique" UNIQUE("user_id")
);
--> statement-breakpoint
CREATE TABLE "budget_items" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"user_id" uuid NOT NULL,
"name" text NOT NULL,
"amount" text NOT NULL,
"amount_paid" text DEFAULT '0' NOT NULL,
"paid" boolean DEFAULT false NOT NULL,
"note" text,
"order" integer DEFAULT 0 NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "budget_sub_items" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"budget_item_id" uuid NOT NULL,
"name" text NOT NULL,
"amount" text NOT NULL,
"amount_paid" text DEFAULT '0' NOT NULL,
"paid" boolean DEFAULT false NOT NULL,
"note" text,
"order" integer DEFAULT 0 NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "budget_balance" ADD CONSTRAINT "budget_balance_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "budget_items" ADD CONSTRAINT "budget_items_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "budget_sub_items" ADD CONSTRAINT "budget_sub_items_budget_item_id_budget_items_id_fk" FOREIGN KEY ("budget_item_id") REFERENCES "public"."budget_items"("id") ON DELETE cascade ON UPDATE no action;
2 changes: 2 additions & 0 deletions drizzle/0020_mixed_tarantula.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "budget_items" ALTER COLUMN "amount" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "budget_items" ALTER COLUMN "amount_paid" DROP NOT NULL;
3 changes: 3 additions & 0 deletions drizzle/0021_sad_young_avengers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE "budget_items" ALTER COLUMN "amount" SET DEFAULT '0';--> statement-breakpoint
ALTER TABLE "budget_items" ALTER COLUMN "amount" SET NOT NULL;--> statement-breakpoint
ALTER TABLE "budget_items" ALTER COLUMN "amount_paid" SET NOT NULL;
Loading