From f3531f7c63615bd15b88a4f8235465e2ea858fb2 Mon Sep 17 00:00:00 2001 From: Shikha Vyaghra Date: Fri, 6 Dec 2024 01:10:57 +0000 Subject: [PATCH] migrations: remove all the weak setting on downgrade We need this migration that will delete all the weak settings and setting-generators. --- Release.toml | 1 + sources/Cargo.lock | 7 +++++++ sources/Cargo.toml | 1 + .../remove-weak-settings-migration/Cargo.toml | 15 +++++++++++++++ .../remove-weak-settings-migration/src/main.rs | 18 ++++++++++++++++++ 5 files changed, 42 insertions(+) create mode 100644 sources/settings-migrations/v1.29.0/remove-weak-settings-migration/Cargo.toml create mode 100644 sources/settings-migrations/v1.29.0/remove-weak-settings-migration/src/main.rs diff --git a/Release.toml b/Release.toml index 52328f3fecd..da6749b721d 100644 --- a/Release.toml +++ b/Release.toml @@ -380,6 +380,7 @@ version = "1.29.0" "migrate_v1.28.0_public-control-container-v0-7-18.lz4", ] "(1.28.0, 1.29.0)" = [ + "migrate_v1.29.0_remove_weak_settings_migration.lz4", "migrate_v1.29.0_update-settings-generator-admin.lz4", "migrate_v1.29.0_update-settings-generator-control.lz4", "migrate_v1.29.0_change-public-admin-container-to-set-gen.lz4", diff --git a/sources/Cargo.lock b/sources/Cargo.lock index dfdb4b4cf11..02d438ca893 100644 --- a/sources/Cargo.lock +++ b/sources/Cargo.lock @@ -2265,6 +2265,13 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "remove-weak-settings-migration" +version = "0.1.0" +dependencies = [ + "migration-helpers", +] + [[package]] name = "repr_offset" version = "0.2.2" diff --git a/sources/Cargo.toml b/sources/Cargo.toml index c147bf192b8..8030037b146 100644 --- a/sources/Cargo.toml +++ b/sources/Cargo.toml @@ -71,6 +71,7 @@ members = [ "settings-migrations/v1.28.0/public-admin-container-v0-11-14", "settings-migrations/v1.28.0/aws-control-container-v0-7-18", "settings-migrations/v1.28.0/public-control-container-v0-7-18", + "settings-migrations/v1.29.0/remove-weak-settings-migration", "settings-migrations/v1.29.0/update-settings-generator-admin", "settings-migrations/v1.29.0/update-settings-generator-control", "settings-migrations/v1.29.0/change-public-admin-container-to-set-gen", diff --git a/sources/settings-migrations/v1.29.0/remove-weak-settings-migration/Cargo.toml b/sources/settings-migrations/v1.29.0/remove-weak-settings-migration/Cargo.toml new file mode 100644 index 00000000000..b3dfdfcebe1 --- /dev/null +++ b/sources/settings-migrations/v1.29.0/remove-weak-settings-migration/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "remove-weak-settings-migration" +version = "0.1.0" +authors = ["Shikha Vyaghra "] +license = "Apache-2.0 OR MIT" +edition = "2021" +publish = false +# Don't rebuild crate just because of changes to README. +exclude = ["README.md"] + + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +migration-helpers.workspace = true diff --git a/sources/settings-migrations/v1.29.0/remove-weak-settings-migration/src/main.rs b/sources/settings-migrations/v1.29.0/remove-weak-settings-migration/src/main.rs new file mode 100644 index 00000000000..28572e95f1d --- /dev/null +++ b/sources/settings-migrations/v1.29.0/remove-weak-settings-migration/src/main.rs @@ -0,0 +1,18 @@ +use migration_helpers::common_migrations::RemoveWeakSettingsMigration; +use migration_helpers::{migrate, Result}; +use std::process; + +// Remove the weak settings on downgrade +fn run() -> Result<()> { + migrate(RemoveWeakSettingsMigration) +} + +// Returning a Result from main makes it print a Debug representation of the error, but with Snafu +// we have nice Display representations of the error, so we wrap "main" (run) and print any error. +// https://github.com/shepmaster/snafu/issues/110 +fn main() { + if let Err(e) = run() { + eprintln!("{}", e); + process::exit(1); + } +}