Skip to content

Commit

Permalink
fix: improve product version range migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanb authored and ctron committed Jan 17, 2025
1 parent f92e968 commit ddfde89
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions etc/deploy/compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ services:
POSTGRES_PASSWORD: "trustify"
POSTGRES_DB: "trustify"
restart: always
shm_size: '1g'
8 changes: 6 additions & 2 deletions migration/src/m0000800_alter_product_version_range_scheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ impl MigrationTrait for Migration {
// use rpm version range scheme as it covers more usecases
manager
.get_connection()
.execute_unprepared(r#"UPDATE version_range SET version_scheme_id = 'rpm' WHERE id IN (SELECT version_range_id FROM product_version_range)"#)
.execute_unprepared(include_str!(
"m0000800_alter_product_version_range_scheme/migration_up.sql"
))
.await?;

Ok(())
Expand All @@ -19,7 +21,9 @@ impl MigrationTrait for Migration {
// return to semver version range scheme
manager
.get_connection()
.execute_unprepared(r#"UPDATE version_range SET version_scheme_id = 'semver' WHERE id IN (SELECT version_range_id FROM product_version_range)"#)
.execute_unprepared(include_str!(
"m0000800_alter_product_version_range_scheme/migration_down.sql"
))
.await?;

Ok(())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
WITH ranges_to_update AS (
SELECT version_range.* FROM
version_range
JOIN product_version_range ON version_range.id = product_version_range.version_range_id
)
UPDATE version_range
SET version_scheme_id = 'semver'
FROM ranges_to_update
WHERE version_range.id = ranges_to_update.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
WITH ranges_to_update AS (
SELECT version_range.* FROM
version_range
JOIN product_version_range ON version_range.id = product_version_range.version_range_id
)
UPDATE version_range
SET version_scheme_id = 'rpm'
FROM ranges_to_update
WHERE version_range.id = ranges_to_update.id

0 comments on commit ddfde89

Please sign in to comment.