3 * Copyright (C) 2009-2024 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.platform.db.migration.version.v00;
22 import java.sql.Connection;
23 import java.sql.ResultSet;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Locale;
28 import org.junit.Rule;
29 import org.junit.Test;
30 import org.sonar.db.MigrationDbTester;
32 import static org.assertj.core.api.Assertions.assertThat;
34 public class CreateInitialSchemaIT {
36 private static final Set<String> SCHEMAS_TO_IGNORE = Set.of("INFORMATION_SCHEMA", "sys", "SYS", "SYSTEM", "CTXSYS", "MDSYS", "XDB");
39 public final MigrationDbTester dbTester = MigrationDbTester.createForMigrationStep(CreateInitialSchema.class);
41 private final CreateInitialSchema underTest = new CreateInitialSchema(dbTester.database());
44 public void creates_tables_on_empty_db() throws Exception {
47 List<String> tables = new ArrayList<>();
48 try (Connection connection = dbTester.openConnection();
49 ResultSet rs = connection.getMetaData().getTables(null, null, null, new String[]{"TABLE"})) {
52 String schema = rs.getString("TABLE_SCHEM");
53 if (!SCHEMAS_TO_IGNORE.contains(schema)) {
54 tables.add(rs.getString("TABLE_NAME").toLowerCase(Locale.ENGLISH));
62 "active_rule_parameters",
63 "app_branch_project_branch",
68 "project_alm_settings",
69 "analysis_properties",
73 "ce_task_characteristics",
78 "deprecated_rule_keys",
82 "event_component_changes",
87 "internal_component_props",
88 "internal_properties",
94 "new_code_reference_issues",
97 "permission_templates",
98 "perm_templates_groups",
99 "perm_templates_users",
100 "perm_tpl_characteristics",
103 "portfolio_projects",
104 "portfolio_proj_branches",
105 "portfolio_references",
107 "project_badge_token",
116 "qgate_group_permissions",
117 "qgate_user_permissions",
119 "qprofile_edit_groups",
120 "qprofile_edit_users",
122 "quality_gate_conditions",
127 "rule_desc_sections",
129 "scanner_analysis_cache",
135 "user_dismissed_messages",
139 "webhook_deliveries");