commit
This commit is contained in:
24
drizzle/0018_organizations_soft_delete_repair.sql
Normal file
24
drizzle/0018_organizations_soft_delete_repair.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
ALTER TABLE "organizations"
|
||||
ADD COLUMN IF NOT EXISTS "is_active" boolean DEFAULT true NOT NULL;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "organizations"
|
||||
ADD COLUMN IF NOT EXISTS "deleted_at" timestamp with time zone;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "organizations"
|
||||
ADD COLUMN IF NOT EXISTS "deleted_by" text;
|
||||
--> statement-breakpoint
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM pg_constraint
|
||||
WHERE conname = 'organizations_deleted_by_users_id_fk'
|
||||
) THEN
|
||||
ALTER TABLE "organizations"
|
||||
ADD CONSTRAINT "organizations_deleted_by_users_id_fk"
|
||||
FOREIGN KEY ("deleted_by")
|
||||
REFERENCES "public"."users"("id")
|
||||
ON DELETE set null
|
||||
ON UPDATE no action;
|
||||
END IF;
|
||||
END $$;
|
||||
Reference in New Issue
Block a user