Skip to content

Commit

Permalink
feat(deployment): reworks top up deployments to rely on db setting
Browse files Browse the repository at this point in the history
refs #714
  • Loading branch information
ygrishajev authored Feb 3, 2025
1 parent b7e647a commit 2762b97
Show file tree
Hide file tree
Showing 30 changed files with 1,316 additions and 760 deletions.
2 changes: 1 addition & 1 deletion apps/api/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { defineConfig } from "drizzle-kit";
import { config } from "./src/core/config";

export default defineConfig({
schema: ["./src/billing/model-schemas", "./src/user/model-schemas"],
schema: ["billing", "user", "deployment"].map(schema => `./src/${schema}/model-schemas`),
out: "./drizzle",
dialect: "postgresql",
dbCredentials: {
Expand Down
17 changes: 17 additions & 0 deletions apps/api/drizzle/0008_pale_dakota_north.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE IF NOT EXISTS "deployment_settings" (
"id" serial PRIMARY KEY NOT NULL,
"user_id" uuid NOT NULL,
"dseq" varchar NOT NULL,
"auto_top_up_enabled" boolean DEFAULT false NOT NULL,
"created_at" timestamp DEFAULT now(),
"updated_at" timestamp DEFAULT now(),
CONSTRAINT "dseq_user_id_idx" UNIQUE("dseq","user_id")
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "deployment_settings" ADD CONSTRAINT "deployment_settings_user_id_userSetting_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."userSetting"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "auto_top_up_enabled_id_idx" ON "deployment_settings" USING btree ("auto_top_up_enabled","id");
Loading

0 comments on commit 2762b97

Please sign in to comment.