diff --git a/implementations/rust/ockam/ockam_node/src/storage/database/migrations/node_migrations/sql/postgres/20240703100000_add_subscriptions.sql b/implementations/rust/ockam/ockam_node/src/storage/database/migrations/node_migrations/sql/postgres/20240703100000_add_subscriptions.sql deleted file mode 100644 index 28ecd731a0a..00000000000 --- a/implementations/rust/ockam/ockam_node/src/storage/database/migrations/node_migrations/sql/postgres/20240703100000_add_subscriptions.sql +++ /dev/null @@ -1,9 +0,0 @@ --- This migration adds the subscriptions table based on the following rust struct -CREATE TABLE subscription ( - space_id TEXT PRIMARY KEY, - name TEXT NOT NULL, - is_free_trial BOOLEAN NOT NULL, - marketplace TEXT, - start_date INTEGER, - end_date INTEGER -); diff --git a/implementations/rust/ockam/ockam_node/src/storage/database/migrations/node_migrations/sql/postgres/20241112100000_add_privileged_portals.sql b/implementations/rust/ockam/ockam_node/src/storage/database/migrations/node_migrations/sql/postgres/20241112100000_add_privileged_portals.sql deleted file mode 100644 index 57400cb0b2c..00000000000 --- a/implementations/rust/ockam/ockam_node/src/storage/database/migrations/node_migrations/sql/postgres/20241112100000_add_privileged_portals.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Add privileged column to the tcp_outlet_status table -ALTER TABLE tcp_outlet_status - ADD privileged BOOLEAN DEFAULT FALSE; -- boolean indicating if the outlet is operating in privileged mode - --- Add privileged column to the tcp_inlet table -ALTER TABLE tcp_inlet - ADD privileged BOOLEAN DEFAULT FALSE; -- boolean indicating if the inlet is operating in privileged mode diff --git a/implementations/rust/ockam/ockam_node/src/storage/database/sqlx_database.rs b/implementations/rust/ockam/ockam_node/src/storage/database/sqlx_database.rs index 2fa7f525ff1..45e54b81ed6 100644 --- a/implementations/rust/ockam/ockam_node/src/storage/database/sqlx_database.rs +++ b/implementations/rust/ockam/ockam_node/src/storage/database/sqlx_database.rs @@ -433,7 +433,7 @@ where let db = SqlxDatabase::create_sqlite(db_file.path()).await?; rethrow("SQLite on disk", f(db)).await?; - // only run the postgres tests if the OCKAM_POSTGRES_* environment variables are set + // only run the postgres tests if the OCKAM_DATABASE_CONNECTION_URL environment variables is set if let Ok(db) = SqlxDatabase::create_new_postgres().await { rethrow("Postgres local", f(db.clone())).await?; db.drop_all_postgres_tables().await?; @@ -441,6 +441,19 @@ where Ok(()) } +/// This function can be used to avoid running a test if the postgres database is used. +pub async fn without_postgres(f: F) -> std::result::Result<(), R> +where + F: Fn() -> Fut + Send + Sync + 'static, + Fut: Future> + Send + 'static, +{ + // only run the postgres tests if the OCKAM_DATABASE_CONNECTION_URL environment variables is not set + if let Err(_) = SqlxDatabase::create_new_postgres().await { + f().await? + }; + Ok(()) +} + /// This function can be used to run some test code with the 3 different databases implementations /// of the application database pub async fn with_application_dbs(f: F) -> Result<()>