Skip to content

[#82] Rename assets/asset_dependencies tables to reflect AssetBundle/PreloadData origin#84

Merged
SkowronskiAndrew merged 2 commits into
mainfrom
issue82-rename-asset
Jul 6, 2026
Merged

[#82] Rename assets/asset_dependencies tables to reflect AssetBundle/PreloadData origin#84
SkowronskiAndrew merged 2 commits into
mainfrom
issue82-rename-asset

Conversation

@SkowronskiAndrew

Copy link
Copy Markdown
Collaborator

Summary

Fixes #82.

The assets and asset_dependencies tables (and their views) had vague names that gave no hint they are AssetBundle/PreloadData-specific and mostly empty for Player and ContentDirectory builds. They were also easy to confuse with the asset_bundles table, serialized_files, and "source assets" in a project. This renames them to reflect what actually populates them.

Schema change

This is a breaking schema change. The analyze database user_version is bumped 1 -> 2.

Before After
assets (table) assetbundle_assets
asset_view (view) assetbundle_asset_view
asset_dependencies (table) preload_dependencies
asset_dependencies_view (view) preload_dependencies_view
index asset_dependencies_object / asset_dependencies_dependency preload_dependencies_object / preload_dependencies_dependency

Naming rationale:

  • assetbundle_assets — populated only from the AssetBundle object's m_Container, so empty for Player/ContentDirectory builds.
  • preload_dependencies — populated from the AssetBundle object's m_PreloadTable, the synthetic scene object's contents, and the PreloadData object's m_Assets. The PreloadData object also appears in Player builds, so this table is not exclusive to AssetBundles.

Compatibility: find-refs queries these tables, so its RequiredSchemaVersion is raised to 2. Running find-refs against a database produced by an older analyze now reports the unsupported-schema message and asks the user to re-run analyze (rather than failing on a missing table).

Changes

  • Schema (Analyzer/Resources/AssetBundle.sql, Analyzer/Resources/Init.sql): renamed the two tables, two views, and two indexes; updated the two view_material_*_refs views that join the assets table; bumped PRAGMA user_version.
  • Writers/handlers: updated AssetBundleHandler, PreloadDataHandler, and SerializedFileSQLiteWriter (insert statements, index creation, comments); renamed the AddAssetDependency command class to AddPreloadDependency.
  • find-refs (ReferenceFinder/ReferenceFinderTool.cs): updated both queries and raised RequiredSchemaVersion.
  • Tests: updated the SELECT COUNT(*) FROM assets assertions in three test files.
  • Docs: updated Documentation/analyzer.md and Documentation/analyze-examples.md.

Note: Analyzer/Properties/Resources.Designer.cs still shows the old names in its auto-generated XML-doc preview. That file is generated from the .sql files via ResXFileRef, so the runtime SQL is correct; only the cosmetic doc comment is stale and will refresh when the ResX generator next runs.

Testing

  • dotnet build UnityDataTools.sln -c Release — clean (0 warnings).
  • dotnet test — full suite green: 234 (UnityDataTool.Tests, incl. find-refs and asset-count coverage) + 62 (Analyzer.Tests).
  • Manual: ran analyze on TestCommon/Data/LeadingEdgeBuilds/AssetBundles; confirmed user_version = 2, all four new tables/views present, no old names remain, and assetbundle_assets populated.

Rename the vaguely-named assets and asset_dependencies tables (and their
views) so it is clear they are populated from the AssetBundle and PreloadData
objects and are mostly empty for Player/ContentDirectory builds:

  assets                -> assetbundle_assets
  asset_view            -> assetbundle_asset_view
  asset_dependencies    -> preload_dependencies
  asset_dependencies_view -> preload_dependencies_view

Bumps the schema user_version 1 -> 2 and raises find-refs'
RequiredSchemaVersion to match, since the renamed tables it queries make
older databases unreadable.
@SkowronskiAndrew SkowronskiAndrew requested a review from Copilot July 6, 2026 01:33
@SkowronskiAndrew SkowronskiAndrew marked this pull request as ready for review July 6, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the analyzer database tables/views assets and asset_dependencies to make their AssetBundle/PreloadData origins explicit, and bumps the analyze DB schema user_version from 1 → 2 so find-refs can reject older databases cleanly.

Changes:

  • Renamed schema objects: assetsassetbundle_assets, asset_viewassetbundle_asset_view, asset_dependenciespreload_dependencies, asset_dependencies_viewpreload_dependencies_view; updated Init.sql joins and bumped PRAGMA user_version = 2.
  • Updated writers/handlers and the find-refs tool to query the new names and require schema v2.
  • Updated tests and documentation to reference the new schema names.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
UnityDataTool.Tests/UnityDataToolPlayerDataTests.cs Updates asset-count assertion to query assetbundle_assets.
UnityDataTool.Tests/UnityDataToolAssetBundleTests.cs Updates asset-count assertion to query assetbundle_assets.
UnityDataTool.Tests/ExpectedDataGenerator.cs Updates expected-data asset-count query to assetbundle_assets.
ReferenceFinder/ReferenceFinderTool.cs Raises required schema version to 2 and updates queries to use assetbundle_assets / assetbundle_asset_view.
Documentation/analyzer.md Renames documented view headings to the new view names.
Documentation/analyze-examples.md Updates narrative references from assets to assetbundle_assets.
Analyzer/SQLite/Writers/SerializedFileSQLiteWriter.cs Renames dependency command usage to AddPreloadDependency and updates comments referencing the renamed table.
Analyzer/SQLite/Handlers/PreloadDataHandler.cs Updates insert SQL to write into preload_dependencies.
Analyzer/SQLite/Handlers/AssetBundleHandler.cs Updates insert SQL to write into assetbundle_assets / preload_dependencies and renames index DDL strings.
Analyzer/SQLite/Commands/SerializedFile/AddPreloadDependency.cs Renames the command class and updates TableName to preload_dependencies.
Analyzer/Resources/Init.sql Updates material views to join assetbundle_assets and bumps PRAGMA user_version to 2.
Analyzer/Resources/AssetBundle.sql Renames the tables/views to the new names and updates view definitions accordingly.
Comments suppressed due to low confidence (1)

Analyzer/SQLite/Commands/SerializedFile/AddPreloadDependency.cs:14

  • The table-definition comment doesn’t match the actual schema created by Resources.AssetBundle (see Analyzer/Resources/AssetBundle.sql): the SQL defines preload_dependencies without a PRIMARY KEY. This comment is misleading for anyone relying on it to understand constraints/uniqueness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Documentation/analyze-examples.md Outdated
Comment on lines 92 to 100
public void Finalize(SqliteConnection db)
{
using var command = new SqliteCommand();
command.Connection = db;
command.CommandText = "CREATE INDEX asset_dependencies_object ON asset_dependencies(object)";
command.CommandText = "CREATE INDEX preload_dependencies_object ON preload_dependencies(object)";
command.ExecuteNonQuery();

command.CommandText = "CREATE INDEX asset_dependencies_dependency ON asset_dependencies(dependency)";
command.CommandText = "CREATE INDEX preload_dependencies_dependency ON preload_dependencies(dependency)";
command.ExecuteNonQuery();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude noticed the same thing and opened issue 83 already

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@SkowronskiAndrew SkowronskiAndrew merged commit 33fcf4a into main Jul 6, 2026
4 of 5 checks passed
@SkowronskiAndrew SkowronskiAndrew deleted the issue82-rename-asset branch July 6, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename vague assets / asset_dependencies tables (and their views) to reflect AssetBundle/PreloadData origin

2 participants