From a6c472084d18929a5b39f6ea7d75ad66120e95bc Mon Sep 17 00:00:00 2001 From: whekin Date: Tue, 24 Mar 2026 01:56:34 +0400 Subject: [PATCH] fix(db): repair notification migration workflow --- lefthook.yml | 5 +++++ package.json | 2 +- packages/db/drizzle-checksums.json | 2 +- packages/db/drizzle/0023_huge_vision.sql | 19 ------------------- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index 3de18ee..3641055 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -3,6 +3,9 @@ pre-commit: parallel: true commands: + db-migration-manifest: + glob: 'packages/db/drizzle/*.sql' + run: bun run db:migrations:manifest && git add packages/db/drizzle-checksums.json format: glob: '*.{ts,tsx,js,jsx,json,md}' run: bun run format:check @@ -13,6 +16,8 @@ pre-commit: pre-push: parallel: true commands: + db-migrations: + run: bun run db:migrations:check typecheck: run: bun run typecheck test: diff --git a/package.json b/package.json index c951c1b..9280983 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "lint:fix": "oxlint --fix .", "format": "bunx oxfmt .", "format:check": "bunx oxfmt --check .", - "db:generate": "bunx drizzle-kit generate --config packages/db/drizzle.config.ts", + "db:generate": "bunx drizzle-kit generate --config packages/db/drizzle.config.ts && bun run db:migrations:manifest", "db:check": "bunx drizzle-kit check --config packages/db/drizzle.config.ts", "db:migrate": "bun run packages/db/src/migrate.ts", "db:migrations:check": "bun run scripts/check-migration-hygiene.ts", diff --git a/packages/db/drizzle-checksums.json b/packages/db/drizzle-checksums.json index c92e4f8..dd2751d 100644 --- a/packages/db/drizzle-checksums.json +++ b/packages/db/drizzle-checksums.json @@ -25,6 +25,6 @@ "0020_silver_payments.sql": "9686235c75453f1eaa016f2f4ab7fce8fe964c76a4e3515987a2b9f90bd7b1ad", "0021_sharp_payer.sql": "973596e154382984ba7769979ea58298b6d93c5139540854be01e8b283ddb4f1", "0022_carry_purchase_history.sql": "f031c9736e43e71eec3263a323332c29de9324c6409db034b0760051c8a9f074", - "0023_huge_vision.sql": "129f5174f645a855b08af98335fd63a11b344ac5adc5875302229dbf4b898d19" + "0023_huge_vision.sql": "9a682e8b62fc6c54711ccd7bb912dd7192e278f546d5853670bea6a0a4585c1c" } } diff --git a/packages/db/drizzle/0023_huge_vision.sql b/packages/db/drizzle/0023_huge_vision.sql index 1ae844a..40ee0e5 100644 --- a/packages/db/drizzle/0023_huge_vision.sql +++ b/packages/db/drizzle/0023_huge_vision.sql @@ -21,30 +21,11 @@ CREATE TABLE "ad_hoc_notifications" ( "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint -CREATE TABLE "payment_purchase_allocations" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "payment_record_id" uuid NOT NULL, - "purchase_id" uuid NOT NULL, - "member_id" uuid NOT NULL, - "amount_minor" bigint NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "purchase_messages" ADD COLUMN "cycle_id" uuid;--> statement-breakpoint -ALTER TABLE "purchase_messages" ADD COLUMN "payer_member_id" uuid;--> statement-breakpoint ALTER TABLE "ad_hoc_notifications" ADD CONSTRAINT "ad_hoc_notifications_household_id_households_id_fk" FOREIGN KEY ("household_id") REFERENCES "public"."households"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "ad_hoc_notifications" ADD CONSTRAINT "ad_hoc_notifications_creator_member_id_members_id_fk" FOREIGN KEY ("creator_member_id") REFERENCES "public"."members"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint ALTER TABLE "ad_hoc_notifications" ADD CONSTRAINT "ad_hoc_notifications_assignee_member_id_members_id_fk" FOREIGN KEY ("assignee_member_id") REFERENCES "public"."members"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint ALTER TABLE "ad_hoc_notifications" ADD CONSTRAINT "ad_hoc_notifications_cancelled_by_member_id_members_id_fk" FOREIGN KEY ("cancelled_by_member_id") REFERENCES "public"."members"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "payment_purchase_allocations" ADD CONSTRAINT "payment_purchase_allocations_payment_record_id_payment_records_id_fk" FOREIGN KEY ("payment_record_id") REFERENCES "public"."payment_records"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "payment_purchase_allocations" ADD CONSTRAINT "payment_purchase_allocations_purchase_id_purchase_messages_id_fk" FOREIGN KEY ("purchase_id") REFERENCES "public"."purchase_messages"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "payment_purchase_allocations" ADD CONSTRAINT "payment_purchase_allocations_member_id_members_id_fk" FOREIGN KEY ("member_id") REFERENCES "public"."members"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE INDEX "ad_hoc_notifications_due_idx" ON "ad_hoc_notifications" USING btree ("status","scheduled_for");--> statement-breakpoint CREATE INDEX "ad_hoc_notifications_household_status_idx" ON "ad_hoc_notifications" USING btree ("household_id","status","scheduled_for");--> statement-breakpoint CREATE INDEX "ad_hoc_notifications_creator_idx" ON "ad_hoc_notifications" USING btree ("creator_member_id");--> statement-breakpoint CREATE INDEX "ad_hoc_notifications_assignee_idx" ON "ad_hoc_notifications" USING btree ("assignee_member_id");--> statement-breakpoint -CREATE INDEX "payment_purchase_allocations_payment_idx" ON "payment_purchase_allocations" USING btree ("payment_record_id");--> statement-breakpoint -CREATE INDEX "payment_purchase_allocations_purchase_member_idx" ON "payment_purchase_allocations" USING btree ("purchase_id","member_id");--> statement-breakpoint -ALTER TABLE "purchase_messages" ADD CONSTRAINT "purchase_messages_cycle_id_billing_cycles_id_fk" FOREIGN KEY ("cycle_id") REFERENCES "public"."billing_cycles"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "purchase_messages" ADD CONSTRAINT "purchase_messages_payer_member_id_members_id_fk" FOREIGN KEY ("payer_member_id") REFERENCES "public"."members"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "purchase_messages_cycle_idx" ON "purchase_messages" USING btree ("cycle_id"); \ No newline at end of file