]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14686 - Fail silently on PK to be dropped not found
authorBelen Pruvost <belen.pruvost@sonarsource.com>
Wed, 21 Apr 2021 11:23:27 +0000 (13:23 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 21 Apr 2021 20:03:46 +0000 (20:03 +0000)
33 files changed:
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinder.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGenerator.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGeneratorTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java

index 833db36471f1a345fbc657361bf3f0a3493d6b2a..01754aebd0c3ab6285f2c294bbf5e119031d392b 100644 (file)
@@ -42,10 +42,9 @@ public class DbPrimaryKeyConstraintFinder {
     this.db = db;
   }
 
-  public String findConstraintName(String tableName) throws SQLException {
+  public Optional<String> findConstraintName(String tableName) throws SQLException {
     String constraintQuery = getDbVendorSpecificQuery(tableName);
-    return executeQuery(constraintQuery)
-      .orElseThrow(() -> constraintNotFoundException(tableName));
+    return executeQuery(constraintQuery);
   }
 
   String getDbVendorSpecificQuery(String tableName) {
index 1e4731386dd02966f83b36d7588e7663f69f4d96..6e42b47eb92e70021b5bd86888e4fd400f534ce0 100644 (file)
@@ -22,7 +22,9 @@ package org.sonar.server.platform.db.migration.sql;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import org.sonar.db.Database;
 import org.sonar.db.dialect.Dialect;
 import org.sonar.db.dialect.H2;
@@ -51,16 +53,19 @@ public class DropPrimaryKeySqlGenerator {
 
   public List<String> generate(String tableName, Collection<String> columnNames, boolean isAutoGenerated) throws SQLException {
     Dialect dialect = db.getDialect();
-    String constraintName = dbConstraintFinder.findConstraintName(tableName);
+    Optional<String> constraintName = dbConstraintFinder.findConstraintName(tableName);
+    if (!constraintName.isPresent()) {
+      return Collections.emptyList();
+    }
     switch (dialect.getId()) {
       case PostgreSql.ID:
-        return generateForPostgresSql(tableName, columnNames, constraintName);
+        return generateForPostgresSql(tableName, columnNames, constraintName.get());
       case MsSql.ID:
-        return generateForMsSql(tableName, constraintName);
+        return generateForMsSql(tableName, constraintName.get());
       case Oracle.ID:
-        return generateForOracle(tableName, constraintName, isAutoGenerated);
+        return generateForOracle(tableName, constraintName.get(), isAutoGenerated);
       case H2.ID:
-        return generateForH2(tableName, constraintName);
+        return generateForH2(tableName, constraintName.get());
       default:
         throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId()));
     }
index faf94bea5c9cf7a3201028af7edf6669744ded2a..ce68bdd0f0d208f1fce147a1cdf7564463c22e76 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.platform.db.migration.sql;
 
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.Optional;
 import javax.sql.DataSource;
 import org.junit.Rule;
 import org.junit.Test;
@@ -52,16 +53,15 @@ public class DbPrimaryKeyConstraintFinderTest {
   @Test
   public void findConstraintName_constraint_exists() throws SQLException {
     DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database());
-    String constraintName = underTest.findConstraintName("TEST_PRIMARY_KEY");
-    assertThat(constraintName).isEqualTo("PK_TEST_PRIMARY_KEY");
+    Optional<String> constraintName = underTest.findConstraintName("TEST_PRIMARY_KEY");
+    assertThat(constraintName).isPresent();
+    assertThat(constraintName.get()).contains("PK_TEST_PRIMARY_KEY");
   }
 
   @Test
-  public void findConstraintName_constraint_not_exist() {
+  public void findConstraintName_constraint_not_exist_fails_silently() throws SQLException {
     DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database());
-    assertThatThrownBy(() -> underTest.findConstraintName("NOT_EXISTING_TABLE"))
-      .hasMessage("Cannot find constraint for table 'NOT_EXISTING_TABLE'")
-      .isInstanceOf(IllegalStateException.class);
+    assertThat(underTest.findConstraintName("NOT_EXISTING_TABLE")).isNotPresent();
   }
 
   @Test
index f74a76027674dbcb7f45515a791aafe7e1005ed2..e44495148c8292859244482e54bf99a185675024 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.platform.db.migration.sql;
 
 import java.sql.SQLException;
 import java.util.List;
+import java.util.Optional;
 import org.junit.Test;
 import org.sonar.db.Database;
 import org.sonar.db.dialect.Dialect;
@@ -51,10 +52,11 @@ public class DropPrimaryKeySqlGeneratorTest {
   private final DropPrimaryKeySqlGenerator underTest = new DropPrimaryKeySqlGenerator(db, dbConstraintFinder);
 
   @Test
-  public void generate_unknown_dialect() {
+  public void generate_unknown_dialect() throws SQLException {
     Dialect mockDialect = mock(Dialect.class);
     when(mockDialect.getId()).thenReturn("unknown-db-vendor");
     when(db.getDialect()).thenReturn(mockDialect);
+    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
 
     assertThatThrownBy(() -> underTest.generate(TABLE_NAME, PK_COLUMN, true))
       .isInstanceOf(IllegalStateException.class);
@@ -62,7 +64,7 @@ public class DropPrimaryKeySqlGeneratorTest {
 
   @Test
   public void generate_for_postgres_sql() throws SQLException {
-    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
     when(dbConstraintFinder.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(TABLE_NAME + "_id_seq");
     when(db.getDialect()).thenReturn(POSTGRESQL);
 
@@ -75,7 +77,7 @@ public class DropPrimaryKeySqlGeneratorTest {
 
   @Test
   public void generate_for_postgres_sql_no_seq() throws SQLException {
-    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
     when(dbConstraintFinder.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(null);
     when(db.getDialect()).thenReturn(POSTGRESQL);
 
@@ -87,7 +89,7 @@ public class DropPrimaryKeySqlGeneratorTest {
 
   @Test
   public void generate_for_ms_sql() throws SQLException {
-    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
     when(db.getDialect()).thenReturn(MS_SQL);
 
     List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true);
@@ -97,7 +99,7 @@ public class DropPrimaryKeySqlGeneratorTest {
 
   @Test
   public void generate_for_oracle_autogenerated_true() throws SQLException {
-    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
     when(db.getDialect()).thenReturn(ORACLE);
 
     List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true);
@@ -109,7 +111,7 @@ public class DropPrimaryKeySqlGeneratorTest {
 
   @Test
   public void generate_for_oracle_autogenerated_false() throws SQLException {
-    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
     when(db.getDialect()).thenReturn(ORACLE);
 
     List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, false);
@@ -119,7 +121,7 @@ public class DropPrimaryKeySqlGeneratorTest {
 
   @Test
   public void generate_for_h2() throws SQLException {
-    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+    when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
     when(db.getDialect()).thenReturn(H2);
 
     List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true);
index 6694a3a73d986f79d0170c9b5ac4038edff37455..c30ebc2258448a234e4eaa114c2340a32eedd284 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest {
 
   private static final String TABLE_NAME = "active_rule_parameters";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index 624616b197d8f1502e8fbed86480f3779332b0af..f33d82dd7b585b47a75d991533e61381fd12450e 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfActiveRulesTableTest {
 
   private static final String TABLE_NAME = "active_rules";
@@ -47,9 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfActiveRulesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 8d38f859bfd2da9b74b62876220f80e4fccbb6f9..09b11b665d6ebe4643515b5ae9ec0a85e647fdb4 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest {
 
   private static final String TABLE_NAME = "ce_activity";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index 02c6d4108e14f212ceb66b4ba24d0a479374a575..4f17918162b4d31a5a2ee5588f7991f6d2377d7b 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfCeQueueTableTest {
 
   private static final String TABLE_NAME = "ce_queue";
@@ -47,9 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfCeQueueTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index c5e6d3fc027ac82deeec439c7c4e5eade4435da3..aeaf762def7316c62a7b590570f28767abf22924 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest {
 
   private static final String TABLE_NAME = "duplications_index";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index 3334c73ac7dfdd0f471adb2b1b589761ef4fac1e..acd069c82c96d819a3621577734561da3260d89a 100644 (file)
@@ -26,8 +26,6 @@ import org.sonar.db.CoreDbTester;
 import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfEventsTableTest {
 
   private static final String TABLE_NAME = "events";
@@ -46,9 +44,10 @@ public class DropPrimaryKeyOnIdColumnOfEventsTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index d919b23671d99284a58801fc8504738b5bef91e9..d859424ac431c75e5dd7b78d2a618933c66e123e 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfFileSourcesTableTest {
 
   private static final String TABLE_NAME = "file_sources";
@@ -47,9 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfFileSourcesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index c29a70cfe1767c95c17c98698d8c1a42ab61ea4e..65e279e04c3d7c0af14cd24811c9bf42ba2d66c7 100644 (file)
@@ -26,8 +26,6 @@ import org.sonar.db.CoreDbTester;
 import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfGroupRolesTableTest {
 
   private static final String TABLE_NAME = "group_roles";
@@ -46,9 +44,10 @@ public class DropPrimaryKeyOnIdColumnOfGroupRolesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 3bb6a6764621d6ffed6127d75287058f54fa88be..99723e8f69255da086fbbcfc13b3dbc6347b8a5b 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfGroupsTableTest {
 
   private static final String TABLE_NAME = "groups";
@@ -47,9 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfGroupsTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 447568e81a962fb26a35e30ceff8e30a69e4da52..c670d997839000848be6b1ec288e0dae8d8f54ce 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest {
 
   private static final String TABLE_NAME = "manual_measures";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index d4ff27457cb23b37e5e691a2f8360647b754315c..ba2cc6188d289f0fe5870c720584bf47528ca694 100644 (file)
@@ -47,9 +47,10 @@ public class DropPrimaryKeyOnIdColumnOfMetricsTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 4c4b65fd6c872d762d17b5c97da452c2f6f085a9..aa332a489a577dc2ea4fc0623649fe0813d3c3b5 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfNotificationTableTest {
 
   private static final String TABLE_NAME = "notifications";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfNotificationTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index 3b285271f6a28d3898b487114d53cd65a9bd7169..66bb2ffb0cc5ce01a9d1bef36c55f0f48a104ac4 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest {
 
   private static final String TABLE_NAME = "permission_templates";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index 8ad1b9e2ffa824fc3f616a4a4ce2a5770fe92681..b429bf529ee61f5b9b1db67ae49e0edcd5c32fda 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest {
 
   private static final String TABLE_NAME = "perm_templates_groups";
@@ -48,9 +46,10 @@ public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 5ce74c6d0a7708b50bdea89d0c99557f97b31364..0754f744af564e12497e3e83b9d959a6bcd6ade8 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest {
 
   private static final String TABLE_NAME = "perm_templates_users";
@@ -48,9 +46,10 @@ public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 4ba5de120ffa9e0266a9a8651d09b93f0493bf8f..55a39f46937ae49012fdc8bc43061a62ada38bcc 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest {
 
   private static final String TABLE_NAME = "perm_tpl_characteristics";
@@ -48,9 +46,10 @@ public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 69b19b097c30c8927982a5c3c8b28731ce783de5..6dd3642e47c6d9292327116c6019193640f36a9a 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest {
 
   private static final String TABLE_NAME = "project_measures";
@@ -47,10 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
     underTest.execute();
-
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    underTest.execute();
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index 437d7718428aaee8e339722d4488019df30ef31d..9f92f2447fc4d97315ddd7839136efd08b1ce950 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest {
   private static final String TABLE_NAME = "project_qprofiles";
   @Rule
@@ -46,9 +44,10 @@ public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index b5c60304746cf7717d9c20d59d3d618aecbb8f04..9c748ecdd437f5a676af8da1d23533603607a0bb 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfPropertiesTableTest {
 
   private static final String TABLE_NAME = "properties";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfPropertiesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index cea7cc9e6151fa76fe3fbfbbbaf757ea6da501dc..ce1a4861f3efb4bd288e8509dece9302bf36bcd7 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest {
 
   private static final String TABLE_NAME = "quality_gate_conditions";
@@ -47,9 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 9bf5c072b5e0673d2586caef1d4b1c0c23b3ea27..684e534d2c2f8a06057df03eeb1600dde2099b47 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfQGatesTableTest {
 
   private static final String TABLE_NAME = "quality_gates";
@@ -48,9 +46,10 @@ public class DropPrimaryKeyOnIdColumnOfQGatesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 34083c06d6b767affb5a180f5daeaf0eb3fc156b..e47a9781f5119e630c407961a29a739559a2f85e 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.server.platform.db.migration.step.MigrationStep;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 public class DropPrimaryKeyOnIdColumnOfRulesTableTest {
+  private static final String TABLE_NAME = "rules";
 
   @Rule
   public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesTableTest.class, "schema.sql");
@@ -39,18 +40,19 @@ public class DropPrimaryKeyOnIdColumnOfRulesTableTest {
 
   @Test
   public void execute() throws SQLException {
-    db.assertTableExists("rules");
-    db.assertPrimaryKey("rules", "pk_rules", "id");
+    db.assertTableExists(TABLE_NAME);
+    db.assertPrimaryKey(TABLE_NAME, "pk_rules", "id");
 
     underTest.execute();
 
-    db.assertNoPrimaryKey("rules");
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 9599070a71ec3093b1b4ec1229676e80ee03ae7e..351dcd1c21ca6f5ff134df2130c35c677138ccaf 100644 (file)
@@ -27,9 +27,8 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest {
+  private static final String TABLE_NAME = "rules_metadata";
 
   @Rule
   public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.class, "schema.sql");
@@ -39,18 +38,19 @@ public class DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest {
 
   @Test
   public void execute() throws SQLException {
-    db.assertTableExists("rules_metadata");
-    db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_id", "organization_uuid");
+    db.assertTableExists(TABLE_NAME);
+    db.assertPrimaryKey(TABLE_NAME, "pk_rules_metadata", "rule_id", "organization_uuid");
 
     underTest.execute();
 
-    db.assertNoPrimaryKey("rules_metadata");
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 2a99521b12b059c8e6cd07f1a9ea4a127fed4b12..44715d556925deb6ce63dfa11ab37d873ceade52 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfRulesParametersTableTest {
 
   private static final String TABLE_NAME = "rules_parameters";
@@ -47,10 +45,11 @@ public class DropPrimaryKeyOnIdColumnOfRulesParametersTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 
 }
index c4c7eeef714d09f7dcbf67e2a6d274b851dda434..1062c2c04eb15f69f9976f04aef8e54fb0b48405 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest {
   private static final String TABLE_NAME = "rules_profiles";
   @Rule
@@ -46,9 +44,10 @@ public class DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index c6cb5abb90d2720ab2df814fe2e529cd3ec18b78..f55068b7a4faca8a8338c42b4930025db2d04d99 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfSnapshotsTableTest {
 
   private static final String TABLE_NAME = "snapshots";
@@ -47,9 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfSnapshotsTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index b5e43bd15a6657adff707002844e1dcbcf98c178..677b97c8f36dba0592e634534771d78a588a6695 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfUsersTableTest {
   private static final String TABLE_NAME = "users";
   @Rule
@@ -46,9 +44,10 @@ public class DropPrimaryKeyOnIdColumnOfUsersTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index 0285776871447ae1c6e9ae4870175f949d783225..cbc0310e1f5e2390862add88d6b2151a02e720bb 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.DdlChange;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest {
   private static final String TABLE_NAME = "organization_members";
   @Rule
@@ -46,9 +44,10 @@ public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }
index fdcc034b15dba5dd1c681535a0cc6e40810f3215..48b4fd82831c2f0b15713654811708d9b5f93d3e 100644 (file)
@@ -27,8 +27,6 @@ import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
 import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
 import org.sonar.server.platform.db.migration.step.MigrationStep;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
 public class DropPrimaryKeyOnIdColumnOfUserTokensTableTest {
 
   private static final String TABLE_NAME = "user_tokens";
@@ -47,9 +45,10 @@ public class DropPrimaryKeyOnIdColumnOfUserTokensTableTest {
   }
 
   @Test
-  public void migration_is_not_re_entrant() throws SQLException {
+  public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+    underTest.execute();
     underTest.execute();
 
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+    db.assertNoPrimaryKey(TABLE_NAME);
   }
 }