Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-6256 Drop dependencies.from_resource_id and dependencies.to_res…
…ource_id
- Loading branch information
1 parent
c83af35
commit e58da28
Showing
18 changed files
with
212 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...er/src/main/java/org/sonar/server/db/migrations/v52/DropDependenciesComponentColumns.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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.db.migrations.v52; | |||
|
|||
import com.google.common.annotations.VisibleForTesting; | |||
import org.sonar.core.persistence.Database; | |||
import org.sonar.server.db.migrations.DdlChange; | |||
import org.sonar.server.db.migrations.DropColumnsBuilder; | |||
|
|||
import java.sql.SQLException; | |||
|
|||
/** | |||
* Remove the following columns from the dependencies table : | |||
* - from_resource_id | |||
* - to_resource_id | |||
*/ | |||
public class DropDependenciesComponentColumns extends DdlChange { | |||
|
|||
private final Database db; | |||
|
|||
public DropDependenciesComponentColumns(Database db) { | |||
super(db); | |||
this.db = db; | |||
} | |||
|
|||
@Override | |||
public void execute(Context context) throws SQLException { | |||
context.execute(generateSql()); | |||
} | |||
|
|||
@VisibleForTesting | |||
String generateSql() { | |||
return new DropColumnsBuilder(db.getDialect(), "dependencies", "from_resource_id", "to_resource_id") | |||
.build(); | |||
} | |||
|
|||
} |
52 changes: 52 additions & 0 deletions
52
...rc/test/java/org/sonar/server/db/migrations/v52/DropDependenciesComponentColumnsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,52 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube 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. | |||
* | |||
* SonarQube 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.db.migrations.v52; | |||
|
|||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.sonar.core.persistence.Database; | |||
import org.sonar.core.persistence.dialect.PostgreSql; | |||
|
|||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
|
|||
public class DropDependenciesComponentColumnsTest { | |||
|
|||
DropDependenciesComponentColumns migration; | |||
|
|||
Database database; | |||
|
|||
@Before | |||
public void setUp() throws Exception { | |||
database = mock(Database.class); | |||
migration = new DropDependenciesComponentColumns(database); | |||
} | |||
|
|||
@Test | |||
public void generate_sql_on_postgresql() throws Exception { | |||
when(database.getDialect()).thenReturn(new PostgreSql()); | |||
assertThat(migration.generateSql()).isEqualTo( | |||
"ALTER TABLE dependencies DROP COLUMN from_resource_id, DROP COLUMN to_resource_id" | |||
); | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/911_remove_dependencies_component_ids.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
# | |||
# SonarQube, open source software quality management tool. | |||
# Copyright (C) 2008-2014 SonarSource | |||
# mailto:contact AT sonarsource DOT com | |||
# | |||
# SonarQube 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. | |||
# | |||
# SonarQube 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. | |||
# | |||
|
|||
# | |||
# SonarQube 5.2 | |||
# SONAR-6256 | |||
# | |||
class RemoveDependenciesComponentIds < ActiveRecord::Migration | |||
|
|||
def self.up | |||
execute_java_migration('org.sonar.server.db.migrations.v52.DropDependenciesComponentColumns') | |||
end | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
sonar-core/src/test/resources/org/sonar/core/dependency/DependencyMapperTest/fixture.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,4 @@ | |||
<dataset> | <dataset> | ||
<dependencies id="1" from_resource_id="100" to_resource_id="101" from_snapshot_id="1000" to_snapshot_id="1001" dep_usage="compile" dep_weight="1" /> | <dependencies id="1" from_component_uuid="ABCD" to_component_uuid="EFGH" from_snapshot_id="1000" to_snapshot_id="1001" dep_usage="compile" dep_weight="1" /> | ||
<dependencies id="2" from_resource_id="200" to_resource_id="201" from_snapshot_id="2000" to_snapshot_id="2001" dep_usage="provided" dep_weight="1" /> | <dependencies id="2" from_component_uuid="DCBA" to_component_uuid="HGFE" from_snapshot_id="2000" to_snapshot_id="2001" dep_usage="provided" dep_weight="1" /> | ||
</dataset> | </dataset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.