[#82] Rename assets/asset_dependencies tables to reflect AssetBundle/PreloadData origin#84
Merged
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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:
assets→assetbundle_assets,asset_view→assetbundle_asset_view,asset_dependencies→preload_dependencies,asset_dependencies_view→preload_dependencies_view; updatedInit.sqljoins and bumpedPRAGMA user_version = 2. - Updated writers/handlers and the
find-refstool 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(seeAnalyzer/Resources/AssetBundle.sql): the SQL definespreload_dependencieswithout 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 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(); |
Collaborator
Author
There was a problem hiding this comment.
Claude noticed the same thing and opened issue 83 already
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #82.
The
assetsandasset_dependenciestables (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 theasset_bundlestable,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
analyzedatabaseuser_versionis bumped1 -> 2.assets(table)assetbundle_assetsasset_view(view)assetbundle_asset_viewasset_dependencies(table)preload_dependenciesasset_dependencies_view(view)preload_dependencies_viewasset_dependencies_object/asset_dependencies_dependencypreload_dependencies_object/preload_dependencies_dependencyNaming rationale:
assetbundle_assets— populated only from the AssetBundle object'sm_Container, so empty for Player/ContentDirectory builds.preload_dependencies— populated from the AssetBundle object'sm_PreloadTable, the synthetic scene object's contents, and thePreloadDataobject'sm_Assets. ThePreloadDataobject also appears in Player builds, so this table is not exclusive to AssetBundles.Compatibility:
find-refsqueries these tables, so itsRequiredSchemaVersionis raised to2. Runningfind-refsagainst a database produced by an olderanalyzenow reports the unsupported-schema message and asks the user to re-runanalyze(rather than failing on a missing table).Changes
Analyzer/Resources/AssetBundle.sql,Analyzer/Resources/Init.sql): renamed the two tables, two views, and two indexes; updated the twoview_material_*_refsviews that join the assets table; bumpedPRAGMA user_version.AssetBundleHandler,PreloadDataHandler, andSerializedFileSQLiteWriter(insert statements, index creation, comments); renamed theAddAssetDependencycommand class toAddPreloadDependency.ReferenceFinder/ReferenceFinderTool.cs): updated both queries and raisedRequiredSchemaVersion.SELECT COUNT(*) FROM assetsassertions in three test files.Documentation/analyzer.mdandDocumentation/analyze-examples.md.Note:
Analyzer/Properties/Resources.Designer.csstill shows the old names in its auto-generated XML-doc preview. That file is generated from the.sqlfiles viaResXFileRef, 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).analyzeonTestCommon/Data/LeadingEdgeBuilds/AssetBundles; confirmeduser_version = 2, all four new tables/views present, no old names remain, andassetbundle_assetspopulated.