|
1 | 1 | -- Game Foundry Studio DEV database DDL |
2 | 2 | -- Group: Asset |
3 | 3 | -- Ownership: docs_build/database/ddl/asset.sql |
4 | | --- Runtime Local DB schemas for these tables are currently owned by src/dev-runtime/persistence/mock-db-store.js. |
5 | | --- This grouped file documents the product/tool ownership boundary until an executable migration PR promotes the table DDL. |
| 4 | +-- Target DEV database: gamefoundry_dev |
| 5 | +-- Scope: executable grouped table DDL for active Local DB/server API migration. |
| 6 | +-- Authoritative key values are generated by the server/API layer unless a later DEV-only seed exception explicitly applies. |
6 | 7 | -- Owned tables: asset_role_definitions, asset_library_items, asset_storage_objects, asset_import_events, asset_validation_items |
| 8 | +CREATE TABLE IF NOT EXISTS asset_role_definitions ( |
| 9 | + key text PRIMARY KEY, |
| 10 | + "id" text, |
| 11 | + "label" text, |
| 12 | + "storageFolder" text, |
| 13 | + "extensions" jsonb NOT NULL DEFAULT '[]'::jsonb, |
| 14 | + "mimeTypes" jsonb NOT NULL DEFAULT '[]'::jsonb, |
| 15 | + "previewBehavior" text, |
| 16 | + "uploadEnabled" boolean NOT NULL DEFAULT false, |
| 17 | + "inputMode" text, |
| 18 | + "usageRoles" jsonb NOT NULL DEFAULT '[]'::jsonb, |
| 19 | + "maxSizeBytes" integer NOT NULL DEFAULT 0, |
| 20 | + "dbFields" jsonb NOT NULL DEFAULT '[]'::jsonb, |
| 21 | + "validationNeeds" jsonb NOT NULL DEFAULT '[]'::jsonb, |
| 22 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 23 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 24 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 25 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 26 | +); |
7 | 27 |
|
8 | | --- Server/API layer owns authoritative key generation for records in this group. |
| 28 | +CREATE INDEX IF NOT EXISTS idx_asset_role_definitions_createdby ON asset_role_definitions ("createdBy"); |
| 29 | +CREATE INDEX IF NOT EXISTS idx_asset_role_definitions_updatedby ON asset_role_definitions ("updatedBy"); |
| 30 | + |
| 31 | +CREATE TABLE IF NOT EXISTS asset_library_items ( |
| 32 | + key text PRIMARY KEY, |
| 33 | + "id" text, |
| 34 | + "gameId" text REFERENCES game_workspace_games(key), |
| 35 | + "ownerProjectId" text REFERENCES game_workspace_games(key), |
| 36 | + "ownerUserId" text REFERENCES users(key), |
| 37 | + "assetRole" text, |
| 38 | + "assetRoleLabel" text, |
| 39 | + "assetType" text, |
| 40 | + "description" text, |
| 41 | + "tagKeys" jsonb NOT NULL DEFAULT '[]'::jsonb, |
| 42 | + "name" text, |
| 43 | + "source" text, |
| 44 | + "reference" text, |
| 45 | + "fileName" text, |
| 46 | + "originalName" text, |
| 47 | + "mimeType" text, |
| 48 | + "size" integer NOT NULL DEFAULT 0, |
| 49 | + "checksum" text, |
| 50 | + "storageObjectId" text, |
| 51 | + "storedPath" text, |
| 52 | + "path" text, |
| 53 | + "previewKind" text, |
| 54 | + "role" text, |
| 55 | + "type" text, |
| 56 | + "usage" text, |
| 57 | + "status" text, |
| 58 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 59 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 60 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 61 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 62 | +); |
| 63 | + |
| 64 | +CREATE INDEX IF NOT EXISTS idx_asset_library_items_gameid ON asset_library_items ("gameId"); |
| 65 | +CREATE INDEX IF NOT EXISTS idx_asset_library_items_ownerprojectid ON asset_library_items ("ownerProjectId"); |
| 66 | +CREATE INDEX IF NOT EXISTS idx_asset_library_items_owneruserid ON asset_library_items ("ownerUserId"); |
| 67 | +CREATE INDEX IF NOT EXISTS idx_asset_library_items_storageobjectid ON asset_library_items ("storageObjectId"); |
| 68 | +CREATE INDEX IF NOT EXISTS idx_asset_library_items_createdby ON asset_library_items ("createdBy"); |
| 69 | +CREATE INDEX IF NOT EXISTS idx_asset_library_items_updatedby ON asset_library_items ("updatedBy"); |
| 70 | + |
| 71 | +CREATE TABLE IF NOT EXISTS asset_storage_objects ( |
| 72 | + key text PRIMARY KEY, |
| 73 | + "id" text, |
| 74 | + "assetId" text REFERENCES asset_library_items(key), |
| 75 | + "gameId" text REFERENCES game_workspace_games(key), |
| 76 | + "ownerProjectId" text REFERENCES game_workspace_games(key), |
| 77 | + "role" text, |
| 78 | + "originalName" text, |
| 79 | + "storedPath" text, |
| 80 | + "mimeType" text, |
| 81 | + "size" integer NOT NULL DEFAULT 0, |
| 82 | + "checksum" text, |
| 83 | + "status" text, |
| 84 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 85 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 86 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 87 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 88 | +); |
| 89 | + |
| 90 | +CREATE INDEX IF NOT EXISTS idx_asset_storage_objects_assetid ON asset_storage_objects ("assetId"); |
| 91 | +CREATE INDEX IF NOT EXISTS idx_asset_storage_objects_gameid ON asset_storage_objects ("gameId"); |
| 92 | +CREATE INDEX IF NOT EXISTS idx_asset_storage_objects_ownerprojectid ON asset_storage_objects ("ownerProjectId"); |
| 93 | +CREATE INDEX IF NOT EXISTS idx_asset_storage_objects_createdby ON asset_storage_objects ("createdBy"); |
| 94 | +CREATE INDEX IF NOT EXISTS idx_asset_storage_objects_updatedby ON asset_storage_objects ("updatedBy"); |
| 95 | + |
| 96 | +CREATE TABLE IF NOT EXISTS asset_import_events ( |
| 97 | + key text PRIMARY KEY, |
| 98 | + "id" text, |
| 99 | + "assetId" text REFERENCES asset_library_items(key), |
| 100 | + "gameId" text REFERENCES game_workspace_games(key), |
| 101 | + "fileName" text, |
| 102 | + "mimeType" text, |
| 103 | + "storedPath" text, |
| 104 | + "status" text, |
| 105 | + "type" text, |
| 106 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 107 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 108 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 109 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 110 | +); |
| 111 | + |
| 112 | +CREATE INDEX IF NOT EXISTS idx_asset_import_events_assetid ON asset_import_events ("assetId"); |
| 113 | +CREATE INDEX IF NOT EXISTS idx_asset_import_events_gameid ON asset_import_events ("gameId"); |
| 114 | +CREATE INDEX IF NOT EXISTS idx_asset_import_events_createdby ON asset_import_events ("createdBy"); |
| 115 | +CREATE INDEX IF NOT EXISTS idx_asset_import_events_updatedby ON asset_import_events ("updatedBy"); |
| 116 | + |
| 117 | +CREATE TABLE IF NOT EXISTS asset_validation_items ( |
| 118 | + key text PRIMARY KEY, |
| 119 | + "id" text, |
| 120 | + "gameId" text REFERENCES game_workspace_games(key), |
| 121 | + "field" text, |
| 122 | + "label" text, |
| 123 | + "status" text, |
| 124 | + "action" text, |
| 125 | + "createdAt" timestamptz NOT NULL DEFAULT now(), |
| 126 | + "updatedAt" timestamptz NOT NULL DEFAULT now(), |
| 127 | + "createdBy" text NOT NULL REFERENCES users(key), |
| 128 | + "updatedBy" text NOT NULL REFERENCES users(key) |
| 129 | +); |
| 130 | + |
| 131 | +CREATE INDEX IF NOT EXISTS idx_asset_validation_items_gameid ON asset_validation_items ("gameId"); |
| 132 | +CREATE INDEX IF NOT EXISTS idx_asset_validation_items_createdby ON asset_validation_items ("createdBy"); |
| 133 | +CREATE INDEX IF NOT EXISTS idx_asset_validation_items_updatedby ON asset_validation_items ("updatedBy"); |
0 commit comments