-
Notifications
You must be signed in to change notification settings - Fork 13.8k
feat(assets): add namespaced model_type tags and align tag semantics #14511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
synap5e
wants to merge
7
commits into
master
Choose a base branch
from
synap5e/assets-namespaced-tags
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e163d59
Add namespaced model type asset tags
synap5e 6df0c18
Add explicit asset upload subfolder handling
synap5e 2d46d92
Update asset tests for namespaced tags
synap5e 54d64d9
Reject Windows subfolder paths
synap5e 14266fe
Defer public asset file paths
synap5e 4340337
Advertise model type tag support
synap5e de997d2
Address asset tag review feedback
synap5e File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| """ | ||
| Allow case-sensitive tag names. | ||
|
|
||
| Revision ID: 0005_allow_case_sensitive_tags | ||
| Revises: 0004_drop_tag_type | ||
| Create Date: 2026-06-16 | ||
| """ | ||
|
|
||
| from alembic import op | ||
|
|
||
| revision = "0005_allow_case_sensitive_tags" | ||
| down_revision = "0004_drop_tag_type" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| bind = op.get_bind() | ||
| if bind.dialect.name == "sqlite": | ||
| # SQLite cannot ALTER/DROP CHECK constraints. Recreate the small tag | ||
| # vocabulary table without the lowercase constraint while preserving | ||
| # existing tag names. | ||
| op.execute("PRAGMA foreign_keys=OFF") | ||
| op.execute( | ||
| "CREATE TABLE tags_new (" | ||
| "name VARCHAR(512) NOT NULL, " | ||
| "CONSTRAINT pk_tags PRIMARY KEY (name)" | ||
| ")" | ||
| ) | ||
| op.execute("INSERT INTO tags_new(name) SELECT name FROM tags") | ||
| op.execute("DROP TABLE tags") | ||
| op.execute("ALTER TABLE tags_new RENAME TO tags") | ||
| op.execute("PRAGMA foreign_keys=ON") | ||
| return | ||
|
|
||
| op.drop_constraint("ck_tags_ck_tags_lowercase", "tags", type_="check") | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| # Existing mixed-case tags cannot satisfy the old constraint. Lowercase them | ||
| # before restoring it, merging duplicate vocabulary/link rows that collide. | ||
| op.execute("INSERT OR IGNORE INTO tags(name) SELECT lower(name) FROM tags") | ||
| op.execute( | ||
| "DELETE FROM asset_reference_tags " | ||
| "WHERE rowid NOT IN (" | ||
| " SELECT MIN(rowid) FROM asset_reference_tags " | ||
| " GROUP BY asset_reference_id, lower(tag_name)" | ||
| ")" | ||
| ) | ||
| op.execute("UPDATE asset_reference_tags SET tag_name = lower(tag_name)") | ||
| op.execute("DELETE FROM tags WHERE name != lower(name)") | ||
|
|
||
| bind = op.get_bind() | ||
| if bind.dialect.name == "sqlite": | ||
| op.execute("PRAGMA foreign_keys=OFF") | ||
| op.execute( | ||
| "CREATE TABLE tags_new (" | ||
| "name VARCHAR(512) NOT NULL, " | ||
| "CONSTRAINT pk_tags PRIMARY KEY (name), " | ||
| "CONSTRAINT ck_tags_lowercase CHECK (name = lower(name))" | ||
| ")" | ||
| ) | ||
| op.execute("INSERT INTO tags_new(name) SELECT name FROM tags") | ||
| op.execute("DROP TABLE tags") | ||
| op.execute("ALTER TABLE tags_new RENAME TO tags") | ||
| op.execute("PRAGMA foreign_keys=ON") | ||
| return | ||
|
|
||
| op.create_check_constraint( | ||
| "ck_tags_ck_tags_lowercase", "tags", "name = lower(name)" | ||
| ) | ||
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.