@@ -1102,9 +1102,9 @@ CREATE TABLE "WEBHOOK_DELIVERIES"( | |||
"CREATED_AT" BIGINT NOT NULL | |||
); | |||
ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); | |||
CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST); | |||
CREATE INDEX "IDX_WBHK_DLVRS_WBHK_UUID" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID" NULLS FIRST); | |||
CREATE INDEX "WD_PROJECT_UUID" ON "WEBHOOK_DELIVERIES"("PROJECT_UUID" NULLS FIRST); | |||
CREATE INDEX "WD_WEBHOOK_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID" NULLS FIRST, "CREATED_AT" NULLS FIRST); | |||
CREATE INDEX "WD_PROJECT_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("PROJECT_UUID" NULLS FIRST, "CREATED_AT" NULLS FIRST); | |||
CREATE INDEX "WD_CE_TASK_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST, "CREATED_AT" NULLS FIRST); | |||
CREATE TABLE "WEBHOOKS"( | |||
"UUID" CHARACTER VARYING(40) NOT NULL, |
@@ -0,0 +1,62 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.step; | |||
import java.sql.Connection; | |||
import java.sql.SQLException; | |||
import org.sonar.db.Database; | |||
import org.sonar.db.DatabaseUtils; | |||
import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; | |||
public abstract class CreateIndexOnColumns extends DdlChange { | |||
private final String table; | |||
private final String indexPrefix; | |||
private final String[] columnNames; | |||
private final boolean unique; | |||
protected CreateIndexOnColumns(Database db, String table, String indexPrefix, boolean unique, String... columnNames) { | |||
super(db); | |||
this.table = table; | |||
this.indexPrefix = indexPrefix; | |||
this.unique = unique; | |||
this.columnNames = columnNames; | |||
} | |||
@Override | |||
public void execute(Context context) throws SQLException { | |||
try (Connection connection = getDatabase().getDataSource().getConnection()) { | |||
if (!DatabaseUtils.indexExistsIgnoreCase(table, newIndexName(), connection)) { | |||
CreateIndexBuilder builder = new CreateIndexBuilder() | |||
.setTable(table) | |||
.setName(newIndexName()) | |||
.setUnique(unique); | |||
for (String columnName : columnNames) { | |||
builder.addColumn(columnName); | |||
} | |||
context.execute(builder.build()); | |||
} | |||
} | |||
} | |||
public String newIndexName() { | |||
return indexPrefix + "_" + String.join("_", columnNames); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import org.sonar.db.Database; | |||
import org.sonar.server.platform.db.migration.step.CreateIndexOnColumns; | |||
public class CreateIndexProjectUuidCreatedAtInWebhookDeliveries extends CreateIndexOnColumns { | |||
protected CreateIndexProjectUuidCreatedAtInWebhookDeliveries(Database db) { | |||
super(db, "webhook_deliveries", "wd", false, "project_uuid", "created_at"); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import org.sonar.db.Database; | |||
import org.sonar.server.platform.db.migration.step.CreateIndexOnColumns; | |||
public class CreateIndexTaskUuidCreatedAtInWebhookDeliveries extends CreateIndexOnColumns { | |||
protected CreateIndexTaskUuidCreatedAtInWebhookDeliveries(Database db) { | |||
super(db, "webhook_deliveries", "wd", false, "ce_task_uuid", "created_at"); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import org.sonar.db.Database; | |||
import org.sonar.server.platform.db.migration.step.CreateIndexOnColumns; | |||
public class CreateIndexWebhookUuidCreatedAtInWebhookDeliveries extends CreateIndexOnColumns { | |||
protected CreateIndexWebhookUuidCreatedAtInWebhookDeliveries(Database db) { | |||
super(db, "webhook_deliveries", "wd", false, "webhook_uuid", "created_at"); | |||
} | |||
} |
@@ -25,6 +25,7 @@ import org.sonar.server.platform.db.migration.version.DbVersion; | |||
// ignoring bad number formatting, as it's indented that we align the migration numbers to SQ versions | |||
@SuppressWarnings("java:S3937") | |||
public class DbVersion102 implements DbVersion { | |||
/** | |||
* We use the start of the 10.X cycle as an opportunity to align migration numbers with the SQ version number. | |||
* Please follow this pattern: | |||
@@ -85,6 +86,8 @@ public class DbVersion102 implements DbVersion { | |||
.add(10_2_032, "Increase size of 'ce_queue.main_is_last_key' from 55 to 80 characters", IncreaseMainIsLastKeyInCeActivity.class) | |||
.add(10_2_033, "Add column 'clean_code_attribute' in 'rules' table", AddCleanCodeAttributeInRules.class) | |||
.add(10_2_034, "Populate 'clean_code_attribute' column in 'rules' table", PopulateCleanCodeAttributeColumnInRules.class) | |||
//TODO SONAR-20073 | |||
//.add(10_2_035, "Make 'clean_code_attribute' column not nullable in 'rules' table", MakeCleanCodeAttributeColumnNotNullableInRules.class); | |||
.add(10_2_036, "Create 'rules_default_impacts' table", CreateRulesDefaultImpactsTable.class) | |||
.add(10_2_037, "Create unique constraint index on 'rules_default_impacts' table", CreateUniqueConstraintOnRulesDefaultImpacts.class) | |||
@@ -98,6 +101,14 @@ public class DbVersion102 implements DbVersion { | |||
.add(10_2_044, "Update column 'value' and populate column 'previous_non_compliant_value' in 'new_code_periods' table", | |||
UpdateValueAndPopulatePreviousNonCompliantValueInNewCodePeriods.class) | |||
.add(10_2_045, "Alter 'project_uuid' in 'user_dismissed_messages' - make it nullable", MakeProjectUuidNullableInUserDismissedMessages.class) | |||
.add(10_2_046, "Create index 'project_branches_project_uuid' in 'project_branches' table", CreateIndexProjectUuidInProjectBranches.class); | |||
.add(10_2_046, "Create index 'project_branches_project_uuid' in 'project_branches' table", CreateIndexProjectUuidInProjectBranches.class) | |||
.add(10_2_047, "Drop index 'idx_wbhk_dlvrs_wbhk_uuid' in 'webhook_deliveries'", DropIndexWebhookUuidInWebhookDeliveries.class) | |||
.add(10_2_048, "Create index 'wb_webhook_uuid_created_at' in 'webhook_deliveries'", CreateIndexWebhookUuidCreatedAtInWebhookDeliveries.class) | |||
.add(10_2_049, "Drop index 'wd_project_uuid' in 'webhook_deliveries'", DropIndexProjectUuidInWebhookDeliveries.class) | |||
.add(10_2_050, "Create index 'wd_project_uuid_created_at' in 'webhook_deliveries'", CreateIndexProjectUuidCreatedAtInWebhookDeliveries.class) | |||
.add(10_2_051, "Drop index 'ce_task_uuid' in 'webhook_deliveries'", DropIndexTaskUuidInWebhookDeliveries.class) | |||
.add(10_2_052, "Create index 'wd_task_uuid_created_at' in 'webhook_deliveries'", CreateIndexTaskUuidCreatedAtInWebhookDeliveries.class) | |||
; | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import org.sonar.db.Database; | |||
import org.sonar.server.platform.db.migration.step.DropIndexChange; | |||
public class DropIndexProjectUuidInWebhookDeliveries extends DropIndexChange { | |||
public DropIndexProjectUuidInWebhookDeliveries(Database db) { | |||
super(db, "wd_project_uuid", "webhook_deliveries"); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import org.sonar.db.Database; | |||
import org.sonar.server.platform.db.migration.step.DropIndexChange; | |||
public class DropIndexTaskUuidInWebhookDeliveries extends DropIndexChange { | |||
public DropIndexTaskUuidInWebhookDeliveries(Database db) { | |||
super(db, "ce_task_uuid", "webhook_deliveries"); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import org.sonar.db.Database; | |||
import org.sonar.server.platform.db.migration.step.DropIndexChange; | |||
public class DropIndexWebhookUuidInWebhookDeliveries extends DropIndexChange { | |||
public DropIndexWebhookUuidInWebhookDeliveries(Database db) { | |||
super(db, "idx_wbhk_dlvrs_wbhk_uuid", "webhook_deliveries"); | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import java.sql.SQLException; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.db.CoreDbTester; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
public class CreateIndexProjectUuidCreatedAtInWebhookDeliveriesTest { | |||
public static final String TABLE_NAME = "webhook_deliveries"; | |||
public static final String INDEX_NAME = "wd_project_uuid_created_at"; | |||
@Rule | |||
public final CoreDbTester db = CoreDbTester.createForSchema(CreateIndexProjectUuidCreatedAtInWebhookDeliveriesTest.class, "schema.sql"); | |||
private final DdlChange createIndex = new CreateIndexProjectUuidCreatedAtInWebhookDeliveries(db.database()); | |||
@Test | |||
public void migration_should_create_index() throws SQLException { | |||
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); | |||
createIndex.execute(); | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, "project_uuid", "created_at"); | |||
} | |||
@Test | |||
public void migration_should_be_reentrant() throws SQLException { | |||
createIndex.execute(); | |||
createIndex.execute(); | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, "project_uuid", "created_at"); | |||
} | |||
} |
@@ -0,0 +1,54 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import java.sql.SQLException; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.db.CoreDbTester; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
public class CreateIndexTaskUuidCreatedAtInWebhookDeliveriesTest { | |||
public static final String TABLE_NAME = "webhook_deliveries"; | |||
public static final String INDEX_NAME = "wd_ce_task_uuid_created_at"; | |||
@Rule | |||
public final CoreDbTester db = CoreDbTester.createForSchema(CreateIndexTaskUuidCreatedAtInWebhookDeliveriesTest.class, "schema.sql"); | |||
private final DdlChange createIndex = new CreateIndexTaskUuidCreatedAtInWebhookDeliveries(db.database()); | |||
@Test | |||
public void migration_should_create_index() throws SQLException { | |||
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); | |||
createIndex.execute(); | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, "ce_task_uuid", "created_at"); | |||
} | |||
@Test | |||
public void migration_should_be_reentrant() throws SQLException { | |||
createIndex.execute(); | |||
createIndex.execute(); | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, "ce_task_uuid", "created_at"); | |||
} | |||
} |
@@ -0,0 +1,55 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import java.sql.SQLException; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.db.CoreDbTester; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
public class CreateIndexWebhookUuidCreatedAtInWebhookDeliveriesTest { | |||
public static final String TABLE_NAME = "webhook_deliveries"; | |||
public static final String INDEX_NAME = "wd_webhook_uuid_created_at"; | |||
@Rule | |||
public final CoreDbTester db = CoreDbTester.createForSchema(CreateIndexWebhookUuidCreatedAtInWebhookDeliveriesTest.class, "schema.sql"); | |||
private final DdlChange createIndex = new CreateIndexWebhookUuidCreatedAtInWebhookDeliveries(db.database()); | |||
@Test | |||
public void migration_should_create_index() throws SQLException { | |||
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); | |||
createIndex.execute(); | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, "webhook_uuid", "created_at"); | |||
} | |||
@Test | |||
public void migration_should_be_reentrant() throws SQLException { | |||
createIndex.execute(); | |||
createIndex.execute(); | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, "webhook_uuid", "created_at"); | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import java.sql.SQLException; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.db.CoreDbTester; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
public class DropIndexProjectUuidInWebhookDeliveriesTest { | |||
private static final String TABLE_NAME = "webhook_deliveries"; | |||
private static final String COLUMN_NAME = "project_uuid"; | |||
private static final String INDEX_NAME = "wd_project_uuid"; | |||
@Rule | |||
public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexProjectUuidInWebhookDeliveriesTest.class, "schema.sql"); | |||
private final DdlChange underTest = new DropIndexProjectUuidInWebhookDeliveries(db.database()); | |||
@Test | |||
public void index_is_dropped() throws SQLException { | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME); | |||
underTest.execute(); | |||
db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME); | |||
} | |||
@Test | |||
public void migration_is_reentrant() throws SQLException { | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME); | |||
underTest.execute(); | |||
underTest.execute(); | |||
db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME); | |||
} | |||
} |
@@ -0,0 +1,57 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import java.sql.SQLException; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.db.CoreDbTester; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
public class DropIndexTaskUuidInWebhookDeliveriesTest { | |||
private static final String TABLE_NAME = "webhook_deliveries"; | |||
private static final String COLUMN_NAME = "ce_task_uuid"; | |||
private static final String INDEX_NAME = "ce_task_uuid"; | |||
@Rule | |||
public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexTaskUuidInWebhookDeliveriesTest.class, "schema.sql"); | |||
private final DdlChange underTest = new DropIndexTaskUuidInWebhookDeliveries(db.database()); | |||
@Test | |||
public void index_is_dropped() throws SQLException { | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME); | |||
underTest.execute(); | |||
db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME); | |||
} | |||
@Test | |||
public void migration_is_reentrant() throws SQLException { | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME); | |||
underTest.execute(); | |||
underTest.execute(); | |||
db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME); | |||
} | |||
} |
@@ -0,0 +1,58 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2023 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.server.platform.db.migration.version.v102; | |||
import java.sql.SQLException; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.db.CoreDbTester; | |||
import org.sonar.server.platform.db.migration.step.DdlChange; | |||
public class DropIndexWebhookUuidInWebhookDeliveriesTest { | |||
private static final String TABLE_NAME = "webhook_deliveries"; | |||
private static final String COLUMN_NAME = "webhook_uuid"; | |||
private static final String INDEX_NAME = "idx_wbhk_dlvrs_wbhk_uuid"; | |||
@Rule | |||
public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexWebhookUuidInWebhookDeliveriesTest.class, "schema.sql"); | |||
private final DdlChange underTest = new DropIndexWebhookUuidInWebhookDeliveries(db.database()); | |||
@Test | |||
public void index_is_dropped() throws SQLException { | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME); | |||
underTest.execute(); | |||
db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME); | |||
} | |||
@Test | |||
public void migration_is_reentrant() throws SQLException { | |||
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME); | |||
underTest.execute(); | |||
underTest.execute(); | |||
db.assertIndexDoesNotExist(TABLE_NAME, COLUMN_NAME); | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
CREATE TABLE "WEBHOOK_DELIVERIES"( | |||
"UUID" CHARACTER VARYING(40) NOT NULL, | |||
"WEBHOOK_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"PROJECT_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"CE_TASK_UUID" CHARACTER VARYING(40), | |||
"ANALYSIS_UUID" CHARACTER VARYING(40), | |||
"NAME" CHARACTER VARYING(100) NOT NULL, | |||
"URL" CHARACTER VARYING(2000) NOT NULL, | |||
"SUCCESS" BOOLEAN NOT NULL, | |||
"HTTP_STATUS" INTEGER, | |||
"DURATION_MS" BIGINT NOT NULL, | |||
"PAYLOAD" CHARACTER LARGE OBJECT NOT NULL, | |||
"ERROR_STACKTRACE" CHARACTER LARGE OBJECT, | |||
"CREATED_AT" BIGINT NOT NULL | |||
); | |||
ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); | |||
CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST); | |||
CREATE INDEX "WD_WEBHOOK_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID", "CREATED_AT" NULLS FIRST); |
@@ -0,0 +1,18 @@ | |||
CREATE TABLE "WEBHOOK_DELIVERIES"( | |||
"UUID" CHARACTER VARYING(40) NOT NULL, | |||
"WEBHOOK_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"PROJECT_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"CE_TASK_UUID" CHARACTER VARYING(40), | |||
"ANALYSIS_UUID" CHARACTER VARYING(40), | |||
"NAME" CHARACTER VARYING(100) NOT NULL, | |||
"URL" CHARACTER VARYING(2000) NOT NULL, | |||
"SUCCESS" BOOLEAN NOT NULL, | |||
"HTTP_STATUS" INTEGER, | |||
"DURATION_MS" BIGINT NOT NULL, | |||
"PAYLOAD" CHARACTER LARGE OBJECT NOT NULL, | |||
"ERROR_STACKTRACE" CHARACTER LARGE OBJECT, | |||
"CREATED_AT" BIGINT NOT NULL | |||
); | |||
ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); | |||
CREATE INDEX "WD_WEBHOOK_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID", "CREATED_AT" NULLS FIRST); | |||
CREATE INDEX "WD_PROJECT_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("PROJECT_UUID", "CREATED_AT" NULLS FIRST); |
@@ -0,0 +1,18 @@ | |||
CREATE TABLE "WEBHOOK_DELIVERIES"( | |||
"UUID" CHARACTER VARYING(40) NOT NULL, | |||
"WEBHOOK_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"PROJECT_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"CE_TASK_UUID" CHARACTER VARYING(40), | |||
"ANALYSIS_UUID" CHARACTER VARYING(40), | |||
"NAME" CHARACTER VARYING(100) NOT NULL, | |||
"URL" CHARACTER VARYING(2000) NOT NULL, | |||
"SUCCESS" BOOLEAN NOT NULL, | |||
"HTTP_STATUS" INTEGER, | |||
"DURATION_MS" BIGINT NOT NULL, | |||
"PAYLOAD" CHARACTER LARGE OBJECT NOT NULL, | |||
"ERROR_STACKTRACE" CHARACTER LARGE OBJECT, | |||
"CREATED_AT" BIGINT NOT NULL | |||
); | |||
ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); | |||
CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST); | |||
CREATE INDEX "PROJECT_UUID" ON "WEBHOOK_DELIVERIES"("PROJECT_UUID" NULLS FIRST); |
@@ -0,0 +1,19 @@ | |||
CREATE TABLE "WEBHOOK_DELIVERIES"( | |||
"UUID" CHARACTER VARYING(40) NOT NULL, | |||
"WEBHOOK_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"PROJECT_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"CE_TASK_UUID" CHARACTER VARYING(40), | |||
"ANALYSIS_UUID" CHARACTER VARYING(40), | |||
"NAME" CHARACTER VARYING(100) NOT NULL, | |||
"URL" CHARACTER VARYING(2000) NOT NULL, | |||
"SUCCESS" BOOLEAN NOT NULL, | |||
"HTTP_STATUS" INTEGER, | |||
"DURATION_MS" BIGINT NOT NULL, | |||
"PAYLOAD" CHARACTER LARGE OBJECT NOT NULL, | |||
"ERROR_STACKTRACE" CHARACTER LARGE OBJECT, | |||
"CREATED_AT" BIGINT NOT NULL | |||
); | |||
ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); | |||
CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST); | |||
CREATE INDEX "WD_PROJECT_UUID" ON "WEBHOOK_DELIVERIES"("PROJECT_UUID" NULLS FIRST); | |||
CREATE INDEX "WD_WEBHOOK_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID", "CREATED_AT" NULLS FIRST); |
@@ -0,0 +1,19 @@ | |||
CREATE TABLE "WEBHOOK_DELIVERIES"( | |||
"UUID" CHARACTER VARYING(40) NOT NULL, | |||
"WEBHOOK_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"PROJECT_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"CE_TASK_UUID" CHARACTER VARYING(40), | |||
"ANALYSIS_UUID" CHARACTER VARYING(40), | |||
"NAME" CHARACTER VARYING(100) NOT NULL, | |||
"URL" CHARACTER VARYING(2000) NOT NULL, | |||
"SUCCESS" BOOLEAN NOT NULL, | |||
"HTTP_STATUS" INTEGER, | |||
"DURATION_MS" BIGINT NOT NULL, | |||
"PAYLOAD" CHARACTER LARGE OBJECT NOT NULL, | |||
"ERROR_STACKTRACE" CHARACTER LARGE OBJECT, | |||
"CREATED_AT" BIGINT NOT NULL | |||
); | |||
ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); | |||
CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST); | |||
CREATE INDEX "WD_WEBHOOK_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID", "CREATED_AT" NULLS FIRST); | |||
CREATE INDEX "WD_PROJECT_UUID_CREATED_AT" ON "WEBHOOK_DELIVERIES"("PROJECT_UUID", "CREATED_AT" NULLS FIRST); |
@@ -0,0 +1,19 @@ | |||
CREATE TABLE "WEBHOOK_DELIVERIES"( | |||
"UUID" CHARACTER VARYING(40) NOT NULL, | |||
"WEBHOOK_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"PROJECT_UUID" CHARACTER VARYING(40) NOT NULL, | |||
"CE_TASK_UUID" CHARACTER VARYING(40), | |||
"ANALYSIS_UUID" CHARACTER VARYING(40), | |||
"NAME" CHARACTER VARYING(100) NOT NULL, | |||
"URL" CHARACTER VARYING(2000) NOT NULL, | |||
"SUCCESS" BOOLEAN NOT NULL, | |||
"HTTP_STATUS" INTEGER, | |||
"DURATION_MS" BIGINT NOT NULL, | |||
"PAYLOAD" CHARACTER LARGE OBJECT NOT NULL, | |||
"ERROR_STACKTRACE" CHARACTER LARGE OBJECT, | |||
"CREATED_AT" BIGINT NOT NULL | |||
); | |||
ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); | |||
CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST); | |||
CREATE INDEX "IDX_WBHK_DLVRS_WBHK_UUID" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID" NULLS FIRST); | |||
CREATE INDEX "PROJECT_UUID" ON "WEBHOOK_DELIVERIES"("PROJECT_UUID" NULLS FIRST); |