diff --git a/Client/origin-client/autoloads/ModelCache.gd b/Client/origin-client/autoloads/ModelCache.gd index aa256c7..f8f9520 100644 --- a/Client/origin-client/autoloads/ModelCache.gd +++ b/Client/origin-client/autoloads/ModelCache.gd @@ -2,61 +2,105 @@ extends Node ## ModelCache — downloads and caches .glb / .gltf 3D models from CDN. ## ## Usage: -## ModelCache.load_model(url, func(node: Node3D): ...) +## ModelCache.load_model(url, func(node: Node3D): ..., etag) ## ## The callback receives a freshly-instantiated Node3D on success, or null on -## failure. Multiple callers requesting the same URL share a single download. -## Parsed PackedScenes are kept in memory so re-instantiation is instant. -## Raw GLB bytes are written to: -## user://remote_model_cache/.bin +## failure. Multiple callers requesting the same URL+ETag share a single +## download. Parsed PackedScenes are kept in memory so re-instantiation is +## instant. Raw GLB bytes are written to: +## user://remote_model_cache/.bin ## so subsequent app launches skip the download. +## +## Cache versioning: +## A sentinel file "user://remote_model_cache/_cache_ver" stores the current +## cache scheme version. When the scheme changes (bump _CACHE_VER), all +## stale .bin files from the old scheme are purged on first launch. const _CACHE_DIR := "user://remote_model_cache" +const _CACHE_VER := "v2" # bump this when the disk-key scheme changes # On web exports, direct CDN fetches are blocked by CORS (Ceph RadosGW doesn't send # Access-Control-Allow-Origin). Route through the game server proxy instead. const _CDN_BASE := "https://cdn.aeternalisgames.com" const _PROXY_BASE := "https://hub.aeternalisgames.com/cdn" -# url (String) → PackedScene or null (null means "tried and failed") +# cache-key (String) → PackedScene or null (null means "tried and failed") static var _mem: Dictionary = {} -# url (String) → Array[Callable] (callbacks waiting on an in-flight download) +# cache-key (String) → Array[Callable] (callbacks waiting on an in-flight download) static var _pending: Dictionary = {} func _ready() -> void: DirAccess.make_dir_recursive_absolute(_CACHE_DIR) + _migrate_cache() + + +## Purge all .bin files if the cache version sentinel doesn't match _CACHE_VER. +## This evicts entries written under an old disk-key scheme so stale models +## are re-downloaded with the new scheme. +func _migrate_cache() -> void: + var ver_path := _CACHE_DIR + "/_cache_ver" + var stored := "" + if FileAccess.file_exists(ver_path): + var f := FileAccess.open(ver_path, FileAccess.READ) + if f: + stored = f.get_as_text().strip_edges() + f.close() + + if stored == _CACHE_VER: + return + + # Version mismatch — delete every .bin file in the cache directory. + var dir := DirAccess.open(_CACHE_DIR) + if dir: + dir.list_dir_begin() + var name := dir.get_next() + while name != "": + if name.ends_with(".bin"): + DirAccess.remove_absolute(_CACHE_DIR + "/" + name) + name = dir.get_next() + dir.list_dir_end() + + # Write new sentinel. + var f := FileAccess.open(ver_path, FileAccess.WRITE) + if f: + f.store_string(_CACHE_VER) + f.close() ## Remove a cached entry (memory + disk) so the next load_model call re-downloads it. ## Use before retrying a previously-failed URL. -func evict(url: String) -> void: - _mem.erase(url) - var disk := _disk_path(url) +func evict(url: String, etag: String = "") -> void: + var key := _cache_key(url, etag) + _mem.erase(key) + var disk := _disk_path(url, etag) if FileAccess.file_exists(disk): DirAccess.remove_absolute(disk) ## Request a model by CDN URL. ## callback(node: Node3D) is called on the main thread; node may be null. -## If the same URL is already downloading, callbacks are queued and all +## If the same URL+ETag is already downloading, callbacks are queued and all ## fire together when the download completes. -func load_model(url: String, callback: Callable) -> void: +## etag: the ContentETag from the server DTO (empty string = no etag, use URL only). +func load_model(url: String, callback: Callable, etag: String = "") -> void: + var key := _cache_key(url, etag) + var disk := _disk_path(url, etag) + # 1 — memory hit - if _mem.has(url): - var packed: PackedScene = _mem[url] + if _mem.has(key): + var packed: PackedScene = _mem[key] callback.call(packed.instantiate() if packed != null else null) return # 2 — disk hit (bytes from previous session) - var disk := _disk_path(url) if FileAccess.file_exists(disk): var bytes := FileAccess.get_file_as_bytes(disk) if not bytes.is_empty(): var packed := _parse_gltf(bytes) if packed != null: - _mem[url] = packed + _mem[key] = packed callback.call(packed.instantiate()) return # Corrupted cache file — delete and re-download. @@ -64,13 +108,13 @@ func load_model(url: String, callback: Callable) -> void: DirAccess.remove_absolute(disk) # 3 — already downloading → queue - if _pending.has(url): - _pending[url].append(callback) + if _pending.has(key): + _pending[key].append(callback) return # 4 — start download - _pending[url] = [callback] - _download(url, disk) + _pending[key] = [callback] + _download(url, key, disk) ## Returns the URL to actually fetch — on web, rewrites CDN URLs to go through @@ -81,7 +125,7 @@ func _fetch_url(url: String) -> String: return url -func _download(url: String, disk: String) -> void: +func _download(url: String, key: String, disk: String) -> void: var fetch := _fetch_url(url) print("ModelCache: downloading — %s" % fetch) var http := HTTPRequest.new() @@ -94,8 +138,8 @@ func _download(url: String, disk: String) -> void: http.get_signal_connection_list("request_completed").clear() http.queue_free() - var callbacks: Array = _pending.get(url, []) - _pending.erase(url) + var callbacks: Array = _pending.get(key, []) + _pending.erase(key) # Log details to help diagnose content-type / truncation issues. var ct := "" @@ -130,7 +174,7 @@ func _download(url: String, disk: String) -> void: # Parse directly from the downloaded bytes — avoids any file-path quirks. var packed := _parse_gltf(body) - _mem[url] = packed + _mem[key] = packed if packed != null: # Only write a good file to the disk cache. @@ -146,8 +190,8 @@ func _download(url: String, disk: String) -> void: var err := http.request(fetch) if err != OK: push_warning("ModelCache: request() error %d — %s" % [err, fetch]) - var callbacks: Array = _pending.get(url, []) - _pending.erase(url) + var callbacks: Array = _pending.get(key, []) + _pending.erase(key) for cb: Callable in callbacks: cb.call(null) http.get_signal_connection_list("request_completed").clear() @@ -196,5 +240,12 @@ func _parse_gltf(data: PackedByteArray) -> PackedScene: return packed -func _disk_path(url: String) -> String: - return _CACHE_DIR + "/" + url.sha256_text() + ".bin" +## Disk key is sha256(url + "#" + etag) when etag is non-empty, or sha256(url) otherwise. +func _cache_key(url: String, etag: String) -> String: + if etag.is_empty(): + return url + return url + "#" + etag + + +func _disk_path(url: String, etag: String = "") -> String: + return _CACHE_DIR + "/" + _cache_key(url, etag).sha256_text() + ".bin" diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index f80ed84..fe15017 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -793,6 +793,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) var def := ContentCache.get_definition(def_id) var model_asset := _find_model3d_asset(def) var model_url := str(model_asset.get("cdnUrl", "")) + var model_etag := str(model_asset.get("contentETag", "")) if model_url.is_empty(): return @@ -824,7 +825,7 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) return if model_node == null: # Download failed — schedule a background retry. - _schedule_model_retry(iid, model_url, 1) + _schedule_model_retry(iid, model_url, 1, model_etag) return # Remove the placeholder MeshInstance3D. @@ -861,13 +862,13 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false) _anim_players[iid] = ap if ap != null: _play_unit_anim(iid, "idle", true) - ) + , model_etag) ## Schedule a retry to (re)download the real GLB model for a unit. ## attempt is 1-based; retries stop after MAX_RETRIES. ## Only schedules if no equal-or-later retry is already pending for this unit. -func _schedule_model_retry(iid: String, model_url: String, attempt: int) -> void: +func _schedule_model_retry(iid: String, model_url: String, attempt: int, etag: String = "") -> void: const MAX_RETRIES := 10 if attempt > MAX_RETRIES: return @@ -877,14 +878,14 @@ func _schedule_model_retry(iid: String, model_url: String, attempt: int) -> void _unit_model_retries[iid] = attempt print("[GameScreen] Model retry %d/%d scheduled for %s in 60s" % [attempt, MAX_RETRIES, iid]) get_tree().create_timer(60.0).timeout.connect( - func() -> void: _do_model_retry(iid, model_url, attempt), + func() -> void: _do_model_retry(iid, model_url, attempt, etag), CONNECT_ONE_SHOT) ## Execute one model retry attempt. Evicts the URL so ModelCache re-downloads it. ## If successful, swaps out the placeholder and starts idle animation. ## If it fails again, schedules the next attempt. -func _do_model_retry(iid: String, model_url: String, attempt: int) -> void: +func _do_model_retry(iid: String, model_url: String, attempt: int, etag: String = "") -> void: # Was this attempt superseded by a later scheduled retry? if _unit_model_retries.get(iid, -1) != attempt: return @@ -893,12 +894,12 @@ func _do_model_retry(iid: String, model_url: String, attempt: int) -> void: _unit_model_retries.erase(iid) return print("[GameScreen] Model retry %d — downloading %s" % [attempt, model_url]) - ModelCache.evict(model_url) + ModelCache.evict(model_url, etag) ModelCache.load_model(model_url, func(model_node: Node3D) -> void: if model_node == null: # Still failing — try again later. _unit_model_retries.erase(iid) - _schedule_model_retry(iid, model_url, attempt + 1) + _schedule_model_retry(iid, model_url, attempt + 1, etag) return _unit_model_retries.erase(iid) # Use the CURRENT body (may differ from when the retry was first scheduled). @@ -933,7 +934,7 @@ func _do_model_retry(iid: String, model_url: String, attempt: int) -> void: if ap != null: _play_unit_anim(iid, "idle", true) print("[GameScreen] Model retry %d succeeded for %s" % [attempt, iid]) - ) + , etag) ## Returns the first Model3D asset dict for a card definition, or {} if none. diff --git a/Server/src/SOR.Admin/Components/Pages/Content/CdnBrowser.razor b/Server/src/SOR.Admin/Components/Pages/Content/CdnBrowser.razor index a619f10..7653838 100644 --- a/Server/src/SOR.Admin/Components/Pages/Content/CdnBrowser.razor +++ b/Server/src/SOR.Admin/Components/Pages/Content/CdnBrowser.razor @@ -578,7 +578,7 @@ window.sorCdn = { try { var key = $"{_activePrefix}{file.Name}"; - await UploadFileToKeyAsync(key, file); + await UploadFileToKeyAsync(key, file); // ETag not propagated for brand-new uploads (no CardAsset row yet) await UpsertUploadRecordAsync(key, file.ContentType, _uploadIsAiGenerated); _message = $"Uploaded {file.Name}."; _isError = false; @@ -606,8 +606,9 @@ window.sorCdn = { try { - await UploadFileToKeyAsync(_replaceTarget.Key, file); + var etag = await UploadFileToKeyAsync(_replaceTarget.Key, file); await UpsertUploadRecordAsync(_replaceTarget.Key, file.ContentType, _replaceIsAiGenerated); + await PropagateAssetETagAsync(_replaceTarget.PublicUrl, etag); _message = $"Replaced {_replaceTarget.Key}."; _isError = false; await LoadAsync(reset: true); @@ -686,7 +687,8 @@ window.sorCdn = { _replaceIsAiGenerated = false; } - private async Task UploadFileToKeyAsync(string key, IBrowserFile file) + /// Upload to ; returns the S3 ETag. + private async Task UploadFileToKeyAsync(string key, IBrowserFile file) { const long maxUploadBytes = 100 * 1024 * 1024; @@ -705,7 +707,36 @@ window.sorCdn = { DisableDefaultChecksumValidation = true, }; - await S3.PutObjectAsync(request); + var response = await S3.PutObjectAsync(request); + return response.ETag; + } + + /// + /// After a replace, update ContentETag on any CardAsset whose CdnUrl matches + /// and touch the parent CardDefinition so the + /// definition_version trigger fires and clients pick up the change. + /// + private async Task PropagateAssetETagAsync(string publicUrl, string? etag) + { + if (string.IsNullOrWhiteSpace(etag)) + return; + + var assets = await Db.Set() + .Include(a => a.CardDefinition) + .Where(a => a.CdnUrl == publicUrl) + .ToListAsync(); + + if (assets.Count == 0) + return; + + var now = DateTimeOffset.UtcNow; + foreach (var asset in assets) + { + asset.ContentETag = etag; + asset.CardDefinition.UpdatedAt = now; + } + + await Db.SaveChangesAsync(); } private async Task UpsertUploadRecordAsync(string key, string? contentType, bool isAiGenerated) diff --git a/Server/src/SOR.Cdn/CdnUploadResult.cs b/Server/src/SOR.Cdn/CdnUploadResult.cs index bb69ebd..1964c4e 100644 --- a/Server/src/SOR.Cdn/CdnUploadResult.cs +++ b/Server/src/SOR.Cdn/CdnUploadResult.cs @@ -8,4 +8,6 @@ public sealed record CdnUploadResult( /// Fully-qualified public URL. Null on failure. string? PublicUrl, /// Error description. Null on success. - string? Error); + string? Error, + /// ETag returned by S3 for the uploaded object. Null on failure or if S3 did not return one. + string? ETag = null); diff --git a/Server/src/SOR.Cdn/HttpCdnClient.cs b/Server/src/SOR.Cdn/HttpCdnClient.cs index 74ba84f..3d3b9cb 100644 --- a/Server/src/SOR.Cdn/HttpCdnClient.cs +++ b/Server/src/SOR.Cdn/HttpCdnClient.cs @@ -51,11 +51,11 @@ public sealed class S3CdnClient : ICdnClient // and CDN edges can cache aggressively without ever serving stale bytes. request.Headers["Cache-Control"] = "public, max-age=31536000, immutable"; - await _s3.PutObjectAsync(request, ct); + var response = await _s3.PutObjectAsync(request, ct); var publicUrl = $"{_options.PublicBaseUrl.TrimEnd('/')}/{key}"; _logger.LogInformation("CDN upload succeeded: {Url}", publicUrl); - return new CdnUploadResult(true, key, publicUrl, null); + return new CdnUploadResult(true, key, publicUrl, null, response.ETag); } catch (Exception ex) { diff --git a/Server/src/SOR.Content/ContentMessages.cs b/Server/src/SOR.Content/ContentMessages.cs index 58ef099..92d1d7b 100644 --- a/Server/src/SOR.Content/ContentMessages.cs +++ b/Server/src/SOR.Content/ContentMessages.cs @@ -119,7 +119,9 @@ public sealed record CardAssetDto( bool IsAiGenerated, // Model3D config (asset/file-level) string? ModelFacingDirection, - string? ModelTintMaskUrl); + string? ModelTintMaskUrl, + // Cache-busting ETag updated whenever the file is replaced via CDN browser + string? ContentETag = null); public sealed record CardAnimationBindingDto( Guid Id, diff --git a/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs b/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs index cc159de..7eead34 100644 --- a/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs +++ b/Server/src/SOR.Content/Handlers/ContentDtoMapper.cs @@ -60,7 +60,8 @@ internal static class ContentDtoMapper a.MimeType, a.IsAiGenerated, a.ModelFacingDirection, - a.ModelTintMaskUrl)), + a.ModelTintMaskUrl, + a.ContentETag)), AnimationBindings: c.AnimationBindings.Select(b => new CardAnimationBindingDto( b.Id, b.ActionName, diff --git a/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs b/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs index 2b42b61..5511c50 100644 --- a/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs +++ b/Server/src/SOR.Database/Entities/Catalog/CardAsset.cs @@ -38,6 +38,12 @@ public sealed class CardAsset // ───────────────────────────────────────────────────────────────────────── + /// + /// S3 ETag of the uploaded object, updated whenever the file is replaced via the CDN browser. + /// Included in the content sync DTO so clients can use it as a cache-busting key. + /// + public string? ContentETag { get; set; } + /// /// True if this asset was generated by an AI tool (Midjourney, DALL-E, Stable Diffusion, etc.). /// Surfaced in the AI art tracker report in the admin portal. diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260318000001_AddAssetContentETag.Designer.cs b/Server/src/SOR.Database/Migrations/Catalog/20260318000001_AddAssetContentETag.Designer.cs new file mode 100644 index 0000000..79f0a49 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260318000001_AddAssetContentETag.Designer.cs @@ -0,0 +1,505 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + [DbContext(typeof(CatalogDbContext))] + [Migration("20260318000001_AddAssetContentETag")] + partial class AddAssetContentETag + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("catalog") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationTrackName") + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CastSoundCdnUrl") + .HasColumnType("text"); + + b.Property("ImpactSoundCdnUrl") + .HasColumnType("text"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "ActionName") + .IsUnique(); + + b.ToTable("card_animation_bindings", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AssetType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContentETag") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.Property("MimeType") + .HasColumnType("text"); + + b.Property("ModelFacingDirection") + .HasColumnType("text"); + + b.Property("ModelTintMaskUrl") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "AssetType"); + + b.ToTable("card_assets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AbilitiesJson") + .HasColumnType("jsonb") + .HasColumnName("abilities"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("AttackSoundUrl") + .HasColumnType("text"); + + b.Property("AttackType") + .HasColumnType("text"); + + b.Property("BlockedSoundUrl") + .HasColumnType("text"); + + b.Property("CanAttack") + .HasColumnType("boolean"); + + b.Property("CanBeAttacked") + .HasColumnType("boolean"); + + b.Property("CanBeBlocked") + .HasColumnType("boolean"); + + b.Property("CanBeObstructed") + .HasColumnType("boolean"); + + b.Property("CanBeSacrificed") + .HasColumnType("boolean"); + + b.Property("CanDefend") + .HasColumnType("boolean"); + + b.Property("CanMove") + .HasColumnType("boolean"); + + b.Property("CanUseAbility") + .HasColumnType("boolean"); + + b.Property("CardType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CollectorNumber") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Damage") + .HasColumnType("integer"); + + b.Property("DamagedSoundUrl") + .HasColumnType("text"); + + b.Property("DeathSoundUrl") + .HasColumnType("text"); + + b.Property("DefinitionVersion") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasDefaultValue(0L); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EffectsJson") + .HasColumnType("jsonb") + .HasColumnName("effects"); + + b.Property("Genus") + .HasColumnType("text[]"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("IsRetired") + .HasColumnType("boolean"); + + b.Property("MaxAttackRange") + .HasColumnType("integer"); + + b.Property("MaxChannelRange") + .HasColumnType("integer"); + + b.Property("MaxDefense") + .HasColumnType("integer"); + + b.Property("MaxHealth") + .HasColumnType("integer"); + + b.Property("MinAttackRange") + .HasColumnType("integer"); + + b.Property("MinChannelRange") + .HasColumnType("integer"); + + b.Property("ModelScale") + .HasColumnType("real"); + + b.Property("ModelTintColor") + .HasColumnType("text"); + + b.Property("MoveSoundUrl") + .HasColumnType("text"); + + b.Property("MovementPoints") + .HasColumnType("integer"); + + b.Property("MovementType") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherCostsJson") + .HasColumnType("jsonb") + .HasColumnName("other_costs"); + + b.Property("PreviousTierId") + .HasColumnType("uuid"); + + b.Property("Rarity") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequiresLos") + .HasColumnType("boolean"); + + b.Property("RetiredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SetId") + .HasColumnType("uuid"); + + b.Property("SpCost") + .HasColumnType("integer"); + + b.Property("StCost") + .HasColumnType("integer"); + + b.Property("TerramorphaMode") + .HasColumnType("text"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Affinity"); + + b.HasIndex("CardType"); + + b.HasIndex("DefinitionVersion"); + + b.HasIndex("Name"); + + b.HasIndex("PreviousTierId"); + + b.HasIndex("Rarity"); + + b.HasIndex("SetId"); + + b.HasIndex("IsPublished", "SetId"); + + b.ToTable("card_definitions", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReleaseDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("card_sets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CdnUploadRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContentType") + .HasColumnType("text"); + + b.Property("IsAiGenerated") + .HasColumnType("boolean"); + + b.Property("ObjectKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("text"); + + b.Property("PublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("UploadedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("IsAiGenerated"); + + b.HasIndex("ObjectKey") + .IsUnique(); + + b.HasIndex("Prefix"); + + b.ToTable("cdn_upload_records", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.GameAudioConfig", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Context") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("TrackCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("TrackName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Context"); + + b.HasIndex("IsActive"); + + b.ToTable("game_audio_configs", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.TileBottomModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CdnKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("PublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("IsActive"); + + b.ToTable("tile_bottom_models", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.TileModelBinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModelCdnKey") + .IsRequired() + .HasColumnType("text"); + + b.Property("ModelPublicUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("Shape") + .IsRequired() + .HasColumnType("text"); + + b.Property("TexturePublicUrl") + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Affinity", "Shape") + .IsUnique(); + + b.ToTable("tile_model_bindings", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("AnimationBindings") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("Assets") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "PreviousTier") + .WithMany() + .HasForeignKey("PreviousTierId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set") + .WithMany("Cards") + .HasForeignKey("SetId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("PreviousTier"); + + b.Navigation("Set"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Navigation("AnimationBindings"); + + b.Navigation("Assets"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Navigation("Cards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260318000001_AddAssetContentETag.cs b/Server/src/SOR.Database/Migrations/Catalog/20260318000001_AddAssetContentETag.cs new file mode 100644 index 0000000..6977a94 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260318000001_AddAssetContentETag.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + /// + public partial class AddAssetContentETag : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ContentETag", + schema: "catalog", + table: "card_assets", + type: "text", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ContentETag", + schema: "catalog", + table: "card_assets"); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs index cdb1789..dfd7594 100644 --- a/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs +++ b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs @@ -77,6 +77,9 @@ namespace SOR.Database.Migrations.Catalog .IsRequired() .HasColumnType("text"); + b.Property("ContentETag") + .HasColumnType("text"); + b.Property("CreatedAt") .HasColumnType("timestamp with time zone");