From 699b33c0d3a7ba2bafb690a3543a095bc33ec22f Mon Sep 17 00:00:00 2001 From: nbesimi Date: Sun, 27 Nov 2022 23:59:35 +0100 Subject: [PATCH 1/6] added: safety operation in model.yaml --- README.md | 9 +++++++++ cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java | 6 ++++++ .../adaptivescale/rosetta/common/models/Database.java | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/README.md b/README.md index c875fe42..c567465d 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,7 @@ Parameter | Description Example: ```yaml --- +safetyOperationEnabled: false databaseType: bigquery tables: - name: "profiles" @@ -412,6 +413,7 @@ Parameter | Description Example: ```yaml --- +safetyOperationEnabled: false databaseType: "mysql" tables: - name: "actor" @@ -475,6 +477,7 @@ Example: (Actual database) ```yaml --- +safetyOperationEnabled: false databaseType: "mysql" tables: - name: "actor" @@ -500,6 +503,7 @@ tables: (Expected database) ```yaml --- +safetyOperationEnabled: false databaseType: "mysql" tables: - name: "actor" @@ -539,6 +543,11 @@ tables: Description: Our actual database does not contain `first_name` so we expect it to alter the table and add the column, inside the source directory there will be the executed DDL and a snapshot of the current database. + +### Safety Operation +In `model.yaml` you can find the attribute `safetyOperationEnabled` which is by default disabled. If you want to prevent any DROP operation during +`apply` command, enable the safety operation the value for `safetyOperationEnabled: true`. + ## Copyright and License Information Unless otherwise specified, all content, including all source code files and documentation files in this repository are: diff --git a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java index cc1506f5..20128cc6 100644 --- a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java +++ b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java @@ -186,6 +186,12 @@ private void apply(@CommandLine.Option(names = {"-s", "--source"}, required = tr return; } + if (changes.stream().filter(change -> change.getStatus().equals(Change.Status.DROP)).findFirst().isPresent() && + expectedDatabase.getSafetyOperationEnabled()) { + log.info("Not going to perform the changes because there are DROP operations and the safety operation is enabled."); + return; + } + ChangeHandler handler = DDLFactory.changeHandler(source.getDbType()); String ddl = handler.createDDLForChanges(changes); diff --git a/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java b/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java index fe439362..9528f646 100644 --- a/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java +++ b/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java @@ -4,6 +4,7 @@ public class Database { + private Boolean safetyOperationEnabled = false; private Collection tables; private String databaseProductName; private String databaseType; @@ -35,4 +36,12 @@ public String getDatabaseType() { public void setDatabaseType(String databaseType) { this.databaseType = databaseType; } + + public Boolean getSafetyOperationEnabled() { + return safetyOperationEnabled; + } + + public void setSafetyOperationEnabled(Boolean safetyOperationEnabled) { + this.safetyOperationEnabled = safetyOperationEnabled; + } } From a9a511d56d934569afb1c7d8bf4cdc4131a2ad51 Mon Sep 17 00:00:00 2001 From: Fehmi Havziu <106117501+Femi3211@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:25:54 +0100 Subject: [PATCH 2/6] Added integration tests for postgres (#105) --- .../PostgresDDLIntegrationTest.java | 241 +++++++++++++++++- 1 file changed, 239 insertions(+), 2 deletions(-) diff --git a/cli/src/test/java/integration/PostgresDDLIntegrationTest.java b/cli/src/test/java/integration/PostgresDDLIntegrationTest.java index e29eba74..21741122 100644 --- a/cli/src/test/java/integration/PostgresDDLIntegrationTest.java +++ b/cli/src/test/java/integration/PostgresDDLIntegrationTest.java @@ -1,11 +1,17 @@ package integration; import com.adaptivescale.rosetta.common.DriverManagerDriverProvider; +import com.adaptivescale.rosetta.common.models.AssertTest; import com.adaptivescale.rosetta.common.models.Database; +import com.adaptivescale.rosetta.common.models.test.Tests; import com.adaptivescale.rosetta.ddl.DDLFactory; import com.adaptivescale.rosetta.ddl.change.PostgresChangeFinder; import com.adaptivescale.rosetta.ddl.change.model.Change; import com.adaptivescale.rosetta.ddl.executor.DDLExecutor; +import com.adaptivescale.rosetta.test.assertion.AssertionSqlGenerator; +import com.adaptivescale.rosetta.test.assertion.DefaultAssertTestEngine; +import com.adaptivescale.rosetta.test.assertion.DefaultSqlExecution; +import com.adaptivescale.rosetta.test.assertion.generator.AssertionSqlGeneratorFactory; import integration.helpers.GenericJDBCContainer; import org.junit.Rule; import org.junit.jupiter.api.*; @@ -14,7 +20,7 @@ import java.util.List; -import static org.junit.Assert.assertSame; +import static org.junit.Assert.*; @Testcontainers @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @@ -31,6 +37,58 @@ public class PostgresDDLIntegrationTest { private static int PORT = 5432; private static String DROP_VIEWS = "DROP VIEW actor_info,customer_list,film_list,nicer_but_slower_film_list,sales_by_film_category,sales_by_store,staff_list cascade;"; + private static String DROP_VIEWS1 = + "CREATE TABLE \"public\".numerics (\n" + + "\tc_bigint int8 NULL,\n" + + "\tc_bigserial bigserial NOT NULL,\n" + + "\tc_bytea bytea NULL,\n" + + "\tc_boolean bool NULL,\n" + + "\tc_bool bool NULL,\n" + + "\tc_integer int4 NULL,\n" + + "\tc_int int4 NULL,\n" + + "\tc_interval interval NULL,\n" + + "\tc_money money NULL,\n" + + "\tc_numeric numeric NULL,\n" + + "\tc_real float4 NULL,\n" + + "\tc_smallint int2 NULL,\n" + + "\tc_smallserial smallserial NOT NULL,\n" + + "\tc_serial serial4 NOT NULL,\n" + + "\tuser_salary money NOT NULL,\n" + + "\tCONSTRAINT numerics_pkey PRIMARY KEY (user_salary)\n" + + ");"; + + private static String DROP_VIEWS2 = + "CREATE TABLE \"public\".strings (\n" + + "\tc_bit bit(1) NULL,\n" + + "\tc_bitvarying varbit NULL,\n" + + "\tc_character bpchar(1) NULL,\n" + + "\tc_charactervarying varchar NULL,\n" + + "\tc_text text NULL,\n" + + "\tc_varchar varchar(32) NULL,\n" + + "\tuser1_name varchar(32) NOT NULL,\n" + + "\tCONSTRAINT strings_pkey PRIMARY KEY (user1_name)\n" + + ");"; + + private static String DROP_VIEWS3 ="CREATE TABLE \"public\".time_date (\n" + + "\tc_timestamp timestamp NULL,\n" + + "\tc_timestamptz timestamptz NULL,\n" + + "\tc_date date NULL,\n" + + "\tc_time time NULL,\n" + + "\tc_timetz timetz NULL,\n" + + "\tuser_date date NOT NULL,\n" + + "\tCONSTRAINT time_date_pkey PRIMARY KEY (user_date)\n" + + ");"; + + private static String DROP_VIEWS4 ="CREATE TABLE \"public\".user1 (\n" + + "\tcustomer_id int4 NULL,\n" + + "\tuser1_salary money NULL,\n" + + "\tuser_name varchar(32) NULL,\n" + + "\tuser_date date NULL\n" + + ");\n"; + private static String DROP_VIEWSFK = + "ALTER TABLE \"public\".user1 ADD CONSTRAINT user1_user1_salary_fkey FOREIGN KEY (user1_salary) REFERENCES \"public\".numerics(user_salary);\n" + + "ALTER TABLE \"public\".user1 ADD CONSTRAINT user1_user_date_fkey FOREIGN KEY (user_date) REFERENCES \"public\".time_date(user_date);\n" + + "ALTER TABLE \"public\".user1 ADD CONSTRAINT user1_user_name_fkey FOREIGN KEY (user_name) REFERENCES \"public\".strings(user1_name);"; @Rule public static GenericJDBCContainer container = new GenericJDBCContainer( IMAGE, USERNAME,PASSWORD, DATABASE, SCHEMA, DB_TYPE, JDBC_URL, CLASS_NAME, PORT).generateContainer(); @@ -45,6 +103,11 @@ public static void beforeAll() { @Order(0) void prep() throws Exception { container.getContainer().createConnection("").createStatement().execute(DROP_VIEWS); + container.getContainer().createConnection("").createStatement().execute(DROP_VIEWS1); + container.getContainer().createConnection("").createStatement().execute(DROP_VIEWS2); + container.getContainer().createConnection("").createStatement().execute(DROP_VIEWS3); + container.getContainer().createConnection("").createStatement().execute(DROP_VIEWS4); + container.getContainer().createConnection("").createStatement().execute(DROP_VIEWSFK); } @Test @@ -52,7 +115,7 @@ void prep() throws Exception { @Order(1) void textExtract() throws Exception { Database sourceModel = container.getDatabaseModel(); - assertSame("Comparing table count.", 21, sourceModel.getTables().size()); + assertSame("Comparing table count.", 25, sourceModel.getTables().size()); assertSame("Comparing actor table column count.", 4, container.getTableColumns(sourceModel, "actor").size()); } @@ -97,4 +160,178 @@ void testApply() throws Exception { assertSame("Actors table exists", 1L, actors); assertSame("Actor table is removed", 0L, actor); } + + + @Test + @DisplayName("Test Postgres SQL Assertion") + @Order(4) + void testTest() throws Exception { + Database sourceModel = container.getDatabaseModel(); + ObjectMapper objectMapper = new ObjectMapper(); + Database targetModel = objectMapper.readValue(objectMapper.writeValueAsString(sourceModel), Database.class); + targetModel.getTables().forEach(table -> { + if(table.getName().equals("actor")) { + table.getColumns().forEach(column -> { + if(column.getName().equals("first_name")){ + AssertTest assertTest = new AssertTest(); + assertTest.setValue("Nick"); + assertTest.setOperator("="); + assertTest.setExpected("1"); + Tests tests = new Tests(); + tests.setAssertions(List.of(assertTest)); + + column.setTests(tests); + } + }); + } + }); + + AssertionSqlGenerator assertionSqlGenerator = AssertionSqlGeneratorFactory.generatorFor(container.getRosettaConnection()); + DefaultSqlExecution defaultSqlExecution = new DefaultSqlExecution(container.getRosettaConnection(), new DriverManagerDriverProvider()); + new DefaultAssertTestEngine(assertionSqlGenerator, defaultSqlExecution).run(container.getRosettaConnection(), targetModel); + } + + @Test + @DisplayName("Extract PostgreSQL") + @Order(5) + + void testExtractDDL() throws Exception { + Database sourceModel = container.getDatabaseModel(); + ObjectMapper objectMapper = new ObjectMapper(); + Database targetModel = objectMapper.readValue(objectMapper.writeValueAsString(sourceModel), Database.class); + targetModel.getTables().forEach(table ->{ + if (table.getName().equals("numerics")) { + table.getColumns().forEach(column -> { + switch (column.getName()) { + case "c_integer": + assertEquals("", "int4", column.getTypeName()); + break; + case "c_bigint": + assertEquals("", "int8", column.getTypeName()); + break; + case "c_bigserial": + assertEquals("", "bigserial", column.getTypeName()); + break; + case "c_bytea": + assertEquals("", "bytea", column.getTypeName()); + break; + case "c_boolean": + assertEquals("", "bool", column.getTypeName()); + break; + case "c_bool": + assertEquals("", "bool", column.getTypeName()); + break; + case "c_int": + assertEquals("", "int4", column.getTypeName()); + break; + case "c_interval": + assertEquals("", "interval", column.getTypeName()); + break; + case "c_money": + assertEquals("", "money", column.getTypeName()); + break; + case "c_numeric": + assertEquals("", "numeric", column.getTypeName()); + break; + case "c_real": + assertEquals("", "float4", column.getTypeName()); + break; + case "c_smallint": + assertEquals("", "int2", column.getTypeName()); + break; + case "c_smallserial": + assertEquals("", "smallserial", column.getTypeName()); + break; + case "c_serial": + assertEquals("", "serial", column.getTypeName()); + break; + case "user_salary": + assertEquals("", "money", column.getTypeName()); + break; + } + }); + } + if(table.getName().equals("strings")) { + table.getColumns().forEach(column -> { + switch (column.getName()) { + case "c_bit": + assertEquals("", "bit", column.getTypeName()); + break; + case "c_bitvarying": + assertEquals("", "varbit", column.getTypeName()); + break; + case "c_character": + assertEquals("", "bpchar", column.getTypeName()); + break; + case "c_charactervarying": + assertEquals("", "varchar", column.getTypeName()); + break; + case "c_text": + assertEquals("", "text", column.getTypeName()); + break; + case "c_varchar": + assertEquals("", "varchar", column.getTypeName()); + break; + case "user1_name": + assertEquals("", "varchar", column.getTypeName()); + assertEquals("", true, column.isPrimaryKey()); + break; + } + }); + } + if (table.getName().equals("time_date")){ + table.getColumns().forEach(column -> { + switch (column.getName()) { + case "c_timestamp": + assertEquals("", "timestamp", column.getTypeName()); + break; + case "c_timestamptz": + assertEquals("", "timestamptz", column.getTypeName()); + break; + case "c_date": + assertEquals("", "date", column.getTypeName()); + break; + case "c_time": + assertEquals("", "time", column.getTypeName()); + break; + case "c_timetz": + assertEquals("", "timetz", column.getTypeName()); + break; + case "user_date": + assertEquals("", "date", column.getTypeName()); + assertEquals("", true, column.isPrimaryKey()); + break; + } + }); + } + }); + + } + + + @Test + @DisplayName("Foreign key constraint") + @Order(6) + void testForeignKey() throws Exception { + Database sourceModel = container.getDatabaseModel(); + ObjectMapper objectMapper = new ObjectMapper(); + Database targetModel = objectMapper.readValue(objectMapper.writeValueAsString(sourceModel), Database.class); + targetModel.getTables().forEach(table -> { + if (table.getName().equals("user1")) { + table.getColumns().forEach(column -> { + switch (column.getName()) { + case "user1_salary": + assertEquals("", 1L, column.getForeignKeys().size()); + break; + case "user_name": + assertEquals("", 1L, column.getForeignKeys().size()); + break; + case "user_date": + assertEquals("", 1L, column.getForeignKeys().size()); + break; + } + }); + } + }); + } } From 43f305ae2b1140d6c41bf91150379082c4e6e4b6 Mon Sep 17 00:00:00 2001 From: Nuhi Date: Mon, 28 Nov 2022 15:27:47 +0100 Subject: [PATCH 3/6] fixed: multiple SLF4J bindings (#106) --- cli/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/build.gradle b/cli/build.gradle index 4bedf0d4..a39c8c29 100644 --- a/cli/build.gradle +++ b/cli/build.gradle @@ -15,7 +15,7 @@ dependencies { implementation project(':test') implementation group: 'info.picocli', name: 'picocli', version: '4.6.3' - implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30' + implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.5' implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.7' implementation group: 'commons-io', name: 'commons-io', version: '2.11.0' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.3' @@ -54,4 +54,4 @@ jar { it.isDirectory() ? it : zipTree(it) } } -} +} \ No newline at end of file From cb1f4a41e2e0d5f3160909c913f37e7b85e26f8e Mon Sep 17 00:00:00 2001 From: Nuhi Date: Mon, 28 Nov 2022 15:28:35 +0100 Subject: [PATCH 4/6] added: optional model argument for the apply command (#107) --- README.md | 4 +++ .../com/adaptivescale/rosetta/cli/Cli.java | 30 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c875fe42..8cec7f2e 100644 --- a/README.md +++ b/README.md @@ -384,6 +384,8 @@ Parameter | Description -h, --help | Show the help message and exit. -c, --config CONFIG_FILE | YAML config file. If none is supplied it will use main.conf in the current directory if it exists. -s, --source CONNECTION_NAME | The source connection is used to specify which models and connection to use. +-m, --model MODEL_FILE (Optional) | The model file to use for apply. Default is `model.yaml` + Example: ``` @@ -469,6 +471,8 @@ Parameter | Description -h, --help | Show the help message and exit. -c, --config CONFIG_FILE | YAML config file. If none is supplied it will use main.conf in the current directory if it exists. -s, --source CONNECTION_NAME | The source connection is used to specify which models and connection to use. +-m, --model MODEL_FILE (Optional) | The model file to use for apply. Default is `model.yaml` + Example: diff --git a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java index cc1506f5..377ca1eb 100644 --- a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java +++ b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java @@ -56,6 +56,9 @@ description = "Declarative Database Management - DDL Transpiler" ) class Cli implements Callable { + + public static final String DEFAULT_MODEL_YAML = "model.yaml"; + @CommandLine.Spec CommandLine.Model.CommandSpec spec; @@ -82,7 +85,7 @@ private void extract(@CommandLine.Option(names = {"-s", "--source"}, required = Files.createDirectory(sourceWorkspace); Database result = SourceGeneratorFactory.sourceGenerator(source).generate(source); - YamlModelOutput yamlInputModel = new YamlModelOutput("model.yaml", sourceWorkspace); + YamlModelOutput yamlInputModel = new YamlModelOutput(DEFAULT_MODEL_YAML, sourceWorkspace); yamlInputModel.write(result); log.info("Successfully written input database yaml ({}).", yamlInputModel.getFilePath()); @@ -155,7 +158,8 @@ private void compile(@CommandLine.Option(names = {"-s", "--source"}) String sour @CommandLine.Command(name = "apply", description = "Get current model and compare with state of database," + " generate ddl for changes and apply to database. ", mixinStandardHelpOptions = true) - private void apply(@CommandLine.Option(names = {"-s", "--source"}, required = true) String sourceName) throws Exception { + private void apply(@CommandLine.Option(names = {"-s", "--source"}, required = true) String sourceName, + @CommandLine.Option(names = {"-m", "--model"}, defaultValue = DEFAULT_MODEL_YAML) String model) throws Exception { requireConfig(config); Connection source = getSourceConnection(sourceName); @@ -166,7 +170,7 @@ private void apply(@CommandLine.Option(names = {"-s", "--source"}, required = tr " models for translation", sourceWorkspace, sourceName)); } - List databases = getDatabases(sourceWorkspace) + List databases = getDatabaseForModel(sourceWorkspace, model) .map(AbstractMap.SimpleImmutableEntry::getValue) .collect(Collectors.toList()); @@ -283,7 +287,7 @@ private void extractDbtModels(Connection connection, Path sourceWorkspace) throw List databases = getDatabases(sourceWorkspace).map(AbstractMap.SimpleImmutableEntry::getValue).collect(Collectors.toList()); DbtModel dbtModel = DbtModelGenerator.dbtModelGenerator(connection, databases); - DbtYamlModelOutput dbtYamlModelOutput = new DbtYamlModelOutput("model.yaml", dbtWorkspace); + DbtYamlModelOutput dbtYamlModelOutput = new DbtYamlModelOutput(DEFAULT_MODEL_YAML, dbtWorkspace); dbtYamlModelOutput.write(dbtModel); Map dbtSQLTables = DbtModelGenerator.dbtSQLGenerator(dbtModel); @@ -294,7 +298,8 @@ private void extractDbtModels(Connection connection, Path sourceWorkspace) throw } @CommandLine.Command(name = "diff", description = "Show difference between local model and database", mixinStandardHelpOptions = true) - private void diff(@CommandLine.Option(names = {"-s", "--source"}) String sourceName) throws Exception { + private void diff(@CommandLine.Option(names = {"-s", "--source"}) String sourceName, + @CommandLine.Option(names = {"-m", "--model"}, defaultValue=DEFAULT_MODEL_YAML) String model) throws Exception { requireConfig(config); Connection sourceConnection = getSourceConnection(sourceName); @@ -304,7 +309,7 @@ private void diff(@CommandLine.Option(names = {"-s", "--source"}) String sourceN " models for translation", sourceWorkspace, sourceName)); } - List databases = getDatabases(sourceWorkspace) + List databases = getDatabaseForModel(sourceWorkspace, model) .map(AbstractMap.SimpleImmutableEntry::getValue) .collect(Collectors.toList()); @@ -404,6 +409,19 @@ private Stream getDatabases(Path directory) throws IOEx }); } + private Stream getDatabaseForModel(Path directory, String model) throws IOException { + return Files.list(directory) + .filter(path -> FilenameUtils.getName(path.toString()).equals(model) && !Files.isDirectory(path)) + .map(path -> { + try { + Database input = new ObjectMapper(new YAMLFactory()).readValue(path.toFile(), Database.class); + return new FileNameAndDatabasePair(path.getFileName().toString(), input); + } catch (Exception exception) { + throw new RuntimeException(exception); + } + }); + } + private Function translateDatabases(Translator translator) { return fileNameAndModelPair -> { try { From fb260206d0809b605b8ab3fba3f846ef29e3c266 Mon Sep 17 00:00:00 2001 From: nbesimi Date: Mon, 28 Nov 2022 16:09:37 +0100 Subject: [PATCH 5/6] added: safety operation in model.yaml --- README.md | 12 ++++++------ .../main/java/com/adaptivescale/rosetta/cli/Cli.java | 4 ++-- .../rosetta/common/models/Database.java | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c567465d..7464e2b9 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,7 @@ Parameter | Description Example: ```yaml --- -safetyOperationEnabled: false +safeMode: false databaseType: bigquery tables: - name: "profiles" @@ -413,7 +413,7 @@ Parameter | Description Example: ```yaml --- -safetyOperationEnabled: false +safeMode: false databaseType: "mysql" tables: - name: "actor" @@ -477,7 +477,7 @@ Example: (Actual database) ```yaml --- -safetyOperationEnabled: false +safeMode: false databaseType: "mysql" tables: - name: "actor" @@ -503,7 +503,7 @@ tables: (Expected database) ```yaml --- -safetyOperationEnabled: false +safeMode: false databaseType: "mysql" tables: - name: "actor" @@ -545,8 +545,8 @@ Description: Our actual database does not contain `first_name` so we expect it t ### Safety Operation -In `model.yaml` you can find the attribute `safetyOperationEnabled` which is by default disabled. If you want to prevent any DROP operation during -`apply` command, enable the safety operation the value for `safetyOperationEnabled: true`. +In `model.yaml` you can find the attribute `safeMode` which is by default disabled (false). If you want to prevent any DROP operation during +`apply` command, set `safeMode: true`. ## Copyright and License Information Unless otherwise specified, all content, including all source code files and documentation files in this repository are: diff --git a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java index 20128cc6..eb79c0b9 100644 --- a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java +++ b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java @@ -187,8 +187,8 @@ private void apply(@CommandLine.Option(names = {"-s", "--source"}, required = tr } if (changes.stream().filter(change -> change.getStatus().equals(Change.Status.DROP)).findFirst().isPresent() && - expectedDatabase.getSafetyOperationEnabled()) { - log.info("Not going to perform the changes because there are DROP operations and the safety operation is enabled."); + expectedDatabase.getSafeMode()) { + log.info("Not going to perform the changes because there are DROP operations and the safe mode is enabled."); return; } diff --git a/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java b/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java index 9528f646..5be1ea7f 100644 --- a/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java +++ b/common/src/main/java/com/adaptivescale/rosetta/common/models/Database.java @@ -4,7 +4,7 @@ public class Database { - private Boolean safetyOperationEnabled = false; + private Boolean safeMode = false; private Collection
tables; private String databaseProductName; private String databaseType; @@ -37,11 +37,11 @@ public void setDatabaseType(String databaseType) { this.databaseType = databaseType; } - public Boolean getSafetyOperationEnabled() { - return safetyOperationEnabled; + public Boolean getSafeMode() { + return safeMode; } - public void setSafetyOperationEnabled(Boolean safetyOperationEnabled) { - this.safetyOperationEnabled = safetyOperationEnabled; + public void setSafeMode(Boolean safeMode) { + this.safeMode = safeMode; } } From 47ccfed2b46fd87fa967a704333857047d139b3c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 13:50:12 +0000 Subject: [PATCH 6/6] Version bump: to 1.7.2 --- build.gradle | 2 +- cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 91807dbf..1dfc3a9f 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ repositories { allprojects { group = 'com.adaptivescale' - version = '1.7.1' + version = '1.7.2' sourceCompatibility = 11 targetCompatibility = 11 } diff --git a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java index 75423bd7..affe1369 100644 --- a/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java +++ b/cli/src/main/java/com/adaptivescale/rosetta/cli/Cli.java @@ -52,7 +52,7 @@ @Slf4j @CommandLine.Command(name = "cli", mixinStandardHelpOptions = true, - version = "1.7.1", + version = "1.7.2", description = "Declarative Database Management - DDL Transpiler" ) class Cli implements Callable {