feat(asset): decouple logical assets from physical storage with StorageKey and implement O(1) copy

This commit is contained in:
yiling
2026-05-25 00:52:45 +08:00
parent c5fba746be
commit 5dc3bdb38e
33 changed files with 2203 additions and 273 deletions
@@ -0,0 +1,25 @@
/*
Warnings:
- You are about to drop the column `key` on the `assets` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "assets" DROP COLUMN "key",
ADD COLUMN "storage_key_id" TEXT;
-- CreateTable
CREATE TABLE "storage_keys" (
"id" TEXT NOT NULL,
"key" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "storage_keys_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "storage_keys_key_key" ON "storage_keys"("key");
-- AddForeignKey
ALTER TABLE "assets" ADD CONSTRAINT "assets_storage_key_id_fkey" FOREIGN KEY ("storage_key_id") REFERENCES "storage_keys"("id") ON DELETE SET NULL ON UPDATE CASCADE;