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
29 changes: 29 additions & 0 deletions drizzle/0008_empty_guardsmen.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
CREATE TABLE "plans" (
"id" serial PRIMARY KEY NOT NULL,
"name" varchar NOT NULL,
"duration_days" integer NOT NULL,
"price" numeric(10, 2) NOT NULL,
"frequency" varchar NOT NULL,
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
CONSTRAINT "plans_name_unique" UNIQUE("name")
);
--> statement-breakpoint
CREATE TABLE "subscriptions" (
"id" serial PRIMARY KEY NOT NULL,
"user_id" integer NOT NULL,
"plan_id" integer NOT NULL,
"frequency" varchar NOT NULL,
"start_date" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
"end_date" timestamp NOT NULL,
"retirement_date" timestamp,
"active" boolean DEFAULT true NOT NULL,
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--> statement-breakpoint
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_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 "subscriptions" ADD CONSTRAINT "subscriptions_plan_id_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "sub_user_idx" ON "subscriptions" USING btree ("user_id");--> statement-breakpoint
CREATE INDEX "sub_plan_idx" ON "subscriptions" USING btree ("plan_id");--> statement-breakpoint
CREATE INDEX "sub_active_idx" ON "subscriptions" USING btree ("active");
36 changes: 36 additions & 0 deletions drizzle/0008_subscriptions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CREATE TABLE IF NOT EXISTS "plans" (
"id" serial PRIMARY KEY NOT NULL,
"name" varchar NOT NULL,
"duration_days" integer NOT NULL,
"price" numeric(10, 2) NOT NULL,
"frequency" varchar NOT NULL,
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
CONSTRAINT "plans_name_unique" UNIQUE("name")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "subscriptions" (
"id" serial PRIMARY KEY NOT NULL,
"user_id" integer NOT NULL,
"plan_id" integer NOT NULL,
"frequency" varchar NOT NULL,
"start_date" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
"end_date" timestamp NOT NULL,
"retirement_date" timestamp,
"active" boolean DEFAULT true NOT NULL,
"created_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
"updated_at" timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "sub_user_idx" ON "subscriptions" ("user_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "sub_plan_idx" ON "subscriptions" ("plan_id");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "sub_active_idx" ON "subscriptions" ("active");--> statement-breakpoint
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_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 "subscriptions" ADD CONSTRAINT "subscriptions_plan_id_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plans"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
INSERT INTO "plans" ("name", "duration_days", "price", "frequency") VALUES
('demo', 15, 0.00, 'one-time'),
('lite', 30, 9.99, 'monthly'),
('lite', 365, 99.99, 'yearly'),
('plus', 30, 19.99, 'monthly'),
('plus', 365, 199.99, 'yearly');

1 change: 1 addition & 0 deletions drizzle/0009_silky_jamie_braddock.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "plans" DROP CONSTRAINT "plans_name_unique";
2 changes: 2 additions & 0 deletions drizzle/0010_sharp_morgan_stark.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "plans" ADD COLUMN "description" text;--> statement-breakpoint
ALTER TABLE "plans" ADD COLUMN "features" jsonb;
Loading