diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-05 21:54:22 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-05 21:54:22 +0200 |
commit | b96df0defa1e12f9f679e4c6e8b451bde1a7a566 (patch) | |
tree | 8fcb6c8413b957f3fc0d3ac316842662d6d8aaca /sonar-core | |
parent | 40ef7ce47f9400d88d351db0bf7e6c8dd7abba68 (diff) | |
download | sonarqube-b96df0defa1e12f9f679e4c6e8b451bde1a7a566.tar.gz sonarqube-b96df0defa1e12f9f679e4c6e8b451bde1a7a566.zip |
SONAR-5381 SONAR-3350 replace mysql MEDIUMTEXT columns by LONGTEXT
Diffstat (limited to 'sonar-core')
8 files changed, 76 insertions, 5 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index 105c8c5b58f..dcb5e436527 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -33,7 +33,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 584; + public static final int LAST_VERSION = 600; public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java index 8dd6bdebe48..435682d17a3 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/MySql.java @@ -48,8 +48,8 @@ public class MySql extends AbstractDialect { public MySqlWithDecimalDialect() { super(); registerColumnType(Types.DOUBLE, "decimal precision"); - registerColumnType(Types.VARCHAR, DatabaseProperties.MAX_TEXT_SIZE, "mediumtext"); - registerColumnType(Types.CLOB, "mediumtext"); + registerColumnType(Types.VARCHAR, DatabaseProperties.MAX_TEXT_SIZE, "longtext"); + registerColumnType(Types.CLOB, "longtext"); registerColumnType(Types.BLOB, "blob"); } } diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java index e535f7a3340..3b28c5c5806 100644 --- a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java +++ b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java @@ -21,6 +21,7 @@ package org.sonar.core.source.db; import org.apache.ibatis.session.SqlSession; +import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; import org.sonar.core.persistence.MyBatis; @@ -29,7 +30,7 @@ import javax.annotation.CheckForNull; /** * @since 3.6 */ -public class SnapshotSourceDao implements ServerComponent { +public class SnapshotSourceDao implements BatchComponent, ServerComponent { private final MyBatis mybatis; @@ -66,4 +67,14 @@ public class SnapshotSourceDao implements ServerComponent { } } + public void insert(SnapshotSourceDto dto) { + SqlSession session = mybatis.openSession(false); + try { + session.getMapper(SnapshotSourceMapper.class).insert(dto); + session.commit(); + } finally { + MyBatis.closeQuietly(session); + } + } + } diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java new file mode 100644 index 00000000000..34df236684d --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java @@ -0,0 +1,50 @@ +/* + * 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.core.source.db; + +public class SnapshotSourceDto { + private Long id; + private Long snapshotId; + private String data; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(Long snapshotId) { + this.snapshotId = snapshotId; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceMapper.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceMapper.java index 95f5a96d2c4..565c1d09e45 100644 --- a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceMapper.java @@ -20,12 +20,18 @@ package org.sonar.core.source.db; +import javax.annotation.CheckForNull; + /** * @since 3.6 */ public interface SnapshotSourceMapper { + @CheckForNull String selectSnapshotSource(long snapshotId); + @CheckForNull String selectSnapshotSourceByComponentKey(String componentKey); + + void insert(SnapshotSourceDto dto); } diff --git a/sonar-core/src/main/resources/META-INF/persistence.xml b/sonar-core/src/main/resources/META-INF/persistence.xml index 3742d878b1f..099bd1c8c9e 100644 --- a/sonar-core/src/main/resources/META-INF/persistence.xml +++ b/sonar-core/src/main/resources/META-INF/persistence.xml @@ -15,7 +15,6 @@ <class>org.sonar.api.design.DependencyDto</class> <class>org.sonar.api.measures.Metric</class> <class>org.sonar.api.database.model.ResourceModel</class> - <class>org.sonar.api.database.model.SnapshotSource</class> <class>org.sonar.api.rules.Rule</class> <class>org.sonar.api.rules.RuleParam</class> <class>org.sonar.api.resources.ProjectLink</class> diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index d9ea9b3d667..687099904a9 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -254,6 +254,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('581'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('582'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('583'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('584'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('600'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml index de072269330..85d08e05d9f 100644 --- a/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml @@ -18,5 +18,9 @@ WHERE p.kee = #{componentKey} </select> + <insert id="insert" parameterType="org.sonar.core.source.db.SnapshotSourceDto" useGeneratedKeys="false"> + insert into snapshot_sources (snapshot_id, data) values (#{snapshotId}, #{data}) + </insert> + </mapper> |