Skip to content

Commit

Permalink
Merge branch 'dev' into feat/enhance-filter-modification
Browse files Browse the repository at this point in the history
  • Loading branch information
freds-dev authored Dec 18, 2024
2 parents 23d7578 + 4b18bc2 commit d09f8cb
Show file tree
Hide file tree
Showing 4 changed files with 980 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/schema/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export const deviceToLocation = pgTable(
{
deviceId: text("device_id")
.notNull()
.references(() => device.id),
.references(() => device.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
locationId: integer("location_id")
.notNull()
.references(() => location.id),
Expand Down
7 changes: 7 additions & 0 deletions drizzle/0011_delete_device_location.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE "device_to_location" DROP CONSTRAINT "device_to_location_device_id_device_id_fk";
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "device_to_location" ADD CONSTRAINT "device_to_location_device_id_device_id_fk" FOREIGN KEY ("device_id") REFERENCES "public"."device"("id") ON DELETE cascade ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Loading

0 comments on commit d09f8cb

Please sign in to comment.