Files
Final-Year-Project/Backend/drizzle/0014_schema_simplification.sql

40 lines
1012 B
SQL

ALTER TABLE "device_commands" RENAME TO "commands";--> statement-breakpoint
ALTER TABLE "push_notifications" RENAME TO "notification_deliveries";--> statement-breakpoint
ALTER TABLE "recordings" ALTER COLUMN "stream_session_id" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "recordings" ALTER COLUMN "requester_device_id" DROP NOT NULL;--> statement-breakpoint
INSERT INTO "recordings" (
"id",
"owner_user_id",
"stream_session_id",
"camera_device_id",
"requester_device_id",
"event_id",
"object_key",
"bucket",
"duration_seconds",
"size_bytes",
"status",
"available_at",
"error",
"created_at",
"updated_at"
)
SELECT
"id",
"user_id",
NULL,
"device_id",
NULL,
"event_id",
"object_key",
"bucket",
NULL,
NULL,
CASE WHEN "download_url" IS NOT NULL THEN 'ready' ELSE 'awaiting_upload' END,
CASE WHEN "download_url" IS NOT NULL THEN "updated_at" ELSE NULL END,
NULL,
"created_at",
"updated_at"
FROM "videos";--> statement-breakpoint
DROP TABLE "videos";