Skip to content

fix: flyway pattern _##__whatever.sql#3

Merged
smithxxl merged 3 commits intomasterfrom
fix/false-positive-prefix-check
Mar 27, 2026
Merged

fix: flyway pattern _##__whatever.sql#3
smithxxl merged 3 commits intomasterfrom
fix/false-positive-prefix-check

Conversation

@smithxxl
Copy link
Copy Markdown
Contributor

@smithxxl smithxxl commented Mar 26, 2026

Deduplication logic improvements:

  • Updated the sed command in both check.sh and script.sh to use a regular expression that extracts file name prefixes ending with an underscore and digits, improving accuracy when identifying duplicates. Look for number and then "__" as the split where everything after is arbitrary, and the prefix is the key to dedup.

Examples where "R__" was creating false positive.

R__20__citest_insert_into_program.sql
R__21__citest_insert_into_mention.sql
R__22__citest_shared.shared_url_2020_01_03-04.sql
R__23__citest_shared.shared_url_2020_03_11.sql
R__24__citest_shared.shared_url_2020_03_12.sql
R__26__insert_into_tree_object_closure.sql
R__28__citest_schedule_job.sql
R__29__citest_test_organizations.sql
U2_08__add_canadian_markets.sql
V1_01__create_dababase_or_grant_select_to_postgres_on_flyway_table.sql
V1_02__non_transactional.sql
V2_01__add_collumns_to_tracking_unit_table.sql
V2_02__alter_tracking_unit_enable_expire_notification.sql
V2_03__add_application_id_in_organization.sql
V2_04__add_new_tracking_type_value_live_prerecorded.sql

Evidence:

❯ ./check.sh "/Volumes/veritone/aiware-core/services/api/core-graphql-server/flyway/db/platform/sql"
/Volumes/veritone/aiware-core/services/api/core-graphql-server/flyway/db/platform/sql/V3_273__add_ingest_slugs_delete_by_source_event.sql:1:1: Duplicate filename -- V3_273
/Volumes/veritone/aiware-core/services/api/core-graphql-server/flyway/db/platform/sql/V3_273__recording_clone_mapping.sql:1:1: Duplicate filename -- V3_273

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the duplicate Flyway migration detection scripts to deduplicate by the migration “prefix” up to the numeric portion before __, avoiding false positives like treating all R__* files as duplicates.

Changes:

  • Adjusted filename-prefix extraction logic to key on ..._<digits>__... prefixes (instead of splitting only on __).
  • Updated directory handling/quoting in the find invocation (partial/inconsistent between scripts).

Reviewed changes

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

File Description
script.sh Adds a new prefix-extraction pipeline, but currently leaves the old pipeline in place (breaking the shell pipeline) and uses an undefined dirname variable.
check.sh Replaces the prefix-extraction logic with a sed regex, but now operates on full paths and has inconsistent quoting in later find usage.
Comments suppressed due to low confidence (2)

check.sh:8

  • Inside the loop, find $dirname -type f is unquoted. If the provided directory contains spaces or glob characters, this will break or scan unintended paths. Quote the variable consistently (as done in the earlier find).
  find $dirname -type f | grep "${fileName}" |
  while read fname

script.sh:23

  • dirname is not defined anywhere in this script, so find $dirname -type f will expand to an empty path and scan the current working directory instead of INPUT_DIRECTORY. Use the same directory variable used for scanning (e.g., INPUT_DIRECTORY) and quote it to handle spaces.
do
  find $dirname -type f | grep "${fileName}" |
  while read fname

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

@smithxxl smithxxl changed the title fix: flyway pattern M_##_##__whatever.sql fix: flyway pattern _##__whatever.sql Mar 26, 2026
@smithxxl smithxxl merged commit b9946cf into master Mar 27, 2026
30 checks passed
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.

4 participants