refactor(backend): simplify media schema and recording metadata

This commit is contained in:
2026-03-11 17:15:00 +00:00
parent 662d8d7b90
commit c6919d8174
18 changed files with 223 additions and 113 deletions

View File

@@ -1 +1 @@
ALTER TABLE "users" ADD COLUMN "password_hash" varchar(255) NOT NULL;
ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "password_hash" varchar(255) NOT NULL;

View File

@@ -0,0 +1,39 @@
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";

View File

@@ -99,6 +99,13 @@
"when": 1770800000000,
"tag": "0013_users_password_hash_nullable",
"breakpoints": true
},
{
"idx": 14,
"version": "7",
"when": 1770900000000,
"tag": "0014_schema_simplification",
"breakpoints": true
}
]
}