Merge devel_27 → master#585
Merged
jirkamotejl merged 8 commits intomasterfrom Apr 9, 2026
Merged
Conversation
* feat(file_placements): add placement_attributes kwarg to multi picker fields * feat(file_placements): add title to multi picker fields * feat(file_placements): prefill title, hide hints and placeholders * feat(file_placements): update alt i18n * feat(remote_scripts): add integrity support * chore(changelog): add entries * fix: code review * fix: code review
feat: enforce unique slug on Folio::File with safe migration and retry logic
Add a DB-level unique index on folio_files.slug with a backfill migration
that handles null slugs and deduplicates existing conflicts before the
index is applied. Includes a retry path for race conditions at index
creation time.
Key changes:
- Migration: backfill null slugs with timestamp-hex values, deduplicate
existing duplicate slugs (oldest keeps original, others get new neutral
slugs), then swap to a unique index with a max_attempts guard (100
iterations) to prevent infinite loops
- Folio::File: replace complex hash_id_for_slug fallback with a simpler
neutral_slug (timestamp-hex); extend by_query scope to also match on slug
- S3::CreateFileJob: handle ActiveRecord::RecordNotUnique at the DB level
in addition to validation-level slug conflicts; extract slug_conflict?
and save_with_db_uniqueness_guard helpers
- Tests: migration test suite covering null backfill, deduplication order,
findability via new and original slugs, three-way duplicate handling;
job tests for DB uniqueness retry; friendly_id concern tests
…583) * fix(input/tags): keep tag field editable after choosing a suggestion * chore: run guard * chore(deps): bump actionview from 8.0.4 to 8.0.4.1 (#564) Bumps [actionview](https://github.com/rails/rails) from 8.0.4 to 8.0.4.1. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.1.2.1/actionview/CHANGELOG.md) - [Commits](rails/rails@v8.0.4...v8.0.4.1) --- updated-dependencies: - dependency-name: actionview dependency-version: 8.0.4.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump activestorage from 8.0.4 to 8.0.4.1 (#565) Bumps [activestorage](https://github.com/rails/rails) from 8.0.4 to 8.0.4.1. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.1.2.1/activestorage/CHANGELOG.md) - [Commits](rails/rails@v8.0.4...v8.0.4.1) --- updated-dependencies: - dependency-name: activestorage dependency-version: 8.0.4.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump activesupport from 8.0.4 to 8.0.4.1 (#566) Bumps [activesupport](https://github.com/rails/rails) from 8.0.4 to 8.0.4.1. - [Release notes](https://github.com/rails/rails/releases) - [Changelog](https://github.com/rails/rails/blob/v8.1.2.1/activesupport/CHANGELOG.md) - [Commits](rails/rails@v8.0.4...v8.0.4.1) --- updated-dependencies: - dependency-name: activesupport dependency-version: 8.0.4.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump json from 2.18.1 to 2.19.2 (#559) Bumps [json](https://github.com/ruby/json) from 2.18.1 to 2.19.2. - [Release notes](https://github.com/ruby/json/releases) - [Changelog](https://github.com/ruby/json/blob/master/CHANGES.md) - [Commits](ruby/json@v2.18.1...v2.19.2) --- updated-dependencies: - dependency-name: json dependency-version: 2.19.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump bcrypt from 3.1.20 to 3.1.22 (#561) Bumps [bcrypt](https://github.com/bcrypt-ruby/bcrypt-ruby) from 3.1.20 to 3.1.22. - [Release notes](https://github.com/bcrypt-ruby/bcrypt-ruby/releases) - [Changelog](https://github.com/bcrypt-ruby/bcrypt-ruby/blob/master/CHANGELOG) - [Commits](bcrypt-ruby/bcrypt-ruby@v3.1.20...v3.1.22) --- updated-dependencies: - dependency-name: bcrypt dependency-version: 3.1.22 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5 (#551) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5. - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump rack from 2.2.21 to 2.2.22 (#534) Bumps [rack](https://github.com/rack/rack) from 2.2.21 to 2.2.22. - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md) - [Commits](rack/rack@v2.2.21...v2.2.22) --- updated-dependencies: - dependency-name: rack dependency-version: 2.2.22 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5 in /test/dummy (#539) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5. - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump svgo from 2.8.0 to 2.8.2 in /test/dummy (#545) Bumps [svgo](https://github.com/svg/svgo) from 2.8.0 to 2.8.2. - [Release notes](https://github.com/svg/svgo/releases) - [Commits](svg/svgo@v2.8.0...v2.8.2) --- updated-dependencies: - dependency-name: svgo dependency-version: 2.8.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(guard): run * refactor(migrations): simplified folio_accounts merge migration process by removing unnecessary connection pooling * feat(file_placements): add title to multi picker fields (#579) * feat(file_placements): add placement_attributes kwarg to multi picker fields * feat(file_placements): add title to multi picker fields * feat(file_placements): prefill title, hide hints and placeholders * feat(file_placements): update alt i18n * feat(remote_scripts): add integrity support * chore(changelog): add entries * fix: code review * fix: code review * fix(changelog): entries * Fix - duplicate slug validation (#572) feat: enforce unique slug on Folio::File with safe migration and retry logic Add a DB-level unique index on folio_files.slug with a backfill migration that handles null slugs and deduplicates existing conflicts before the index is applied. Includes a retry path for race conditions at index creation time. Key changes: - Migration: backfill null slugs with timestamp-hex values, deduplicate existing duplicate slugs (oldest keeps original, others get new neutral slugs), then swap to a unique index with a max_attempts guard (100 iterations) to prevent infinite loops - Folio::File: replace complex hash_id_for_slug fallback with a simpler neutral_slug (timestamp-hex); extend by_query scope to also match on slug - S3::CreateFileJob: handle ActiveRecord::RecordNotUnique at the DB level in addition to validation-level slug conflicts; extract slug_conflict? and save_with_db_uniqueness_guard helpers - Tests: migration test suite covering null backfill, deduplication order, findability via new and original slugs, three-way duplicate handling; job tests for DB uniqueness retry; friendly_id concern tests * chore(guard): run * docs: update CHANGELOG with tags fields --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Nikolaj Kolesnik <k.kolesnik@seznam.cz> Co-authored-by: jirkamotejl <motejl.jirka@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Petr Marek <contact@petrmarek.eu> Co-authored-by: Martin Dedek <dedekmm@gmail.com> Co-authored-by: zaneta.gebka <zaneta.gebka@sinfin.cz>
The AddUniqueIndexToFileSlug migration assumed index_folio_files_on_slug exists before attempting removal. On databases restored from pg_dump (which may not include indexes), this causes the migration to fail after already committing the deduplication changes, leaving the DB in an inconsistent state — data modified but no unique index created. Tested against production dump (March 2026, 323k files, 42 duplicate slug groups) — migration now completes successfully regardless of whether the old index exists. [CS-201] [CS-219]
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
Regular merge (NOT squash) — preserving commit history.