</prerequisites>
<properties>
- <!--
- Warning before upgrading Derby to 10.8 : new conversion from BOOLEAN to CHAR.
- "If you use setBoolean() or setObject() with a CHAR(1) datatype you must change your code and use setInt() or Derby will try to store "true" or
- "false" strings."
- -->
- <derby.version>10.7.1.1</derby.version>
-
+ <h2.version>1.3.167</h2.version>
<jetty.version>6.1.25</jetty.version>
<sonar.skippedModules>sonar-gwt-api,sonar-core-gwt</sonar.skippedModules>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version>0.9.30</version>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbyclient</artifactId>
- <version>${derby.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>${derby.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbynet</artifactId>
- <version>${derby.version}</version>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
</dependency>
<dependency>
<!--
<excludes>
<exclude>org.codehaus.sonar:sonar-server</exclude>
<exclude>mysql:mysql-connector-java</exclude>
- <exclude>org.apache.derby:derbyclient</exclude>
+ <exclude>com.h2database:h2</exclude>
<exclude>postgresql:postgresql</exclude>
<exclude>net.sourceforge.jtds:jtds</exclude>
<exclude>org.codehaus.sonar.plugins:*</exclude>
<scope>runtime</scope>
</dependencySet>
<dependencySet>
- <outputDirectory>extensions/jdbc-driver/derby/</outputDirectory>
+ <outputDirectory>extensions/jdbc-driver/h2/</outputDirectory>
<includes>
- <include>org.apache.derby:derbyclient</include>
+ <include>com.h2database:h2</include>
</includes>
<unpack>false</unpack>
<scope>runtime</scope>
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbyclient</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
#-----------------------------------------------------------------------
# DATABASE
#
-# IMPORTANT : the embedded database Derby is used by default.
+# IMPORTANT : the embedded database H2 is used by default.
# It is recommended for tests only. Please use an external database
# for production environment (MySQL, Oracle, Postgresql, SQLServer)
#
sonar.jdbc.username: sonar
sonar.jdbc.password: sonar
-#----- Embedded database Derby
+#----- Embedded database H2
# Note : it does not accept connections from remote hosts, so the
# sonar server and the maven plugin must be executed on the same host.
# Comment the following line to deactivate the default embedded database.
-sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
-#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
+sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar
+#sonar.jdbc.driverClassName: org.h2.Driver
#sonar.jdbc.validationQuery: values(1)
-# directory containing Derby database files. By default it's the /data directory in the sonar installation.
+# directory containing H2 database files. By default it's the /data directory in the sonar installation.
#sonar.embeddedDatabase.dataDir:
-# derby embedded database server listening port, defaults to 1527
-#sonar.derby.drda.portNumber: 1527
-
-# uncomment to accept connections from remote hosts. Ba default it only accepts localhost connections.
-#sonar.derby.drda.host: 0.0.0.0
+# H2 embedded database server listening port, defaults to 9092
+#sonar.embeddedDatabase.port: 9092
#----- MySQL 5.x/6.x
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbyclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbynet</artifactId>
- </dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-update-center-common</artifactId>
<artifactId>jtds</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
import java.sql.Connection;
/**
- * Restore schema by executing DDL scripts. Only Derby database is supported.
+ * Restore schema by executing DDL scripts. Only H2 database is supported.
* Other databases are created by Ruby on Rails migrations.
*
* @since 2.12
}
public static boolean supportsDialect(String dialect) {
- return "derby".equals(dialect);
+ return "h2".equals(dialect);
}
/**
import org.slf4j.LoggerFactory;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseProperties;
-import org.sonar.core.persistence.dialect.*;
+import org.sonar.core.persistence.dialect.Dialect;
+import org.sonar.core.persistence.dialect.DialectUtils;
+import org.sonar.core.persistence.dialect.H2;
+import org.sonar.core.persistence.dialect.Oracle;
+import org.sonar.core.persistence.dialect.PostgreSql;
import org.sonar.jpa.session.CustomHibernateConnectionProvider;
import javax.sql.DataSource;
+
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
if (dialect == null) {
throw new IllegalStateException("Can not guess the JDBC dialect. Please check the property sonar.jdbc.url.");
}
- if (Derby.ID.equals(dialect.getId())) {
- LoggerFactory.getLogger(DefaultDatabase.class).warn("Derby database should be used for evaluation purpose only");
+ if (H2.ID.equals(dialect.getId())) {
+ LoggerFactory.getLogger(DefaultDatabase.class).warn("H2 database should be used for evaluation purpose only");
}
if (!properties.containsKey("sonar.jdbc.driverClassName")) {
properties.setProperty("sonar.jdbc.driverClassName", dialect.getDefaultDriverClassName());
}
}
- private void initDatasource() throws Exception {//NOSONAR this exception is thrown by BasicDataSourceFactory
+ private void initDatasource() throws Exception {// NOSONAR this exception is thrown by BasicDataSourceFactory
// but it's correctly caught by start()
LOG.info("Create JDBC datasource");
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.core.persistence.dialect;
-
-import org.apache.commons.lang.StringUtils;
-import org.hibernate.dialect.DerbyDialect;
-import org.hibernate.id.IdentityGenerator;
-import org.sonar.api.database.DatabaseProperties;
-
-import java.sql.Types;
-
-/**
- * @since 1.12
- */
-public class Derby implements Dialect {
-
- public static final String ID = "derby";
-
- public String getId() {
- return ID;
- }
-
- public String getActiveRecordDialectCode() {
- return "derby";
- }
-
- public String getActiveRecordJdbcAdapter() {
- return "jdbc";
- }
-
- public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
- return DerbyWithDecimalDialect.class;
- }
-
- public boolean matchesJdbcURL(String jdbcConnectionURL) {
- return StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:derby:");
- }
-
- public String getDefaultDriverClassName() {
- return "org.apache.derby.jdbc.ClientDriver";
- }
-
- public String getConnectionInitStatement(String schema) {
- return null;
- }
-
- public static class DerbyWithDecimalDialect extends DerbyDialect {
- public DerbyWithDecimalDialect() {
- super();
- registerColumnType(Types.DOUBLE, "decimal");
- registerColumnType(Types.VARCHAR, DatabaseProperties.MAX_TEXT_SIZE, "clob");
- registerColumnType(Types.VARBINARY, "blob");
-
- // Not possible to do alter column types in Derby
- registerColumnType(Types.BIGINT, "integer");
-
- registerColumnType(Types.BIT, "boolean");
- }
-
- @Override
- public String toBooleanValueString(boolean bool) {
- return bool ? "true" : "false";
- }
-
- /**
- * To be compliant with Oracle, we define on each model (ch.hortis.sonar.model classes)
- * a sequence generator. It works on mySQL because strategy = GenerationType.AUTO, so
- * it equals GenerationType.IDENTITY.
- * But on derby, AUTO becomes TABLE instead of IDENTITY. So we explicitly change this behavior.
- */
- @Override
- public Class getNativeIdentifierGeneratorClass() {
- return IdentityGenerator.class;
- }
- }
-
- public String getTrueSqlValue() {
- return "true";
- }
-
- public String getFalseSqlValue() {
- return "false";
- }
-}
private DialectUtils() {
}
- private static final Dialect[] DIALECTS = new Dialect[]{new Derby(), new MySql(), new Oracle(), new PostgreSql(), new MsSql()};
+ private static final Dialect[] DIALECTS = new Dialect[] {new H2(), new MySql(), new Oracle(), new PostgreSql(), new MsSql()};
public static Dialect find(final String dialectId, final String jdbcConnectionUrl) {
Dialect match = StringUtils.isNotBlank(dialectId) ? findById(dialectId) : findByJdbcUrl(jdbcConnectionUrl);
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.persistence.dialect;
+
+import org.apache.commons.lang.StringUtils;
+import org.hibernate.dialect.H2Dialect;
+
+/**
+ * @since 1.12
+ */
+public class H2 implements Dialect {
+
+ public static final String ID = "h2";
+
+ public String getId() {
+ return ID;
+ }
+
+ public String getActiveRecordDialectCode() {
+ return "h2";
+ }
+
+ public String getActiveRecordJdbcAdapter() {
+ return "jdbc";
+ }
+
+ public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
+ return H2Dialect.class;
+ }
+
+ public boolean matchesJdbcURL(String jdbcConnectionURL) {
+ return StringUtils.startsWithIgnoreCase(jdbcConnectionURL, "jdbc:h2:");
+ }
+
+ public String getDefaultDriverClassName() {
+ return "org.h2.Driver";
+ }
+
+ public String getConnectionInitStatement(String schema) {
+ return null;
+ }
+
+ public String getTrueSqlValue() {
+ return "true";
+ }
+
+ public String getFalseSqlValue() {
+ return "false";
+ }
+}
+++ /dev/null
--- All the rows inserted during Rails migrations. Rows inserted during server startup tasks (Java) are excluded : rules, profiles, metrics, ...
-
-INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (1, 1, null, 'admin');
-INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (2, 1, null, 'default-admin');
-INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (3, 2, null, 'default-user');
-INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (4, null, null, 'default-user');
-INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (5, 2, null, 'default-codeviewer');
-INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (6, null, null, 'default-codeviewer');
-ALTER TABLE GROUP_ROLES ALTER COLUMN ID RESTART WITH 7;
-
-INSERT INTO GROUPS(ID, NAME, DESCRIPTION, CREATED_AT, UPDATED_AT) VALUES (1, 'sonar-administrators', 'System administrators', '2011-09-26 22:27:51.0', '2011-09-26 22:27:51.0');
-INSERT INTO GROUPS(ID, NAME, DESCRIPTION, CREATED_AT, UPDATED_AT) VALUES (2, 'sonar-users', 'Any new users created will automatically join this group', '2011-09-26 22:27:51.0', '2011-09-26 22:27:51.0');
-ALTER TABLE GROUPS ALTER COLUMN ID RESTART WITH 3;
-
-INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 1);
-INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 2);
-
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('2');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('10');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('11');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('13');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('14');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('16');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('35');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('36');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('39');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('41');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('46');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('48');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('49');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('51');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('52');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('53');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('54');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('55');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('57');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('58');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('59');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('60');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('61');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('62');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('66');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('68');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('69');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('72');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('73');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('75');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('76');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('77');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('78');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('79');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('80');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('81');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('82');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('84');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('85');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('86');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('87');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('88');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('89');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('90');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('91');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('92');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('93');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('94');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('95');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('96');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('97');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('98');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('99');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('100');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('101');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('110');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('111');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('112');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('113');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('114');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('115');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('116');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('117');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('118');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('119');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('120');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('131');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('132');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('133');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('134');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('135');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('136');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('137');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('138');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('139');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('140');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('141');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('142');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('151');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('160');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('162');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('163');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('165');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('166');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('167');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('168');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('169');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('170');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('180');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('190');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('191');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('200');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('201');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('202');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('203');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('210');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('211');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('212');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('213');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('214');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('215');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('216');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('217');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('220');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('221');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('222');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('230');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('231');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('232');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('233');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('234');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('235');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('236');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('237');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('238');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('239');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('240');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('241');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('250');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('251');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('252');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('254');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('255');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('256');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('257');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('258');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('259');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('260');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('261');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('262');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('263');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('280');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('281');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('282');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('283');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('284');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('285');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('286');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('287');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('300');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('301');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('302');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('303');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('304');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('305');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('306');
-
-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;
--- /dev/null
+-- All the rows inserted during Rails migrations. Rows inserted during server startup tasks (Java) are excluded : rules, profiles, metrics, ...
+
+INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (1, 1, null, 'admin');
+INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (2, 1, null, 'default-admin');
+INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (3, 2, null, 'default-user');
+INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (4, null, null, 'default-user');
+INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (5, 2, null, 'default-codeviewer');
+INSERT INTO GROUP_ROLES(ID, GROUP_ID, RESOURCE_ID, ROLE) VALUES (6, null, null, 'default-codeviewer');
+ALTER TABLE GROUP_ROLES ALTER COLUMN ID RESTART WITH 7;
+
+INSERT INTO GROUPS(ID, NAME, DESCRIPTION, CREATED_AT, UPDATED_AT) VALUES (1, 'sonar-administrators', 'System administrators', '2011-09-26 22:27:51.0', '2011-09-26 22:27:51.0');
+INSERT INTO GROUPS(ID, NAME, DESCRIPTION, CREATED_AT, UPDATED_AT) VALUES (2, 'sonar-users', 'Any new users created will automatically join this group', '2011-09-26 22:27:51.0', '2011-09-26 22:27:51.0');
+ALTER TABLE GROUPS ALTER COLUMN ID RESTART WITH 3;
+
+INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 1);
+INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 2);
+
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('2');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('10');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('11');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('13');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('14');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('16');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('35');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('36');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('39');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('41');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('46');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('48');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('49');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('51');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('52');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('53');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('54');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('55');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('57');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('58');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('59');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('60');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('61');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('62');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('66');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('68');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('69');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('72');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('73');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('75');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('76');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('77');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('78');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('79');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('80');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('81');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('82');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('84');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('85');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('86');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('87');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('88');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('89');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('90');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('91');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('92');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('93');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('94');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('95');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('96');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('97');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('98');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('99');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('100');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('101');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('110');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('111');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('112');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('113');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('114');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('115');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('116');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('117');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('118');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('119');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('120');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('131');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('132');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('133');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('134');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('135');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('136');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('137');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('138');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('139');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('140');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('141');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('142');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('151');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('160');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('162');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('163');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('165');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('166');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('167');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('168');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('169');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('170');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('180');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('190');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('191');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('200');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('201');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('202');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('203');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('210');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('211');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('212');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('213');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('214');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('215');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('216');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('217');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('220');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('221');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('222');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('230');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('231');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('232');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('233');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('234');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('235');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('236');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('237');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('238');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('239');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('240');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('241');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('250');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('251');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('252');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('254');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('255');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('256');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('257');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('258');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('259');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('260');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('261');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('262');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('263');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('280');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('281');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('282');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('283');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('284');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('285');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('286');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('287');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('300');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('301');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('302');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('303');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('304');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('305');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('306');
+
+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;
+++ /dev/null
--- Structure of Sonar Database
-
--- Initially this file has been generated from existing Derby DB
--- Should be updated manually, during addition of new migrations
-
-CREATE TABLE "QUALITY_MODELS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(100)
-);
-
-CREATE TABLE "GROUPS_USERS" (
- "USER_ID" INTEGER,
- "GROUP_ID" INTEGER
-);
-
-CREATE TABLE "CHARACTERISTIC_EDGES" (
- "CHILD_ID" INTEGER,
- "PARENT_ID" INTEGER
-);
-
-CREATE TABLE "CRITERIA" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "FILTER_ID" INTEGER,
- "FAMILY" VARCHAR(100),
- "KEE" VARCHAR(100),
- "OPERATOR" VARCHAR(20),
- "VALUE" DECIMAL(30,20),
- "TEXT_VALUE" VARCHAR(256),
- "VARIATION" BOOLEAN
-);
-
-CREATE TABLE "DEPENDENCIES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "FROM_SNAPSHOT_ID" INTEGER,
- "FROM_RESOURCE_ID" INTEGER,
- "TO_SNAPSHOT_ID" INTEGER,
- "TO_RESOURCE_ID" INTEGER,
- "DEP_USAGE" VARCHAR(30),
- "DEP_WEIGHT" INTEGER,
- "PROJECT_SNAPSHOT_ID" INTEGER,
- "PARENT_DEPENDENCY_ID" BIGINT,
- "FROM_SCOPE" VARCHAR(3),
- "TO_SCOPE" VARCHAR(3)
-);
-
-CREATE TABLE "CHARACTERISTICS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "QUALITY_MODEL_ID" INTEGER,
- "KEE" VARCHAR(100),
- "NAME" VARCHAR(100),
- "RULE_ID" INTEGER,
- "DEPTH" INTEGER,
- "CHARACTERISTIC_ORDER" INTEGER,
- "DESCRIPTION" VARCHAR(4000),
- "ENABLED" BOOLEAN
-);
-
-CREATE TABLE "RULES_PARAMETERS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "RULE_ID" INTEGER NOT NULL,
- "NAME" VARCHAR(128) NOT NULL,
- "PARAM_TYPE" VARCHAR(512) NOT NULL,
- "DEFAULT_VALUE" VARCHAR(4000),
- "DESCRIPTION" VARCHAR(4000)
-);
-
-CREATE TABLE "RULES_PROFILES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(100) NOT NULL,
- "DEFAULT_PROFILE" BOOLEAN DEFAULT FALSE,
- "PROVIDED" BOOLEAN NOT NULL DEFAULT FALSE,
- "LANGUAGE" VARCHAR(16),
- "PARENT_NAME" VARCHAR(100),
- "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE,
- "VERSION" INTEGER DEFAULT 1,
- "USED_PROFILE" BOOLEAN DEFAULT FALSE
-);
-
-CREATE TABLE "WIDGETS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "DASHBOARD_ID" INTEGER NOT NULL,
- "WIDGET_KEY" VARCHAR(256) NOT NULL,
- "NAME" VARCHAR(256),
- "DESCRIPTION" VARCHAR(1000),
- "COLUMN_INDEX" INTEGER,
- "ROW_INDEX" INTEGER,
- "CONFIGURED" BOOLEAN,
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP,
- "RESOURCE_ID" INTEGER
-);
-
-CREATE TABLE "FILTER_COLUMNS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "FILTER_ID" INTEGER,
- "FAMILY" VARCHAR(100),
- "KEE" VARCHAR(100),
- "SORT_DIRECTION" VARCHAR(5),
- "ORDER_INDEX" INTEGER,
- "VARIATION" BOOLEAN
-);
-
-CREATE TABLE "MEASURE_DATA" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "MEASURE_ID" INTEGER,
- "SNAPSHOT_ID" INTEGER,
- "DATA" BLOB(2147483647)
-);
-
-CREATE TABLE "GROUPS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(40),
- "DESCRIPTION" VARCHAR(200),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-CREATE TABLE "ACTIVE_RULE_PARAM_CHANGES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "ACTIVE_RULE_CHANGE_ID" INTEGER NOT NULL,
- "RULES_PARAMETER_ID" INTEGER NOT NULL,
- "OLD_VALUE" VARCHAR(4000),
- "NEW_VALUE" VARCHAR(4000)
-);
-
-CREATE TABLE "SNAPSHOTS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "CREATED_AT" TIMESTAMP,
- "BUILD_DATE" TIMESTAMP,
- "PROJECT_ID" INTEGER NOT NULL,
- "PARENT_SNAPSHOT_ID" INTEGER,
- "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U',
- "PURGE_STATUS" INTEGER,
- "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE,
- "SCOPE" VARCHAR(3),
- "QUALIFIER" VARCHAR(10),
- "ROOT_SNAPSHOT_ID" INTEGER,
- "VERSION" VARCHAR(60),
- "PATH" VARCHAR(96),
- "DEPTH" INTEGER,
- "ROOT_PROJECT_ID" INTEGER,
- "PERIOD1_MODE" VARCHAR(100),
- "PERIOD1_PARAM" VARCHAR(100),
- "PERIOD1_DATE" TIMESTAMP,
- "PERIOD2_MODE" VARCHAR(100),
- "PERIOD2_PARAM" VARCHAR(100),
- "PERIOD2_DATE" TIMESTAMP,
- "PERIOD3_MODE" VARCHAR(100),
- "PERIOD3_PARAM" VARCHAR(100),
- "PERIOD3_DATE" TIMESTAMP,
- "PERIOD4_MODE" VARCHAR(100),
- "PERIOD4_PARAM" VARCHAR(100),
- "PERIOD4_DATE" TIMESTAMP,
- "PERIOD5_MODE" VARCHAR(100),
- "PERIOD5_PARAM" VARCHAR(100),
- "PERIOD5_DATE" TIMESTAMP
-);
-
-CREATE TABLE "SCHEMA_MIGRATIONS" (
-"VERSION" VARCHAR(256) NOT NULL
-);
-
-CREATE TABLE "GROUP_ROLES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "GROUP_ID" INTEGER,
- "RESOURCE_ID" INTEGER,
- "ROLE" VARCHAR(64) NOT NULL
-);
-
-CREATE TABLE "RULES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL,
- "PLUGIN_NAME" VARCHAR(255) NOT NULL,
- "DESCRIPTION" CLOB(2147483647),
- "PRIORITY" INTEGER,
- "ENABLED" BOOLEAN,
- "CARDINALITY" VARCHAR(10),
- "PARENT_ID" INTEGER,
- "PLUGIN_CONFIG_KEY" VARCHAR(500),
- "NAME" VARCHAR(200)
-);
-
-CREATE TABLE "WIDGET_PROPERTIES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "WIDGET_ID" INTEGER NOT NULL,
- "KEE" VARCHAR(100),
- "TEXT_VALUE" VARCHAR(4000)
-);
-
-CREATE TABLE "EVENTS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(400),
- "RESOURCE_ID" INTEGER,
- "SNAPSHOT_ID" INTEGER,
- "CATEGORY" VARCHAR(50),
- "EVENT_DATE" TIMESTAMP,
- "CREATED_AT" TIMESTAMP,
- "DESCRIPTION" VARCHAR(4000)
-);
-
-CREATE TABLE "ALERTS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "PROFILE_ID" INTEGER,
- "METRIC_ID" INTEGER,
- "OPERATOR" VARCHAR(3),
- "VALUE_ERROR" VARCHAR(64),
- "VALUE_WARNING" VARCHAR(64)
-);
-
-CREATE TABLE "PROPERTIES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "PROP_KEY" VARCHAR(512),
- "RESOURCE_ID" INTEGER,
- "TEXT_VALUE" CLOB(2147483647),
- "USER_ID" INTEGER
-);
-
-CREATE TABLE "PROJECT_LINKS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "PROJECT_ID" INTEGER NOT NULL,
- "LINK_TYPE" VARCHAR(20),
- "NAME" VARCHAR(128),
- "HREF" VARCHAR(2048) NOT NULL
-);
-
-CREATE TABLE "DUPLICATIONS_INDEX" (
- "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
- "SNAPSHOT_ID" INTEGER NOT NULL,
- "HASH" VARCHAR(50) NOT NULL,
- "INDEX_IN_FILE" INTEGER NOT NULL,
- "START_LINE" INTEGER NOT NULL,
- "END_LINE" INTEGER NOT NULL
-);
-
-CREATE TABLE "REVIEW_COMMENTS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP,
- "REVIEW_ID" INTEGER,
- "USER_ID" INTEGER,
- "REVIEW_TEXT" CLOB(2147483647)
-);
-
-CREATE TABLE "ACTIVE_RULE_CHANGES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "USER_NAME" VARCHAR(200) NOT NULL,
- "PROFILE_ID" INTEGER NOT NULL,
- "PROFILE_VERSION" INTEGER NOT NULL,
- "RULE_ID" INTEGER NOT NULL,
- "CHANGE_DATE" TIMESTAMP NOT NULL,
- "ENABLED" BOOLEAN,
- "OLD_SEVERITY" INTEGER,
- "NEW_SEVERITY" INTEGER
-);
-
-CREATE TABLE "PROJECT_MEASURES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "VALUE" DECIMAL(30,20),
- "METRIC_ID" INTEGER NOT NULL,
- "SNAPSHOT_ID" INTEGER,
- "RULE_ID" INTEGER,
- "RULES_CATEGORY_ID" INTEGER,
- "TEXT_VALUE" VARCHAR(96),
- "TENDENCY" INTEGER,
- "MEASURE_DATE" TIMESTAMP,
- "PROJECT_ID" INTEGER,
- "ALERT_STATUS" VARCHAR(5),
- "ALERT_TEXT" VARCHAR(4000),
- "URL" VARCHAR(2000),
- "DESCRIPTION" VARCHAR(4000),
- "RULE_PRIORITY" INTEGER,
- "CHARACTERISTIC_ID" INTEGER,
- "PERSON_ID" INTEGER,
- "VARIATION_VALUE_1" DECIMAL(30,20),
- "VARIATION_VALUE_2" DECIMAL(30,20),
- "VARIATION_VALUE_3" DECIMAL(30,20),
- "VARIATION_VALUE_4" DECIMAL(30,20),
- "VARIATION_VALUE_5" DECIMAL(30,20)
-);
-
-CREATE TABLE "SNAPSHOT_SOURCES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "SNAPSHOT_ID" INTEGER NOT NULL,
- "DATA" CLOB(2147483647)
-);
-
-CREATE TABLE "PROJECTS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(256),
- "DESCRIPTION" VARCHAR(2000),
- "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE,
- "SCOPE" VARCHAR(3),
- "QUALIFIER" VARCHAR(10),
- "KEE" VARCHAR(400),
- "ROOT_ID" INTEGER,
- "PROFILE_ID" INTEGER,
- "LANGUAGE" VARCHAR(5),
- "COPY_RESOURCE_ID" INTEGER,
- "LONG_NAME" VARCHAR(256),
- "PERSON_ID" INTEGER
-);
-
-CREATE TABLE "REVIEWS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP,
- "USER_ID" INTEGER,
- "ASSIGNEE_ID" INTEGER,
- "TITLE" VARCHAR(500),
- "STATUS" VARCHAR(10),
- "SEVERITY" VARCHAR(10),
- "RULE_FAILURE_PERMANENT_ID" INTEGER,
- "PROJECT_ID" INTEGER,
- "RESOURCE_ID" INTEGER,
- "RESOURCE_LINE" INTEGER,
- "RESOLUTION" VARCHAR(200),
- "RULE_ID" INTEGER,
- "MANUAL_VIOLATION" BOOLEAN NOT NULL,
- "MANUAL_SEVERITY" BOOLEAN NOT NULL,
- "DATA" VARCHAR(4000)
-);
-
-CREATE TABLE "MANUAL_MEASURES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "METRIC_ID" INTEGER NOT NULL,
- "RESOURCE_ID" INTEGER,
- "VALUE" DECIMAL(30,20),
- "TEXT_VALUE" VARCHAR(4000),
- "USER_LOGIN" VARCHAR(40),
- "DESCRIPTION" VARCHAR(4000),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-CREATE TABLE "ACTIVE_RULES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "PROFILE_ID" INTEGER NOT NULL,
- "RULE_ID" INTEGER NOT NULL,
- "FAILURE_LEVEL" INTEGER NOT NULL,
- "INHERITANCE" VARCHAR(10)
-);
-
-CREATE TABLE "NOTIFICATIONS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "CREATED_AT" TIMESTAMP,
- "DATA" BLOB(2147483647)
-);
-
-CREATE TABLE "USER_ROLES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "USER_ID" INTEGER,
- "RESOURCE_ID" INTEGER,
- "ROLE" VARCHAR(64) NOT NULL
-);
-
-CREATE TABLE "ACTIVE_DASHBOARDS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "DASHBOARD_ID" INTEGER NOT NULL,
- "USER_ID" INTEGER,
- "ORDER_INDEX" INTEGER
-);
-
-CREATE TABLE "ACTIVE_RULE_PARAMETERS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "ACTIVE_RULE_ID" INTEGER NOT NULL,
- "RULES_PARAMETER_ID" INTEGER NOT NULL,
- "VALUE" VARCHAR(4000)
-);
-
-CREATE TABLE "CHARACTERISTIC_PROPERTIES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "CHARACTERISTIC_ID" INTEGER,
- "KEE" VARCHAR(100),
- "VALUE" DECIMAL(30,20),
- "TEXT_VALUE" VARCHAR(4000)
-);
-
-CREATE TABLE "USERS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "LOGIN" VARCHAR(40),
- "NAME" VARCHAR(200),
- "EMAIL" VARCHAR(100),
- "CRYPTED_PASSWORD" VARCHAR(40),
- "SALT" VARCHAR(40),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP,
- "REMEMBER_TOKEN" VARCHAR(500),
- "REMEMBER_TOKEN_EXPIRES_AT" TIMESTAMP,
- "ACTIVE" BOOLEAN DEFAULT TRUE
-);
-
-CREATE TABLE "FILTERS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(100),
- "KEE" VARCHAR(100),
- "USER_ID" INTEGER,
- "SHARED" BOOLEAN,
- "FAVOURITES" BOOLEAN,
- "RESOURCE_ID" INTEGER,
- "DEFAULT_VIEW" VARCHAR(20),
- "PAGE_SIZE" INTEGER,
- "PERIOD_INDEX" INTEGER
-);
-
-CREATE TABLE "DASHBOARDS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "USER_ID" INTEGER,
- "NAME" VARCHAR(256),
- "DESCRIPTION" VARCHAR(1000),
- "COLUMN_LAYOUT" VARCHAR(20),
- "SHARED" BOOLEAN,
- "IS_GLOBAL" BOOLEAN,
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-CREATE TABLE "RULE_FAILURES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "SNAPSHOT_ID" INTEGER NOT NULL,
- "RULE_ID" INTEGER NOT NULL,
- "FAILURE_LEVEL" INTEGER NOT NULL,
- "MESSAGE" VARCHAR(4000),
- "LINE" INTEGER,
- "COST" DECIMAL(30,20),
- "CREATED_AT" TIMESTAMP,
- "CHECKSUM" VARCHAR(1000),
- "PERMANENT_ID" INTEGER,
- "SWITCHED_OFF" BOOLEAN,
- "PERSON_ID" INTEGER
-);
-
-CREATE TABLE "METRICS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(64) NOT NULL,
- "DESCRIPTION" VARCHAR(255),
- "DIRECTION" INTEGER NOT NULL DEFAULT 0,
- "DOMAIN" VARCHAR(64),
- "SHORT_NAME" VARCHAR(64),
- "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE,
- "VAL_TYPE" VARCHAR(8),
- "USER_MANAGED" BOOLEAN DEFAULT FALSE,
- "ENABLED" BOOLEAN DEFAULT TRUE,
- "ORIGIN" VARCHAR(3),
- "WORST_VALUE" DECIMAL(30,20),
- "BEST_VALUE" DECIMAL(30,20),
- "OPTIMIZED_BEST_VALUE" BOOLEAN,
- "HIDDEN" BOOLEAN,
- "DELETE_HISTORICAL_DATA" BOOLEAN
-);
-
-CREATE TABLE "LOADED_TEMPLATES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "KEE" VARCHAR(200),
- "TEMPLATE_TYPE" VARCHAR(15)
-);
-
-CREATE TABLE "RESOURCE_INDEX" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "KEE" VARCHAR(400) NOT NULL,
- "POSITION" INTEGER NOT NULL,
- "NAME_SIZE" INTEGER NOT NULL,
- "RESOURCE_ID" INTEGER NOT NULL,
- "ROOT_PROJECT_ID" INTEGER NOT NULL,
- "QUALIFIER" VARCHAR(10) NOT NULL
-);
-
-CREATE TABLE "ACTION_PLANS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "USER_ID" INTEGER,
- "NAME" VARCHAR(200),
- "DESCRIPTION" VARCHAR(1000),
- "DEADLINE" TIMESTAMP,
- "USER_LOGIN" VARCHAR(40),
- "PROJECT_ID" INTEGER,
- "STATUS" VARCHAR(10),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-CREATE TABLE "ACTION_PLANS_REVIEWS" (
- "ACTION_PLAN_ID" INTEGER,
- "REVIEW_ID" INTEGER
-);
-
-CREATE TABLE "ACTIVE_RULE_NOTES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "ACTIVE_RULE_ID" INTEGER,
- "USER_LOGIN" VARCHAR(40),
- "DATA" BLOB(2147483647),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-CREATE TABLE "RULE_NOTES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "RULE_ID" INTEGER,
- "USER_LOGIN" VARCHAR(40),
- "DATA" BLOB(2147483647),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-CREATE TABLE "AUTHORS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "PERSON_ID" INTEGER,
- "LOGIN" VARCHAR(100),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
-
--- ----------------------------------------------
--- DDL Statements for indexes
--- ----------------------------------------------
-
-CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID");
-
-CREATE INDEX "GROUP_ROLES_GROUP" ON "GROUP_ROLES" ("GROUP_ID");
-
-CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID");
-
-CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID");
-
-CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX" ("HASH");
-
-CREATE INDEX "DUPLICATIONS_INDEX_SID" ON "DUPLICATIONS_INDEX" ("SNAPSHOT_ID");
-
-CREATE INDEX "DUPLICATIONS_INDEX_PSID" ON "DUPLICATIONS_INDEX" ("PROJECT_SNAPSHOT_ID");
-
-CREATE INDEX "SNAP_SOURCES_SNAPSHOT_ID" ON "SNAPSHOT_SOURCES" ("SNAPSHOT_ID");
-
-CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID");
-
-CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID");
-
-CREATE INDEX "DEPS_TO_SID" ON "DEPENDENCIES" ("TO_SNAPSHOT_ID");
-
-CREATE INDEX "DEPS_FROM_SID" ON "DEPENDENCIES" ("FROM_SNAPSHOT_ID");
-
-CREATE INDEX "DEPS_PRJ_SID" ON "DEPENDENCIES" ("PROJECT_SNAPSHOT_ID");
-
-CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID");
-
-CREATE INDEX "ACTIVE_RULE_CHANGES_PID" ON "ACTIVE_RULE_CHANGES" ("PROFILE_ID");
-
-CREATE INDEX "CHARACTERISTIC_PROPERTIES_CID" ON "CHARACTERISTIC_PROPERTIES" ("CHARACTERISTIC_ID");
-
-CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME");
-
-CREATE INDEX "ACTIVE_RULE_PARAM_CHANGES_CID" ON "ACTIVE_RULE_PARAM_CHANGES" ("ACTIVE_RULE_CHANGE_ID");
-
-CREATE INDEX "M_DATA_SID" ON "MEASURE_DATA" ("SNAPSHOT_ID");
-
-CREATE INDEX "MEASURE_DATA_MEASURE_ID" ON "MEASURE_DATA" ("MEASURE_ID");
-
-CREATE INDEX "RF_PERMANENT_ID" ON "RULE_FAILURES" ("PERMANENT_ID");
-
-CREATE INDEX "RULE_FAILURE_RULE_ID" ON "RULE_FAILURES" ("RULE_ID");
-
-CREATE INDEX "RULE_FAILURE_SNAPSHOT_ID" ON "RULE_FAILURES" ("SNAPSHOT_ID");
-
-CREATE INDEX "EVENTS_SNAPSHOT_ID" ON "EVENTS" ("SNAPSHOT_ID");
-
-CREATE INDEX "EVENTS_RESOURCE_ID" ON "EVENTS" ("RESOURCE_ID");
-
-CREATE INDEX "WIDGETS_WIDGETKEY" ON "WIDGETS" ("WIDGET_KEY");
-
-CREATE INDEX "WIDGETS_DASHBOARDS" ON "WIDGETS" ("DASHBOARD_ID");
-
-CREATE INDEX "SNAPSHOTS_QUALIFIER" ON "SNAPSHOTS" ("QUALIFIER");
-
-CREATE INDEX "SNAPSHOTS_ROOT" ON "SNAPSHOTS" ("ROOT_SNAPSHOT_ID");
-
-CREATE INDEX "SNAPSHOTS_PARENT" ON "SNAPSHOTS" ("PARENT_SNAPSHOT_ID");
-
-CREATE INDEX "SNAPSHOT_PROJECT_ID" ON "SNAPSHOTS" ("PROJECT_ID");
-
-CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS" ("RULE_ID");
-
-CREATE INDEX "ACTIVE_DASHBOARDS_DASHBOARDID" ON "ACTIVE_DASHBOARDS" ("DASHBOARD_ID");
-
-CREATE INDEX "ACTIVE_DASHBOARDS_USERID" ON "ACTIVE_DASHBOARDS" ("USER_ID");
-
-CREATE UNIQUE INDEX "UNIQUE_SCHEMA_MIGRATIONS" ON "SCHEMA_MIGRATIONS" ("VERSION");
-
-CREATE INDEX "WIDGET_PROPERTIES_WIDGETS" ON "WIDGET_PROPERTIES" ("WIDGET_ID");
-
-CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY");
-
-CREATE INDEX "MANUAL_MEASURES_RESOURCE_ID" ON "MANUAL_MEASURES" ("RESOURCE_ID");
-
-CREATE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE");
-
-CREATE INDEX "RESOURCE_INDEX_KEE" ON "RESOURCE_INDEX" ("KEE");
-
-CREATE INDEX "RESOURCE_INDEX_RID" ON "RESOURCE_INDEX" ("RESOURCE_ID");
-
-CREATE INDEX "INDEX_ACTION_PLANS_ON_PROJET_ID" ON "ACTION_PLANS" ("PROJECT_ID");
-
-CREATE INDEX "INDEX_ACTION_PLANS_REVIEWS_ON_ACTION_PLAN_ID" ON "ACTION_PLANS_REVIEWS" ("ACTION_PLAN_ID");
-
-CREATE INDEX "INDEX_ACTION_PLANS_REVIEWS_ON_REVIEW_ID" ON "ACTION_PLANS_REVIEWS" ("REVIEW_ID");
-
-CREATE INDEX "INDEX_ACTIVE_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_NOTES" ("ACTIVE_RULE_ID");
-
-CREATE INDEX "INDEX_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "RULE_NOTES" ("RULE_ID");
-
-CREATE INDEX "REVIEWS_RID" ON "REVIEWS" ("RESOURCE_ID");
-
-
--- ----------------------------------------------
--- DDL Statements for keys
--- ----------------------------------------------
-
--- primary/unique
-ALTER TABLE "GROUP_ROLES" ADD CONSTRAINT "SQL110927104437910" PRIMARY KEY ("ID");
-
-ALTER TABLE "REVIEWS" ADD CONSTRAINT "SQL110927104440700" PRIMARY KEY ("ID");
-
-ALTER TABLE "RULES" ADD CONSTRAINT "SQL110927104437080" PRIMARY KEY ("ID");
-
-ALTER TABLE "USER_ROLES" ADD CONSTRAINT "SQL110927104437940" PRIMARY KEY ("ID");
-
-ALTER TABLE "SNAPSHOT_SOURCES" ADD CONSTRAINT "SQL110927104437590" PRIMARY KEY ("ID");
-
-ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "SQL110927104441030" PRIMARY KEY ("ID");
-
-ALTER TABLE "DEPENDENCIES" ADD CONSTRAINT "SQL110927104438330" PRIMARY KEY ("ID");
-
-ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "SQL110927104437040" PRIMARY KEY ("ID");
-
-ALTER TABLE "ACTIVE_RULE_CHANGES" ADD CONSTRAINT "SQL110927104440770" PRIMARY KEY ("ID");
-
-ALTER TABLE "CHARACTERISTIC_PROPERTIES" ADD CONSTRAINT "SQL110927104439660" PRIMARY KEY ("ID");
-
-ALTER TABLE "QUALITY_MODELS" ADD CONSTRAINT "SQL110927104439440" PRIMARY KEY ("ID");
-
-ALTER TABLE "USERS" ADD CONSTRAINT "SQL110927104437310" PRIMARY KEY ("ID");
-
-ALTER TABLE "CRITERIA" ADD CONSTRAINT "SQL110927104438720" PRIMARY KEY ("ID");
-
-ALTER TABLE "METRICS" ADD CONSTRAINT "SQL110927104436990" PRIMARY KEY ("ID");
-
-ALTER TABLE "ACTIVE_RULE_PARAM_CHANGES" ADD CONSTRAINT "SQL110927104440790" PRIMARY KEY ("ID");
-
-ALTER TABLE "MEASURE_DATA" ADD CONSTRAINT "SQL110927104437810" PRIMARY KEY ("ID");
-
-ALTER TABLE "RULE_FAILURES" ADD CONSTRAINT "SQL110927104437100" PRIMARY KEY ("ID");
-
-ALTER TABLE "EVENTS" ADD CONSTRAINT "SQL110927104437690" PRIMARY KEY ("ID");
-
-ALTER TABLE "WIDGETS" ADD CONSTRAINT "SQL110927104439750" PRIMARY KEY ("ID");
-
-ALTER TABLE "SNAPSHOTS" ADD CONSTRAINT "SQL110927104436960" PRIMARY KEY ("ID");
-
-ALTER TABLE "ACTIVE_RULES" ADD CONSTRAINT "SQL110927104437550" PRIMARY KEY ("ID");
-
-ALTER TABLE "CHARACTERISTICS" ADD CONSTRAINT "SQL110927104439450" PRIMARY KEY ("ID");
-
-ALTER TABLE "RULES_PARAMETERS" ADD CONSTRAINT "SQL110927104437130" PRIMARY KEY ("ID");
-
-ALTER TABLE "ACTIVE_DASHBOARDS" ADD CONSTRAINT "SQL110927104439710" PRIMARY KEY ("ID");
-
-ALTER TABLE "FILTER_COLUMNS" ADD CONSTRAINT "SQL110927104438710" PRIMARY KEY ("ID");
-
-ALTER TABLE "REVIEW_COMMENTS" ADD CONSTRAINT "SQL110927104440710" PRIMARY KEY ("ID");
-
-ALTER TABLE "WIDGET_PROPERTIES" ADD CONSTRAINT "SQL110927104439770" PRIMARY KEY ("ID");
-
-ALTER TABLE "PROPERTIES" ADD CONSTRAINT "SQL110927104437750" PRIMARY KEY ("ID");
-
-ALTER TABLE "DASHBOARDS" ADD CONSTRAINT "SQL110927104439740" PRIMARY KEY ("ID");
-
-ALTER TABLE "GROUPS" ADD CONSTRAINT "SQL110927104437850" PRIMARY KEY ("ID");
-
-ALTER TABLE "PROJECT_LINKS" ADD CONSTRAINT "SQL110927104437150" PRIMARY KEY ("ID");
-
-ALTER TABLE "FILTERS" ADD CONSTRAINT "SQL110927104438690" PRIMARY KEY ("ID");
-
-ALTER TABLE "MANUAL_MEASURES" ADD CONSTRAINT "SQL110927104440930" PRIMARY KEY ("ID");
-
-ALTER TABLE "ALERTS" ADD CONSTRAINT "SQL110927104437730" PRIMARY KEY ("ID");
-
-ALTER TABLE "PROJECTS" ADD CONSTRAINT "SQL110927104436930" PRIMARY KEY ("ID");
-
-ALTER TABLE "RULES_PROFILES" ADD CONSTRAINT "SQL110927104437540" PRIMARY KEY ("ID");
-
-ALTER TABLE "ACTIVE_RULE_PARAMETERS" ADD CONSTRAINT "SQL110927104437560" PRIMARY KEY ("ID");
-
-ALTER TABLE "LOADED_TEMPLATES" ADD CONSTRAINT "SQL110927104437650" PRIMARY KEY ("ID");
-
-ALTER TABLE "ACTION_PLANS" ADD CONSTRAINT "SQL110927104447650" PRIMARY KEY ("ID");
-
-ALTER TABLE "ACTIVE_RULE_NOTES" ADD CONSTRAINT "SQL110927104847650" PRIMARY KEY ("ID");
-
-ALTER TABLE "RULE_NOTES" ADD PRIMARY KEY ("ID");
-
-ALTER TABLE "AUTHORS" ADD PRIMARY KEY ("ID");
-
-ALTER TABLE "RESOURCE_INDEX" ADD PRIMARY KEY ("ID");
--- /dev/null
+-- Structure of Sonar Database
+
+-- Initially this file has been generated from existing H2 DB
+-- Should be updated manually, during addition of new migrations
+
+CREATE TABLE "QUALITY_MODELS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100)
+);
+
+CREATE TABLE "GROUPS_USERS" (
+ "USER_ID" INTEGER,
+ "GROUP_ID" INTEGER
+);
+
+CREATE TABLE "CHARACTERISTIC_EDGES" (
+ "CHILD_ID" INTEGER,
+ "PARENT_ID" INTEGER
+);
+
+CREATE TABLE "CRITERIA" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "FILTER_ID" INTEGER,
+ "FAMILY" VARCHAR(100),
+ "KEE" VARCHAR(100),
+ "OPERATOR" VARCHAR(20),
+ "VALUE" DOUBLE,
+ "TEXT_VALUE" VARCHAR(256),
+ "VARIATION" BOOLEAN
+);
+
+CREATE TABLE "DEPENDENCIES" (
+ "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "FROM_SNAPSHOT_ID" INTEGER,
+ "FROM_RESOURCE_ID" INTEGER,
+ "TO_SNAPSHOT_ID" INTEGER,
+ "TO_RESOURCE_ID" INTEGER,
+ "DEP_USAGE" VARCHAR(30),
+ "DEP_WEIGHT" INTEGER,
+ "PROJECT_SNAPSHOT_ID" INTEGER,
+ "PARENT_DEPENDENCY_ID" BIGINT,
+ "FROM_SCOPE" VARCHAR(3),
+ "TO_SCOPE" VARCHAR(3)
+);
+
+CREATE TABLE "CHARACTERISTICS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "QUALITY_MODEL_ID" INTEGER,
+ "KEE" VARCHAR(100),
+ "NAME" VARCHAR(100),
+ "RULE_ID" INTEGER,
+ "DEPTH" INTEGER,
+ "CHARACTERISTIC_ORDER" INTEGER,
+ "DESCRIPTION" VARCHAR(4000),
+ "ENABLED" BOOLEAN
+);
+
+CREATE TABLE "RULES_PARAMETERS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "RULE_ID" INTEGER NOT NULL,
+ "NAME" VARCHAR(128) NOT NULL,
+ "PARAM_TYPE" VARCHAR(512) NOT NULL,
+ "DEFAULT_VALUE" VARCHAR(4000),
+ "DESCRIPTION" VARCHAR(4000)
+);
+
+CREATE TABLE "RULES_PROFILES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100) NOT NULL,
+ "DEFAULT_PROFILE" BOOLEAN DEFAULT FALSE,
+ "PROVIDED" BOOLEAN NOT NULL DEFAULT FALSE,
+ "LANGUAGE" VARCHAR(16),
+ "PARENT_NAME" VARCHAR(100),
+ "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE,
+ "VERSION" INTEGER DEFAULT 1,
+ "USED_PROFILE" BOOLEAN DEFAULT FALSE
+);
+
+CREATE TABLE "WIDGETS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "DASHBOARD_ID" INTEGER NOT NULL,
+ "WIDGET_KEY" VARCHAR(256) NOT NULL,
+ "NAME" VARCHAR(256),
+ "DESCRIPTION" VARCHAR(1000),
+ "COLUMN_INDEX" INTEGER,
+ "ROW_INDEX" INTEGER,
+ "CONFIGURED" BOOLEAN,
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "RESOURCE_ID" INTEGER
+);
+
+CREATE TABLE "FILTER_COLUMNS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "FILTER_ID" INTEGER,
+ "FAMILY" VARCHAR(100),
+ "KEE" VARCHAR(100),
+ "SORT_DIRECTION" VARCHAR(5),
+ "ORDER_INDEX" INTEGER,
+ "VARIATION" BOOLEAN
+);
+
+CREATE TABLE "MEASURE_DATA" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "MEASURE_ID" BIGINT,
+ "SNAPSHOT_ID" INTEGER,
+ "DATA" BINARY(167772150)
+);
+
+CREATE TABLE "GROUPS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(40),
+ "DESCRIPTION" VARCHAR(200),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP
+);
+
+CREATE TABLE "ACTIVE_RULE_PARAM_CHANGES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "ACTIVE_RULE_CHANGE_ID" INTEGER NOT NULL,
+ "RULES_PARAMETER_ID" INTEGER NOT NULL,
+ "OLD_VALUE" VARCHAR(4000),
+ "NEW_VALUE" VARCHAR(4000)
+);
+
+CREATE TABLE "SNAPSHOTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "CREATED_AT" TIMESTAMP,
+ "BUILD_DATE" TIMESTAMP,
+ "PROJECT_ID" INTEGER NOT NULL,
+ "PARENT_SNAPSHOT_ID" INTEGER,
+ "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U',
+ "PURGE_STATUS" INTEGER,
+ "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE,
+ "SCOPE" VARCHAR(3),
+ "QUALIFIER" VARCHAR(10),
+ "ROOT_SNAPSHOT_ID" INTEGER,
+ "VERSION" VARCHAR(60),
+ "PATH" VARCHAR(96),
+ "DEPTH" INTEGER,
+ "ROOT_PROJECT_ID" INTEGER,
+ "PERIOD1_MODE" VARCHAR(100),
+ "PERIOD1_PARAM" VARCHAR(100),
+ "PERIOD1_DATE" TIMESTAMP,
+ "PERIOD2_MODE" VARCHAR(100),
+ "PERIOD2_PARAM" VARCHAR(100),
+ "PERIOD2_DATE" TIMESTAMP,
+ "PERIOD3_MODE" VARCHAR(100),
+ "PERIOD3_PARAM" VARCHAR(100),
+ "PERIOD3_DATE" TIMESTAMP,
+ "PERIOD4_MODE" VARCHAR(100),
+ "PERIOD4_PARAM" VARCHAR(100),
+ "PERIOD4_DATE" TIMESTAMP,
+ "PERIOD5_MODE" VARCHAR(100),
+ "PERIOD5_PARAM" VARCHAR(100),
+ "PERIOD5_DATE" TIMESTAMP
+);
+
+CREATE TABLE "SCHEMA_MIGRATIONS" (
+"VERSION" VARCHAR(256) NOT NULL
+);
+
+CREATE TABLE "GROUP_ROLES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "GROUP_ID" INTEGER,
+ "RESOURCE_ID" INTEGER,
+ "ROLE" VARCHAR(64) NOT NULL
+);
+
+CREATE TABLE "RULES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL,
+ "PLUGIN_NAME" VARCHAR(255) NOT NULL,
+ "DESCRIPTION" VARCHAR(16777215),
+ "PRIORITY" INTEGER,
+ "ENABLED" BOOLEAN,
+ "CARDINALITY" VARCHAR(10),
+ "PARENT_ID" INTEGER,
+ "PLUGIN_CONFIG_KEY" VARCHAR(500),
+ "NAME" VARCHAR(200)
+);
+
+CREATE TABLE "WIDGET_PROPERTIES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "WIDGET_ID" INTEGER NOT NULL,
+ "KEE" VARCHAR(100),
+ "TEXT_VALUE" VARCHAR(4000)
+);
+
+CREATE TABLE "EVENTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(400),
+ "RESOURCE_ID" INTEGER,
+ "SNAPSHOT_ID" INTEGER,
+ "CATEGORY" VARCHAR(50),
+ "EVENT_DATE" TIMESTAMP,
+ "CREATED_AT" TIMESTAMP,
+ "DESCRIPTION" VARCHAR(4000)
+);
+
+CREATE TABLE "ALERTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PROFILE_ID" INTEGER,
+ "METRIC_ID" INTEGER,
+ "OPERATOR" VARCHAR(3),
+ "VALUE_ERROR" VARCHAR(64),
+ "VALUE_WARNING" VARCHAR(64)
+);
+
+CREATE TABLE "PROPERTIES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PROP_KEY" VARCHAR(512),
+ "RESOURCE_ID" INTEGER,
+ "TEXT_VALUE" CLOB(2147483647),
+ "USER_ID" INTEGER
+);
+
+CREATE TABLE "PROJECT_LINKS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PROJECT_ID" INTEGER NOT NULL,
+ "LINK_TYPE" VARCHAR(20),
+ "NAME" VARCHAR(128),
+ "HREF" VARCHAR(2048) NOT NULL
+);
+
+CREATE TABLE "DUPLICATIONS_INDEX" (
+ "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL,
+ "SNAPSHOT_ID" INTEGER NOT NULL,
+ "HASH" VARCHAR(50) NOT NULL,
+ "INDEX_IN_FILE" INTEGER NOT NULL,
+ "START_LINE" INTEGER NOT NULL,
+ "END_LINE" INTEGER NOT NULL
+);
+
+CREATE TABLE "REVIEW_COMMENTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "REVIEW_ID" INTEGER,
+ "USER_ID" INTEGER,
+ "REVIEW_TEXT" VARCHAR(16777215)
+);
+
+CREATE TABLE "ACTIVE_RULE_CHANGES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "USER_NAME" VARCHAR(200) NOT NULL,
+ "PROFILE_ID" INTEGER NOT NULL,
+ "PROFILE_VERSION" INTEGER NOT NULL,
+ "RULE_ID" INTEGER NOT NULL,
+ "CHANGE_DATE" TIMESTAMP NOT NULL,
+ "ENABLED" BOOLEAN,
+ "OLD_SEVERITY" INTEGER,
+ "NEW_SEVERITY" INTEGER
+);
+
+CREATE TABLE "PROJECT_MEASURES" (
+ "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "VALUE" DOUBLE,
+ "METRIC_ID" INTEGER NOT NULL,
+ "SNAPSHOT_ID" INTEGER,
+ "RULE_ID" INTEGER,
+ "RULES_CATEGORY_ID" INTEGER,
+ "TEXT_VALUE" VARCHAR(96),
+ "TENDENCY" INTEGER,
+ "MEASURE_DATE" TIMESTAMP,
+ "PROJECT_ID" INTEGER,
+ "ALERT_STATUS" VARCHAR(5),
+ "ALERT_TEXT" VARCHAR(4000),
+ "URL" VARCHAR(2000),
+ "DESCRIPTION" VARCHAR(4000),
+ "RULE_PRIORITY" INTEGER,
+ "CHARACTERISTIC_ID" INTEGER,
+ "PERSON_ID" INTEGER,
+ "VARIATION_VALUE_1" DOUBLE,
+ "VARIATION_VALUE_2" DOUBLE,
+ "VARIATION_VALUE_3" DOUBLE,
+ "VARIATION_VALUE_4" DOUBLE,
+ "VARIATION_VALUE_5" DOUBLE
+);
+
+CREATE TABLE "SNAPSHOT_SOURCES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "SNAPSHOT_ID" INTEGER NOT NULL,
+ "DATA" CLOB(2147483647)
+);
+
+CREATE TABLE "PROJECTS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(256),
+ "DESCRIPTION" VARCHAR(2000),
+ "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE,
+ "SCOPE" VARCHAR(3),
+ "QUALIFIER" VARCHAR(10),
+ "KEE" VARCHAR(400),
+ "ROOT_ID" INTEGER,
+ "PROFILE_ID" INTEGER,
+ "LANGUAGE" VARCHAR(5),
+ "COPY_RESOURCE_ID" INTEGER,
+ "LONG_NAME" VARCHAR(256),
+ "PERSON_ID" INTEGER
+);
+
+CREATE TABLE "REVIEWS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "USER_ID" INTEGER,
+ "ASSIGNEE_ID" INTEGER,
+ "TITLE" VARCHAR(500),
+ "STATUS" VARCHAR(10),
+ "SEVERITY" VARCHAR(10),
+ "RULE_FAILURE_PERMANENT_ID" INTEGER,
+ "PROJECT_ID" INTEGER,
+ "RESOURCE_ID" INTEGER,
+ "RESOURCE_LINE" INTEGER,
+ "RESOLUTION" VARCHAR(200),
+ "RULE_ID" INTEGER,
+ "MANUAL_VIOLATION" BOOLEAN NOT NULL,
+ "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+ "DATA" VARCHAR(4000)
+);
+
+CREATE TABLE "MANUAL_MEASURES" (
+ "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "METRIC_ID" INTEGER NOT NULL,
+ "RESOURCE_ID" INTEGER,
+ "VALUE" DOUBLE,
+ "TEXT_VALUE" VARCHAR(4000),
+ "USER_LOGIN" VARCHAR(40),
+ "DESCRIPTION" VARCHAR(4000),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP
+);
+
+CREATE TABLE "ACTIVE_RULES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PROFILE_ID" INTEGER NOT NULL,
+ "RULE_ID" INTEGER NOT NULL,
+ "FAILURE_LEVEL" INTEGER NOT NULL,
+ "INHERITANCE" VARCHAR(10)
+);
+
+CREATE TABLE "NOTIFICATIONS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "CREATED_AT" TIMESTAMP,
+ "DATA" BINARY(167772150)
+);
+
+CREATE TABLE "USER_ROLES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "USER_ID" INTEGER,
+ "RESOURCE_ID" INTEGER,
+ "ROLE" VARCHAR(64) NOT NULL
+);
+
+CREATE TABLE "ACTIVE_DASHBOARDS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "DASHBOARD_ID" INTEGER NOT NULL,
+ "USER_ID" INTEGER,
+ "ORDER_INDEX" INTEGER
+);
+
+CREATE TABLE "ACTIVE_RULE_PARAMETERS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "ACTIVE_RULE_ID" INTEGER NOT NULL,
+ "RULES_PARAMETER_ID" INTEGER NOT NULL,
+ "VALUE" VARCHAR(4000)
+);
+
+CREATE TABLE "CHARACTERISTIC_PROPERTIES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "CHARACTERISTIC_ID" INTEGER,
+ "KEE" VARCHAR(100),
+ "VALUE" DOUBLE,
+ "TEXT_VALUE" VARCHAR(4000)
+);
+
+CREATE TABLE "USERS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "LOGIN" VARCHAR(40),
+ "NAME" VARCHAR(200),
+ "EMAIL" VARCHAR(100),
+ "CRYPTED_PASSWORD" VARCHAR(40),
+ "SALT" VARCHAR(40),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "REMEMBER_TOKEN" VARCHAR(500),
+ "REMEMBER_TOKEN_EXPIRES_AT" TIMESTAMP,
+ "ACTIVE" BOOLEAN DEFAULT TRUE
+);
+
+CREATE TABLE "FILTERS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(100),
+ "KEE" VARCHAR(100),
+ "USER_ID" INTEGER,
+ "SHARED" BOOLEAN,
+ "FAVOURITES" BOOLEAN,
+ "RESOURCE_ID" INTEGER,
+ "DEFAULT_VIEW" VARCHAR(20),
+ "PAGE_SIZE" INTEGER,
+ "PERIOD_INDEX" INTEGER
+);
+
+CREATE TABLE "DASHBOARDS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "USER_ID" INTEGER,
+ "NAME" VARCHAR(256),
+ "DESCRIPTION" VARCHAR(1000),
+ "COLUMN_LAYOUT" VARCHAR(20),
+ "SHARED" BOOLEAN,
+ "IS_GLOBAL" BOOLEAN,
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP
+);
+
+CREATE TABLE "RULE_FAILURES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "SNAPSHOT_ID" INTEGER NOT NULL,
+ "RULE_ID" INTEGER NOT NULL,
+ "FAILURE_LEVEL" INTEGER NOT NULL,
+ "MESSAGE" VARCHAR(4000),
+ "LINE" INTEGER,
+ "COST" DOUBLE,
+ "CREATED_AT" TIMESTAMP,
+ "CHECKSUM" VARCHAR(1000),
+ "PERMANENT_ID" INTEGER,
+ "SWITCHED_OFF" BOOLEAN,
+ "PERSON_ID" INTEGER
+);
+
+CREATE TABLE "METRICS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "NAME" VARCHAR(64) NOT NULL,
+ "DESCRIPTION" VARCHAR(255),
+ "DIRECTION" INTEGER NOT NULL DEFAULT 0,
+ "DOMAIN" VARCHAR(64),
+ "SHORT_NAME" VARCHAR(64),
+ "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE,
+ "VAL_TYPE" VARCHAR(8),
+ "USER_MANAGED" BOOLEAN DEFAULT FALSE,
+ "ENABLED" BOOLEAN DEFAULT TRUE,
+ "ORIGIN" VARCHAR(3),
+ "WORST_VALUE" DOUBLE,
+ "BEST_VALUE" DOUBLE,
+ "OPTIMIZED_BEST_VALUE" BOOLEAN,
+ "HIDDEN" BOOLEAN,
+ "DELETE_HISTORICAL_DATA" BOOLEAN
+);
+
+CREATE TABLE "LOADED_TEMPLATES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "KEE" VARCHAR(200),
+ "TEMPLATE_TYPE" VARCHAR(15)
+);
+
+CREATE TABLE "RESOURCE_INDEX" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "KEE" VARCHAR(400) NOT NULL,
+ "POSITION" INTEGER NOT NULL,
+ "NAME_SIZE" INTEGER NOT NULL,
+ "RESOURCE_ID" INTEGER NOT NULL,
+ "ROOT_PROJECT_ID" INTEGER NOT NULL,
+ "QUALIFIER" VARCHAR(10) NOT NULL
+);
+
+CREATE TABLE "ACTION_PLANS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "USER_ID" INTEGER,
+ "NAME" VARCHAR(200),
+ "DESCRIPTION" VARCHAR(1000),
+ "DEADLINE" TIMESTAMP,
+ "USER_LOGIN" VARCHAR(40),
+ "PROJECT_ID" INTEGER,
+ "STATUS" VARCHAR(10),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP
+);
+
+CREATE TABLE "ACTION_PLANS_REVIEWS" (
+ "ACTION_PLAN_ID" INTEGER,
+ "REVIEW_ID" INTEGER
+);
+
+CREATE TABLE "ACTIVE_RULE_NOTES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "ACTIVE_RULE_ID" INTEGER,
+ "USER_LOGIN" VARCHAR(40),
+ "DATA" BINARY(167772150),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP
+);
+
+CREATE TABLE "RULE_NOTES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "RULE_ID" INTEGER,
+ "USER_LOGIN" VARCHAR(40),
+ "DATA" BINARY(167772150),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP
+);
+
+CREATE TABLE "AUTHORS" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PERSON_ID" INTEGER,
+ "LOGIN" VARCHAR(100),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP
+);
input.setProperty("url", "${env:SONAR_JDBC_URL}");
input.setProperty("do_not_change", "${SONAR_JDBC_URL}");
Map<String, String> variables = Maps.newHashMap();
- variables.put("SONAR_JDBC_URL", "jdbc:derby:mem");
+ variables.put("SONAR_JDBC_URL", "jdbc:h2:mem");
Properties output = ConfigurationUtils.interpolateVariables(input, variables);
assertThat(output.size(), is(3));
assertThat(output.getProperty("hello"), is("world"));
- assertThat(output.getProperty("url"), is("jdbc:derby:mem"));
+ assertThat(output.getProperty("url"), is("jdbc:h2:mem"));
assertThat(output.getProperty("do_not_change"), is("${SONAR_JDBC_URL}"));
// input is not changed
public static void startDatabase() throws Exception {
Settings settings = new Settings();
settings.setProperties(Maps.fromProperties(System.getProperties()));
- if (settings.hasKey("sonar.jdbc.dialect")) {
- database = new DefaultDatabase(settings);
- } else {
- database = new InMemoryDatabase();
- }
- database.start();
+ boolean hasDialect = settings.hasKey("sonar.jdbc.dialect");
+
+ if ((null == database) || (hasDialect)) { // Create database only once per vm (Only for in mempry database)
+ if (hasDialect) {
+ database = new DefaultDatabase(settings);
+ } else {
+ database = new H2Database();
+ }
+ database.start();
- myBatis = new MyBatis(database);
- myBatis.start();
+ myBatis = new MyBatis(database);
+ myBatis.start();
- databaseCommands = DatabaseCommands.forDialect(database.getDialect());
+ databaseCommands = DatabaseCommands.forDialect(database.getDialect());
+ }
}
@Before
}
protected final void checkTables(String testName, String... tables) {
- checkTables(testName, new String[]{}, tables);
+ checkTables(testName, new String[] {}, tables);
}
protected final void checkTables(String testName, String[] excludedColumnNames, String... tables) {
package org.sonar.core.persistence;
import org.apache.commons.lang.StringUtils;
-import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
import org.dbunit.dataset.datatype.IDataTypeFactory;
+import org.dbunit.ext.h2.H2DataTypeFactory;
import org.dbunit.ext.mssql.InsertIdentityOperation;
import org.dbunit.ext.mssql.MsSqlDataTypeFactory;
import org.dbunit.ext.mysql.MySqlDataTypeFactory;
import org.dbunit.ext.oracle.Oracle10DataTypeFactory;
import org.dbunit.ext.postgresql.PostgresqlDataTypeFactory;
import org.dbunit.operation.DatabaseOperation;
-import org.sonar.core.persistence.dialect.*;
+import org.sonar.core.persistence.dialect.Dialect;
+import org.sonar.core.persistence.dialect.MsSql;
+import org.sonar.core.persistence.dialect.MySql;
+import org.sonar.core.persistence.dialect.Oracle;
+import org.sonar.core.persistence.dialect.PostgreSql;
import java.sql.Connection;
import java.sql.SQLException;
return DatabaseOperation.CLEAN_INSERT;
}
- static final DatabaseCommands DERBY = new DatabaseCommands(new DefaultDataTypeFactory()) {
+ static final DatabaseCommands H2 = new DatabaseCommands(new H2DataTypeFactory()) {
@Override
public String truncate(String table) {
return "TRUNCATE TABLE " + table;
return Arrays.asList(
"DROP SEQUENCE " + sequence,
"CREATE SEQUENCE " + sequence + " INCREMENT BY 1 MINVALUE 1 START WITH 1"
- );
+ );
}
@Override
}
};
-
public static DatabaseCommands forDialect(Dialect dialect) {
- if (Derby.ID.equals(dialect.getId())) {
- return DERBY;
+ if (org.sonar.core.persistence.dialect.H2.ID.equals(dialect.getId())) {
+ return H2;
}
if (MsSql.ID.equals(dialect.getId())) {
return MSSQL;
*/
package org.sonar.core.persistence;
-import org.apache.derby.jdbc.EmbeddedDriver;
-import org.hamcrest.core.Is;
+import org.h2.Driver;
import org.junit.Test;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
public class DdlUtilsTest {
- static {
- DerbyUtils.fixDerbyLogs();
- }
-
@Test
- public void shouldSupportOnlyDerby() {
- assertThat(DdlUtils.supportsDialect("derby"), Is.is(true));
- assertThat(DdlUtils.supportsDialect("mysql"), Is.is(false));
- assertThat(DdlUtils.supportsDialect("oracle"), Is.is(false));
- assertThat(DdlUtils.supportsDialect("mssql"), Is.is(false));
+ public void shouldSupportOnlyH2() {
+ assertThat(DdlUtils.supportsDialect("h2")).isTrue();
+ assertThat(DdlUtils.supportsDialect("mysql")).isFalse();
+ assertThat(DdlUtils.supportsDialect("oracle")).isFalse();
+ assertThat(DdlUtils.supportsDialect("mssql")).isFalse();
}
@Test
- public void shouldCreateDerbySchema() throws SQLException {
- int tables = 0;
- DriverManager.registerDriver(new EmbeddedDriver());
- Connection connection = DriverManager.getConnection("jdbc:derby:memory:sonar;create=true");
- DdlUtils.createSchema(connection, "derby");
+ public void shouldCreateSchema() throws SQLException {
+ DriverManager.registerDriver(new Driver());
+ Connection connection = DriverManager.getConnection("jdbc:h2:mem:sonar_test");
+ DdlUtils.createSchema(connection, "h2");
+
+ int tables = countTables(connection);
+
+ connection.close();
+ assertThat(tables).isGreaterThan(30);
+ }
- ResultSet resultSet = connection.getMetaData().getTables("", null, null, new String[]{"TABLE"});
+ private int countTables(Connection connection) throws SQLException {
+ int count = 0;
+ ResultSet resultSet = connection.getMetaData().getTables(null, null, null, new String[] {"TABLE"});
while (resultSet.next()) {
- tables++;
+ count++;
}
resultSet.close();
- connection.commit();
- connection.close();
- assertThat(tables, greaterThan(30));
-
- DerbyUtils.dropInMemoryDatabase();
+ return count;
}
}
public class DefaultDatabaseTest {
- static {
- DerbyUtils.fixDerbyLogs();
- }
-
@Test
public void shouldLoadDefaultValues() {
DefaultDatabase db = new DefaultDatabase(new Settings());
Properties props = db.getProperties();
assertThat(props.getProperty("sonar.jdbc.username"), Is.is("sonar"));
assertThat(props.getProperty("sonar.jdbc.password"), Is.is("sonar"));
- assertThat(props.getProperty("sonar.jdbc.url"), Is.is("jdbc:derby://localhost:1527/sonar"));
- assertThat(props.getProperty("sonar.jdbc.driverClassName"), Is.is("org.apache.derby.jdbc.ClientDriver"));
+ assertThat(props.getProperty("sonar.jdbc.url"), Is.is("jdbc:h2:tcp://localhost/sonar"));
+ assertThat(props.getProperty("sonar.jdbc.driverClassName"), Is.is("org.h2.Driver"));
}
@Test
@Test
public void shouldStart() {
Settings settings = new Settings();
- settings.setProperty("sonar.jdbc.url", "jdbc:derby:memory:sonar;create=true;user=sonar;password=sonar");
- settings.setProperty("sonar.jdbc.driverClassName", "org.apache.derby.jdbc.EmbeddedDriver");
+ settings.setProperty("sonar.jdbc.url", "jdbc:h2:mem:sonar");
+ settings.setProperty("sonar.jdbc.driverClassName", "org.h2.Driver");
settings.setProperty("sonar.jdbc.username", "sonar");
settings.setProperty("sonar.jdbc.password", "sonar");
settings.setProperty("sonar.jdbc.maxActive", "1");
- try {
- DefaultDatabase db = new DefaultDatabase(settings);
- db.start();
+ DefaultDatabase db = new DefaultDatabase(settings);
+ db.start();
- assertThat(db.getDialect().getId(), Is.is("derby"));
- assertThat(((BasicDataSource) db.getDataSource()).getMaxActive(), Is.is(1));
- } finally {
- DerbyUtils.dropInMemoryDatabase();
- }
+ assertThat(db.getDialect().getId(), Is.is("h2"));
+ assertThat(((BasicDataSource) db.getDataSource()).getMaxActive(), Is.is(1));
}
@Test
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.core.persistence;
-
-import java.io.OutputStream;
-import java.sql.DriverManager;
-
-public final class DerbyUtils {
-
- private DerbyUtils() {
- }
-
- public static final OutputStream DEV_NULL = new OutputStream() {
- @Override
- public void write(int b) {
- }
- };
-
- /**
- * Disables Derby log.
- * Note: in order to work properly this method should be called before Derby boot.
- * See http://db.apache.org/derby/docs/10.7/ref/rrefproper33027.html
- */
- public static void fixDerbyLogs() {
- System.setProperty("derby.stream.error.field", "org.sonar.core.persistence.DerbyUtils.DEV_NULL");
- }
-
- public static void dropInMemoryDatabase() {
- try {
- DriverManager.getConnection("jdbc:derby:memory:sonar;drop=true");
- } catch (Exception e) {
- // silently ignore
- }
- }
-}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.persistence;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.commons.dbcp.BasicDataSourceFactory;
+import org.hibernate.cfg.Environment;
+import org.sonar.core.persistence.dialect.Dialect;
+import org.sonar.core.persistence.dialect.H2;
+import org.sonar.jpa.session.CustomHibernateConnectionProvider;
+
+import javax.sql.DataSource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * H2 in-memory database, used for unit tests only.
+ *
+ * @since 3.2
+ */
+public class H2Database implements Database {
+ private static BasicDataSource datasource;
+
+ public H2Database start() {
+ if (datasource == null) {
+ startDatabase();
+ createSchema();
+ }
+ return this;
+ }
+
+ /**
+ * IMPORTANT: DB name changed from "sonar" to "sonar2" in order to not conflict with {@link DefaultDatabaseTest}
+ */
+ void startDatabase() {
+ try {
+ Properties properties = new Properties();
+ properties.put("driverClassName", "org.h2.Driver");
+ properties.put("username", "sonar");
+ properties.put("password", "sonar");
+ properties.put("url", "jdbc:h2:mem:sonar2");
+
+ // limit to 2 because of Hibernate and MyBatis
+ properties.put("maxActive", "2");
+ properties.put("maxIdle", "2");
+ datasource = (BasicDataSource) BasicDataSourceFactory.createDataSource(properties);
+
+ } catch (Exception e) {
+ throw new IllegalStateException("Fail to start H2", e);
+ }
+ }
+
+ void createSchema() {
+ Connection connection = null;
+ try {
+ connection = datasource.getConnection();
+ DdlUtils.createSchema(connection, "h2");
+ } catch (SQLException e) {
+ throw new IllegalStateException("Fail to create schema", e);
+ } finally {
+ closeQuietly(connection);
+ }
+ }
+
+ public static void stopDatabase() {
+ try {
+ if (datasource != null) {
+ datasource.close();
+ datasource = null;
+ }
+ } catch (SQLException e) {
+ // Ignore error
+ }
+ }
+
+ public H2Database stop() {
+ return this;
+ }
+
+ public DataSource getDataSource() {
+ return datasource;
+ }
+
+ public Dialect getDialect() {
+ return new H2();
+ }
+
+ public String getSchema() {
+ return null;
+ }
+
+ public Properties getHibernateProperties() {
+ Properties properties = new Properties();
+ properties.put("hibernate.hbm2ddl.auto", "validate");
+ properties.put(Environment.DIALECT, getDialect().getHibernateDialectClass().getName());
+ properties.put(Environment.CONNECTION_PROVIDER, CustomHibernateConnectionProvider.class.getName());
+ return properties;
+ }
+
+ private static void closeQuietly(Connection connection) {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.persistence;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.hamcrest.core.Is;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public class H2DatabaseTest {
+
+ @Test
+ public void shouldExecuteDdlAtStartup() throws SQLException {
+ int tables = 0;
+ H2Database db = new H2Database();
+ try {
+ db.start();
+ assertNotNull(db.getDataSource());
+ Connection connection = db.getDataSource().getConnection();
+ assertNotNull(connection);
+
+ ResultSet resultSet = connection.getMetaData().getTables("", null, null, new String[] {"TABLE"});
+ while (resultSet.next()) {
+ tables++;
+ }
+
+ } finally {
+ db.stop();
+ }
+ assertThat(tables, greaterThan(30));
+ }
+
+ @Test
+ public void shouldLimitThePoolSize() {
+ H2Database db = new H2Database();
+ try {
+ db.startDatabase();
+ assertThat(((BasicDataSource) db.getDataSource()).getMaxActive(), Is.is(2));
+ assertThat(((BasicDataSource) db.getDataSource()).getMaxIdle(), Is.is(2));
+
+ } finally {
+ db.stop();
+ }
+ }
+}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.core.persistence;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.commons.dbcp.BasicDataSourceFactory;
-import org.hibernate.cfg.Environment;
-import org.sonar.core.persistence.dialect.Derby;
-import org.sonar.core.persistence.dialect.Dialect;
-import org.sonar.jpa.session.CustomHibernateConnectionProvider;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.Properties;
-
-/**
- * Derby in-memory database, used for unit tests only.
- *
- * @since 2.12
- */
-public class InMemoryDatabase implements Database {
-
- static {
- DerbyUtils.fixDerbyLogs();
- }
-
- private static BasicDataSource datasource;
-
- public InMemoryDatabase start() {
- if (datasource == null) {
- startDatabase();
- createSchema();
- }
- truncateTables();
- return this;
- }
-
- /**
- * IMPORTANT: DB name changed from "sonar" to "sonar2" in order to not conflict with {@link DefaultDatabaseTest}
- */
- void startDatabase() {
- try {
- Properties properties = new Properties();
- properties.put("driverClassName", "org.apache.derby.jdbc.EmbeddedDriver");
- properties.put("username", "sonar");
- properties.put("password", "sonar");
- properties.put("url", "jdbc:derby:memory:sonar2;create=true;user=sonar;password=sonar");
-
- // limit to 2 because of Hibernate and MyBatis
- properties.put("maxActive", "2");
- properties.put("maxIdle", "2");
- datasource = (BasicDataSource) BasicDataSourceFactory.createDataSource(properties);
-
- } catch (Exception e) {
- throw new IllegalStateException("Fail to start Derby", e);
- }
- }
-
- void createSchema() {
- Connection connection = null;
- try {
- connection = datasource.getConnection();
- DdlUtils.createSchema(connection, "derby");
-
- } catch (SQLException e) {
- throw new IllegalStateException("Fail to create schema", e);
-
- } finally {
- closeQuietly(connection);
- }
- }
-
- private void truncateTables() {
- Connection connection = null;
- try {
- connection = datasource.getConnection();
-
- DatabaseMetaData meta = connection.getMetaData();
- Statement statement = connection.createStatement();
-
- ResultSet res = meta.getTables(null, null, null, new String[]{"TABLE"});
- while (res.next()) {
- String tableName = res.getString("TABLE_NAME");
- statement.executeUpdate("TRUNCATE TABLE " + tableName);
- }
- res.close();
-
- // See https://issues.apache.org/jira/browse/DERBY-5403
- res = meta.getColumns(null, null, null, "ID");
- while (res.next()) {
- String tableName = res.getString("TABLE_NAME");
- statement.executeUpdate("ALTER TABLE " + tableName + " ALTER COLUMN ID RESTART WITH 1");
- }
- res.close();
-
- statement.close();
- } catch (SQLException e) {
- throw new IllegalStateException("Fail to truncate tables", e);
-
- } finally {
- closeQuietly(connection); // Important, otherwise tests can stuck
- }
- }
-
- public static void stopDatabase() {
- try {
- if (datasource != null) {
- datasource.close();
- datasource = null;
- }
- DriverManager.getConnection("jdbc:derby:;shutdown=true");
-
- } catch (SQLException e) {
- // See http://db.apache.org/derby/docs/dev/getstart/rwwdactivity3.html
- // XJ015 indicates successful shutdown of Derby
- // 08006 successful shutdown of a single database
- if (!"XJ015".equals(e.getSQLState())) {
- throw new IllegalStateException("Fail to stop Derby", e);
- }
- }
- }
-
- public InMemoryDatabase stop() {
- return this;
- }
-
- public DataSource getDataSource() {
- return datasource;
- }
-
- public Dialect getDialect() {
- return new Derby();
- }
-
- public String getSchema() {
- return null;
- }
-
- public Properties getHibernateProperties() {
- Properties properties = new Properties();
- properties.put("hibernate.hbm2ddl.auto", "validate");
- properties.put(Environment.DIALECT, getDialect().getHibernateDialectClass().getName());
- properties.put(Environment.CONNECTION_PROVIDER, CustomHibernateConnectionProvider.class.getName());
- return properties;
- }
-
- private static void closeQuietly(Connection connection) {
- if (connection != null) {
- try {
- connection.close();
- } catch (SQLException e) {
- // ignore
- }
- }
- }
-
-}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.core.persistence;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.hamcrest.core.Is;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-public class InMemoryDatabaseTest {
-
- static {
- DerbyUtils.fixDerbyLogs();
- }
-
- @Test
- public void shouldExecuteDdlAtStartup() throws SQLException {
- int tables = 0;
- InMemoryDatabase db = new InMemoryDatabase();
- try {
- db.start();
- assertNotNull(db.getDataSource());
- Connection connection = db.getDataSource().getConnection();
- assertNotNull(connection);
-
- ResultSet resultSet = connection.getMetaData().getTables("", null, null, new String[] {"TABLE"});
- while (resultSet.next()) {
- tables++;
- }
-
- } finally {
- db.stop();
- }
- assertThat(tables, greaterThan(30));
- }
-
- @Test
- public void shouldLimitThePoolSize() {
- InMemoryDatabase db = new InMemoryDatabase();
- try {
- db.startDatabase();
- assertThat(((BasicDataSource) db.getDataSource()).getMaxActive(), Is.is(2));
- assertThat(((BasicDataSource) db.getDataSource()).getMaxIdle(), Is.is(2));
-
- } finally {
- db.stop();
- }
- }
-}
public class MyBatisTest {
- static {
- DerbyUtils.fixDerbyLogs();
- }
-
private static MyBatis myBatis;
- private static InMemoryDatabase database;
+ private static H2Database database;
@BeforeClass
public static void start() {
- database = new InMemoryDatabase();
+ database = new H2Database();
myBatis = new MyBatis(database.start());
myBatis.start();
}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.core.persistence.dialect;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public class DerbyTest {
-
- private Derby derby = new Derby();
-
- @Test
- public void matchesJdbcURL() {
- assertThat(derby.matchesJdbcURL("jdbc:derby:foo"), is(true));
- assertThat(derby.matchesJdbcURL("jdbc:hsql:foo"), is(false));
- }
-
- @Test
- public void testBooleanSqlValues() {
- assertThat(derby.getTrueSqlValue(), is("true"));
- assertThat(derby.getFalseSqlValue(), is("false"));
- }
-}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.core.persistence.dialect;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class H2Test {
+
+ private H2 h2 = new H2();
+
+ @Test
+ public void matchesJdbcURL() {
+ assertThat(h2.matchesJdbcURL("jdbc:h2:foo"), is(true));
+ assertThat(h2.matchesJdbcURL("jdbc:hsql:foo"), is(false));
+ }
+
+ @Test
+ public void testBooleanSqlValues() {
+ assertThat(h2.getTrueSqlValue(), is("true"));
+ assertThat(h2.getFalseSqlValue(), is("false"));
+ }
+}
import org.dbunit.DataSourceDatabaseTester;
import org.dbunit.DatabaseUnitException;
import org.dbunit.IDatabaseTester;
+import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.Column;
import org.dbunit.dataset.CompositeDataSet;
import org.dbunit.dataset.DataSetException;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.ITable;
-import org.dbunit.dataset.ITableMetaData;
import org.dbunit.dataset.ReplacementDataSet;
import org.dbunit.dataset.filter.DefaultColumnFilter;
import org.dbunit.dataset.xml.FlatXmlDataSet;
+import org.dbunit.ext.h2.H2DataTypeFactory;
import org.dbunit.operation.DatabaseOperation;
import org.junit.After;
-import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.sonar.api.database.DatabaseSession;
import org.sonar.core.persistence.Database;
import org.sonar.core.persistence.DatabaseCommands;
-import org.sonar.core.persistence.InMemoryDatabase;
+import org.sonar.core.persistence.H2Database;
import org.sonar.jpa.session.DatabaseSessionFactory;
import org.sonar.jpa.session.DefaultDatabaseConnector;
import org.sonar.jpa.session.JpaDatabaseSession;
import org.sonar.jpa.session.MemoryDatabaseConnector;
import java.io.InputStream;
-import java.sql.ResultSet;
import java.sql.SQLException;
import static org.junit.Assert.fail;
@BeforeClass
public static void startDatabase() throws Exception {
- database = new InMemoryDatabase();
- database.start();
+ if (null == database) { // Create only once per vm
+ database = new H2Database();
+ database.start();
- dbConnector = new MemoryDatabaseConnector(database);
- dbConnector.start();
+ dbConnector = new MemoryDatabaseConnector(database);
+ dbConnector.start();
- databaseCommands = DatabaseCommands.forDialect(database.getDialect());
+ databaseCommands = DatabaseCommands.forDialect(database.getDialect());
+ }
}
@Before
session.stop();
}
- @AfterClass
- public static void stopDatabase() {
- dbConnector.stop();
- database.stop();
- }
-
public DatabaseSession getSession() {
return session;
}
databaseTester.setDataSet(compositeDataSet);
connection = databaseTester.getConnection();
+ connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory());
DatabaseOperation.CLEAN_INSERT.execute(connection, databaseTester.getDataSet());
- resetDerbySequence(compositeDataSet);
} catch (Exception e) {
throw translateException("Could not setup DBUnit data", e);
}
}
- private void resetDerbySequence(CompositeDataSet compositeDataSet) throws DataSetException, SQLException {
- for (ITable table : compositeDataSet.getTables()) {
- ITableMetaData tableMetaData = table.getTableMetaData();
- String tableName = tableMetaData.getTableName();
- for (Column column : tableMetaData.getColumns()) {
- if ("id".equalsIgnoreCase(column.getColumnName())) { // TODO hard-coded value
- String maxSql = "SELECT MAX(id) FROM " + tableName;
- ResultSet res = connection.getConnection().prepareStatement(maxSql).executeQuery();
- res.next();
- int max = res.getInt(1);
- res.close();
- String alterSql = "ALTER TABLE " + tableName + " ALTER COLUMN id RESTART WITH " + (max + 1);
- connection.getConnection().prepareStatement(alterSql).execute();
- }
- }
- }
- }
-
protected final void checkTables(String testName, String... tables) {
checkTables(testName, new String[0], tables);
}
int MAX_TEXT_SIZE = 16777215;
String PROP_URL = "sonar.jdbc.url";
- String PROP_URL_DEFAULT_VALUE = "jdbc:derby://localhost:1527/sonar";
+ String PROP_URL_DEFAULT_VALUE = "jdbc:h2:tcp://localhost/sonar";
String PROP_DRIVER = "sonar.jdbc.driverClassName";
- String PROP_DRIVER_DEFAULT_VALUE = "org.apache.derby.jdbc.ClientDriver";
+ String PROP_DRIVER_DEFAULT_VALUE = "org.h2.Driver";
String PROP_DRIVER_DEPRECATED = "sonar.jdbc.driver";
String PROP_USER = "sonar.jdbc.username";
String PROP_USER_DEPRECATED = "sonar.jdbc.user";
String PROP_HIBERNATE_GENERATE_STATISTICS = "sonar.jdbc.hibernate.generate_statistics";
String PROP_DIALECT = "sonar.jdbc.dialect";
String PROP_HIBERNATE_DEFAULT_SCHEMA = "sonar.hibernate.default_schema";
-
String PROP_EMBEDDED_DATA_DIR = "sonar.embeddedDatabase.dataDir";
+
+ /**
+ * @since 3.2
+ */
+ String PROP_EMBEDDED_PORT = "sonar.embeddedDatabase.port";
+
+ /**
+ * @since 3.2
+ */
+ String PROP_EMBEDDED_PORT_DEFAULT_VALUE = "9092";
}
\ No newline at end of file
+++ /dev/null
-set MAVEN_OPTS='-Xmx768m -XX:MaxPermSize=128m'
-mvn clean jetty:run -Pstart-dev-server,derby
+++ /dev/null
-#!/bin/sh
-export MAVEN_OPTS='-Xmx768m -XX:MaxPermSize=128m'
-mvn clean jetty:run -Pstart-dev-server,derby
--- /dev/null
+set MAVEN_OPTS='-Xmx768m -XX:MaxPermSize=128m'
+mvn clean jetty:run -Pstart-dev-server,h2
--- /dev/null
+#!/bin/sh
+export MAVEN_OPTS='-Xmx768m -XX:MaxPermSize=128m'
+mvn clean jetty:run -Pstart-dev-server,h2
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-update-center-common</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbyclient</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<artifactId>commons-configuration</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbynet</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
</profile>
<profile>
- <id>derby</id>
+ <id>h2</id>
<properties>
- <jdbcDialect>derby</jdbcDialect>
+ <jdbcDialect>h2</jdbcDialect>
</properties>
<build>
<plugins>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<resources>
<resource>
- <directory>${basedir}/src/dev/derby</directory>
+ <directory>${basedir}/src/dev/h2</directory>
<filtering>false</filtering>
</resource>
</resources>
<configuration>
<overWriteIfNewer>true</overWriteIfNewer>
<overWriteReleases>true</overWriteReleases>
- <includeGroupIds>org.apache.derby</includeGroupIds>
- <includeArtifactIds>derbyclient</includeArtifactIds>
- <outputDirectory>${project.build.directory}/sonar-dev-home/extensions/jdbc-driver/derby/
- </outputDirectory>
+ <includeGroupIds>com.h2database</includeGroupIds>
+ <includeArtifactIds>h2</includeArtifactIds>
+ <outputDirectory>${project.build.directory}/sonar-dev-home/extensions/jdbc-driver/h2/</outputDirectory>
</configuration>
</execution>
</executions>
</build>
<dependencies>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derbyclient</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
</dependency>
</dependencies>
</profile>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<configuration>
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>
- %d{HH:mm:ss.SSS} %-5level %logger{20} %X - %msg%n
- </pattern>
- </encoder>
- </appender>
-
- <logger name="org.hibernate.SQL">
- <level value="ERROR"/>
- </logger>
-
- <logger name="org.hibernate.cache.ReadWriteCache">
- <!-- removing "An item was expired by the cache while it was locked (increase your cache timeout)" msg -->
- <level value="ERROR"/>
- </logger>
-
- <logger name="org.hibernate.cache.EhCacheProvider">
- <!-- removing "org.hibernate.cache.EhCacheProvider - Could not find configuratio)" message -->
- <level value="ERROR"/>
- </logger>
-
- <logger name="org.sonar.INFO">
- <level value="INFO"/>
- </logger>
-
- <logger name="net.sf.ehcache">
- <level value="INFO"/>
- </logger>
-
-
- <logger name="rails.sonar">
- <level value="INFO"/>
- </logger>
-
- <root>
- <level value="INFO"/>
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+++ /dev/null
-# Derby
-sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
-sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
-sonar.jdbc.defaultTransactionIsolation: 1
-sonar.jdbc.username: sonar
-sonar.jdbc.password: sonar
-sonar.jdbc.maxActive: 30
-sonar.jdbc.maxIdle: 10
-sonar.jdbc.minIdle: 2
-sonar.jdbc.maxWait: 5000
-sonar.jdbc.minEvictableIdleTimeMillis: 600000
-sonar.jdbc.timeBetweenEvictionRunsMillis: 30000
-
-sonar.runtime.mode: development
-
-sonar.derby.drda.portNumber: 1527
-sonar.derby.drda.host: localhost
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>
+ %d{HH:mm:ss.SSS} %-5level %logger{20} %X - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.hibernate.SQL">
+ <level value="ERROR"/>
+ </logger>
+
+ <logger name="org.hibernate.cache.ReadWriteCache">
+ <!-- removing "An item was expired by the cache while it was locked (increase your cache timeout)" msg -->
+ <level value="ERROR"/>
+ </logger>
+
+ <logger name="org.hibernate.cache.EhCacheProvider">
+ <!-- removing "org.hibernate.cache.EhCacheProvider - Could not find configuratio)" message -->
+ <level value="ERROR"/>
+ </logger>
+
+ <logger name="org.sonar.INFO">
+ <level value="INFO"/>
+ </logger>
+
+ <logger name="net.sf.ehcache">
+ <level value="INFO"/>
+ </logger>
+
+
+ <logger name="rails.sonar">
+ <level value="INFO"/>
+ </logger>
+
+ <root>
+ <level value="INFO"/>
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
--- /dev/null
+# H2
+sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar
+sonar.jdbc.driverClassName: org.h2.Driver
+sonar.jdbc.defaultTransactionIsolation: 1
+sonar.jdbc.username: sonar
+sonar.jdbc.password: sonar
+sonar.jdbc.maxActive: 30
+sonar.jdbc.maxIdle: 10
+sonar.jdbc.minIdle: 2
+sonar.jdbc.maxWait: 5000
+sonar.jdbc.minEvictableIdleTimeMillis: 600000
+sonar.jdbc.timeBetweenEvictionRunsMillis: 30000
+
+sonar.runtime.mode: development
+
+sonar.embeddedDatabase.port: 9092
+
*/
package org.sonar.server.database;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.derby.drda.NetworkServerControl;
+import org.h2.tools.Server;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseProperties;
-import org.sonar.api.utils.Logs;
import org.sonar.api.utils.SonarException;
import org.sonar.server.platform.ServerStartException;
import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.InetAddress;
-import java.util.Properties;
+import java.sql.DriverManager;
+import java.sql.SQLException;
public class EmbeddedDatabase {
+ private static final Logger LOG = LoggerFactory.getLogger(EmbeddedDatabase.class);
- private static final String DEFAULT_USER = "sonar";
- private static final String DEFAULT_PWD = "sonar";
-
- private NetworkServerControl serverControl = null;
-
- private File dbHome;
- private Properties dbProps;
- private PrintWriter dbLog;
+ private final Settings settings;
+ private Server server;
public EmbeddedDatabase(Settings settings) {
- this.dbHome = getDataDirectory(settings);
- this.dbProps = getDefaultProperties(settings);
- }
-
- public EmbeddedDatabase(File dbHome, Properties dbProps) {
- this.dbHome = dbHome;
- this.dbProps = dbProps;
- }
-
- public File getDataDir() {
- return dbHome;
- }
-
- protected File getDataDirectory(Settings settings) {
- String dirName = settings.getString(DatabaseProperties.PROP_EMBEDDED_DATA_DIR);
- if (StringUtils.isBlank(dirName)) {
- File sonarHome = new File(settings.getString(CoreProperties.SONAR_HOME));
- if (!sonarHome.isDirectory() || !sonarHome.exists()) {
- throw new ServerStartException("Sonar home directory does not exist");
- }
- return new File(sonarHome, "data");
- }
- return new File(dirName);
- }
-
- public void setDbLog(PrintWriter dbLog) {
- this.dbLog = dbLog;
+ this.settings = settings;
}
public void start() {
+ File dbHome = getDataDirectory(settings);
if (dbHome.exists() && !dbHome.isDirectory()) {
throw new SonarException("Database home " + dbHome.getPath() + " is not a directory");
}
if (!dbHome.exists()) {
dbHome.mkdirs();
}
- System.setProperty("derby.system.home", dbHome.getPath());
- saveDerbyPropertiesFile();
- startListening();
- Logs.INFO.info("Embedded database started. Data stored in: " + dbHome.getAbsolutePath());
- }
+ String port = getSetting(DatabaseProperties.PROP_EMBEDDED_PORT, DatabaseProperties.PROP_EMBEDDED_PORT_DEFAULT_VALUE);
+ String user = getSetting(DatabaseProperties.PROP_USER, DatabaseProperties.PROP_USER_DEFAULT_VALUE);
+ String password = getSetting(DatabaseProperties.PROP_PASSWORD, DatabaseProperties.PROP_PASSWORD_DEFAULT_VALUE);
- private void startListening() {
try {
- int port = Integer.parseInt(dbProps.getProperty("derby.drda.portNumber"));
- String host = dbProps.getProperty("derby.drda.host");
- serverControl = new NetworkServerControl(InetAddress.getByName(host), port, DEFAULT_USER, DEFAULT_PWD);
- Logs.INFO.info("Starting embedded database on port " + port);
- serverControl.start(dbLog);
- ensureServerIsUp();
- } catch (Exception e) {
- throw new SonarException(e);
- }
- }
+ createDatabase(dbHome, user, password);
- private void saveDerbyPropertiesFile() {
- FileOutputStream output = null;
- try {
- File derbyProps = new File(dbHome.getPath() + "/derby.properties");
- output = new FileOutputStream(derbyProps);
- dbProps.store(output, "GENERATED FILE, DO NOT EDIT ME UNLESS YOU WANT TO LOOSE YOUR TIME ;O)");
+ Server server = Server.createTcpServer("-tcpPort", port, "-tcpAllowOthers", "-ifExists", "-baseDir", dbHome.getAbsolutePath());
- } catch (IOException e) {
- throw new SonarException(e);
+ LOG.info("Starting embedded database on port " + server.getPort());
+ server.start();
- } finally {
- IOUtils.closeQuietly(output);
+ LOG.info("Embedded database started. Data stored in: " + dbHome.getAbsolutePath());
+ } catch (Exception e) {
+ throw new SonarException("Unable to start database", e);
}
}
public void stop() {
- if (serverControl != null) {
- try {
- serverControl.shutdown();
- ensureServerIsDown();
- serverControl = null;
- Logs.INFO.info("Embedded database stopped");
-
- } catch (Exception e) {
- throw new SonarException(e);
- }
+ if (server != null) {
+ server.stop();
+ server = null;
+ LOG.info("Embedded database stopped");
}
}
- private void ensureServerIsUp() {
- for (int retry = 0; retry < 100; retry++) {
- try {
- serverControl.ping();
- return;
-
- } catch (Exception ex) {
- sleep(300);
- }
- }
- throw new SonarException("Embedded database does not respond to ping requests");
+ private String getSetting(String name, String defaultValue) {
+ return StringUtils.defaultIfBlank(settings.getString(name), defaultValue);
}
- private void ensureServerIsDown() {
- for (int retry = 0; retry < 100; retry++) {
- try {
- serverControl.ping();
- sleep(300);
-
- } catch (SonarException se) {
- throw se;
+ private void createDatabase(File dbHome, String user, String password) throws SQLException {
+ String url = String.format("jdbc:h2:%s/sonar;USER=%s;PASSWORD=%s", dbHome.getAbsolutePath(), user, password);
- } catch (Exception e) {
- // normal case: the database does not respond to ping
- return;
- }
- }
- throw new SonarException("Fail to stop embedded database");
+ DriverManager.getConnection(url).close();
}
+ private static File getDataDirectory(Settings settings) {
+ String dirName = settings.getString(DatabaseProperties.PROP_EMBEDDED_DATA_DIR);
+ if (!StringUtils.isBlank(dirName)) {
+ return new File(dirName);
+ }
- private void sleep(long time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- throw new SonarException("Fail to ping embedded database", e);
+ File sonarHome = new File(settings.getString(CoreProperties.SONAR_HOME));
+ if (sonarHome.isDirectory() && sonarHome.exists()) {
+ return new File(sonarHome, "data");
}
- }
- public static Properties getDefaultProperties(Settings settings) {
- Properties props = new Properties();
- props.setProperty("derby.drda.startNetworkServer", "true");
- props.setProperty("derby.drda.host", StringUtils.defaultIfBlank(settings.getString("sonar.derby.drda.host"), "localhost"));
- props.setProperty("derby.drda.portNumber", StringUtils.defaultIfBlank(settings.getString("sonar.derby.drda.portNumber"), "1527"));
- props.setProperty("derby.drda.maxThreads", StringUtils.defaultIfBlank(settings.getString("sonar.derby.drda.maxThreads"), "20"));
- props.setProperty("derby.drda.minThreads", StringUtils.defaultIfBlank(settings.getString("sonar.derby.drda.minThreads"), "2"));
- props.setProperty("derby.drda.logConnections", StringUtils.defaultIfBlank(settings.getString("sonar.derby.drda.logConnections"), "false"));
- props.setProperty("derby.stream.error.logSeverityLevel", StringUtils.defaultIfBlank(settings.getString("sonar.derby.stream.error.logSeverityLevel"), "20000"));
- props.setProperty("derby.connection.requireAuthentication", "true");
- props.setProperty("derby.user." + DEFAULT_USER, DEFAULT_PWD);
- return props;
+ throw new ServerStartException("Sonar home directory does not exist");
}
-
}
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseProperties;
+import org.sonar.core.persistence.dialect.H2;
public class EmbeddedDatabaseFactory {
- private Settings settings;
+ private final Settings settings;
+ private final H2 dialect;
private EmbeddedDatabase embeddedDatabase;
public EmbeddedDatabaseFactory(Settings settings) {
this.settings = settings;
+ dialect = new H2();
}
public void start() {
- String jdbcUrl = settings.getString(DatabaseProperties.PROP_URL);
- if (jdbcUrl != null && jdbcUrl.startsWith("jdbc:derby://") && jdbcUrl.contains("create=true") && embeddedDatabase == null) {
- embeddedDatabase = new EmbeddedDatabase(settings);
- embeddedDatabase.start();
+ if (embeddedDatabase == null) {
+ String jdbcUrl = settings.getString(DatabaseProperties.PROP_URL);
+ if (dialect.matchesJdbcURL(jdbcUrl)) {
+ embeddedDatabase = new EmbeddedDatabase(settings);
+ embeddedDatabase.start();
+ }
}
}
return libs;
}
- private static final String[] IGNORE = { "derby", "jtds", "mysql", "postgresql", "jruby", "jfreechart", "eastwood", "jetty" };
+ private static final String[] IGNORE = {"h2", "jtds", "mysql", "postgresql", "jruby", "jfreechart", "eastwood", "jetty"};
/**
* Dirty hack to disable downloading for certain files.
*/
package org.sonar.server.database;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.derby.jdbc.ClientDriver;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.sonar.api.config.Settings;
-import org.sonar.core.persistence.InMemoryDatabase;
+import org.sonar.api.database.DatabaseProperties;
-import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
-import java.sql.Connection;
import java.sql.DriverManager;
-import java.util.Properties;
import static junit.framework.Assert.fail;
-import static org.junit.Assert.assertTrue;
public class EmbeddedDatabaseTest {
+ @Test(timeout = 5000)
+ public void should_start_and_stop() throws IOException {
+ int port = freeServerPort();
- private final static String TEST_ROOT_DIR = "./target/";
- private final static String TEST_DB_DIR_PREFIX = "testDB";
-
- private EmbeddedDatabase database;
- private String driverUrl;
- private Properties defaultProps;
- private static String testPort;
-
- @Before
- public void setUp() throws Exception {
- // This test doesn't work if InMemoryDatabase is active
- try {
- InMemoryDatabase.stopDatabase();
- } catch (Exception e) {
- }
-
- windowsCleanup();
- if (testPort == null) {
- testPort = Integer.toString(findFreeServerPort());
- }
- defaultProps = EmbeddedDatabase.getDefaultProperties(new Settings());
- defaultProps.put("derby.drda.portNumber", testPort); // changing the default port
- driverUrl = "jdbc:derby://localhost:" + testPort + "/sonar;create=true;user=sonar;password=sonar";
- }
-
- private void windowsCleanup() {
- String os = System.getProperty("os.name");
- if (os.toLowerCase().contains("windows")) {
- File testRoot = new File(TEST_ROOT_DIR);
- File[] files = testRoot.listFiles();
- for (File file : files) {
- if (file.isDirectory() &&
- file.getName().startsWith(TEST_DB_DIR_PREFIX)) {
- try {
- FileUtils.deleteDirectory(file);
- } catch (IOException e) {
- }
- }
- }
- }
- }
-
- private int findFreeServerPort() throws IOException, InterruptedException {
- ServerSocket srv = new ServerSocket(0);
- int port = srv.getLocalPort();
- srv.close();
- Thread.sleep(1500);
- return port;
- }
-
- @Test
- public void shouldStartAndStop() throws Exception {
- database = new EmbeddedDatabase(new File(TEST_ROOT_DIR + TEST_DB_DIR_PREFIX + testPort), defaultProps);
+ EmbeddedDatabase database = new EmbeddedDatabase(settings(port));
database.start();
- ClientDriver.class.newInstance();
- Connection conn;
+
try {
- conn = DriverManager.getConnection(driverUrl);
- conn.close();
+ String driverUrl = String.format("jdbc:h2:tcp://localhost:%d/sonar;USER=login;PASSWORD=pwd", port);
+ DriverManager.getConnection(driverUrl).close();
} catch (Exception ex) {
fail("Unable to connect after start");
}
- try {
- conn = DriverManager.getConnection("jdbc:derby://localhost:" + testPort + "/sonar;user=foo;password=bar");
- conn.close();
- fail("Able to connect with wrong username and password");
- } catch (Exception ex) {
- }
-
- File testDb = new File(database.getDataDir(), "sonar");
- assertTrue(testDb.exists());
- assertTrue(testDb.isDirectory());
database.stop();
-
- try {
- conn = DriverManager.getConnection(driverUrl);
- conn.close();
- fail("Able to connect after stop");
- } catch (Exception ex) {
- }
}
- @After
- public void tearDown() throws IOException {
- if (database.getDataDir().exists()) {
- if (!SystemUtils.IS_OS_WINDOWS) {
- // avoid an issue with file lock issue under windows..
- // thank you mr microsoft
- // solution : no really good solution found.., the db home is not deleted under windows on teardown but only during test startup
- FileUtils.deleteDirectory(database.getDataDir());
- }
- }
+ static Settings settings(int port) {
+ return new Settings()
+ .setProperty(DatabaseProperties.PROP_USER, "login")
+ .setProperty(DatabaseProperties.PROP_PASSWORD, "pwd")
+ .setProperty(DatabaseProperties.PROP_EMBEDDED_PORT, "" + port)
+ .setProperty(DatabaseProperties.PROP_EMBEDDED_DATA_DIR, "./target/testDB");
}
+ static int freeServerPort() throws IOException {
+ ServerSocket srv = new ServerSocket(0);
+ srv.close();
+ return srv.getLocalPort();
+ }
}
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
-import org.sonar.core.persistence.dialect.Derby;
+import org.sonar.core.persistence.dialect.H2;
import org.sonar.core.persistence.dialect.MsSql;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
@Test
public void mustDefineAtLeastOneQualifier() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(new Filter());
assertThat(result.size()).isEqualTo(0);// no qualifiers
}
@Test
public void filterOnScopes() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setScopes(Sets.newHashSet(Resource.SCOPE_SPACE)));
assertSnapshotIds(result, 4);
}
@Test
public void filterOnQualifiers() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(new Filter().setQualifiers(Sets.newHashSet(Resource.QUALIFIER_PROJECT, Resource.QUALIFIER_MODULE)));
assertSnapshotIds(result, 2, 3);
}
@Test
public void filterOnLanguages() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setLanguages(Sets.newHashSet("java")));
assertSnapshotIds(result, 2, 4);
}
@Test
public void filterOnDate() throws ParseException {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse("2008-12-26 00:00");
FilterResult result = executor.execute(Filter.createForAllQualifiers().setDateCriterion(new DateCriterion(">", date)));
assertSnapshotIds(result, 3);
@Test
public void filterOnDateIncludesTime() throws ParseException {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse("2008-12-25 03:00");
FilterResult result = executor.execute(Filter.createForAllQualifiers().setDateCriterion(new DateCriterion("<", date)));
assertSnapshotIds(result, 2, 4);
@Test
public void filterOnBaseSnapshot() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setPath(2, 2, ""));
assertSnapshotIds(result, 4);
}
@Test
public void sortByName() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setSortedByName());
assertSortedSnapshotIds(result, 2, 4, 3);
}
@Test
public void sortByKey() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setSortedByKey());
assertSortedSnapshotIds(result, 3, 2, 4);
}
@Test
public void sortByDate() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setSortedByDate());
assertSortedSnapshotIds(result, 2, 4, 3);
}
@Test
public void sortByDescendingDate() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setSortedByDate().setAscendingSort(false));
assertSortedSnapshotIds(result, 3, 4, 2);
}
@Test
public void sortByAscendingDate() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setSortedByDate().setAscendingSort(true));
assertSortedSnapshotIds(result, 2, 4, 3);
}
@Test
public void sortByAscendingMeasureValue() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.setSortedMetricId(2, true, false);
@Test
public void sortByDecendingMeasureValue() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.setSortedMetricId(2, true, false)
@Test
public void applySingleMeasureCriterion() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(2, ">", 50.0, false));
@Test
public void applyManyMeasureCriteria() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(2, ">", 50.0, false))
@Test
public void criteriaAreExclusive() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(2, ">", 50.0, false))
@Test
public void sortAndFilterMeasures() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(2, ">", 5.0, false))
@Test
public void sortDescendingAndFilterMeasures() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(2, ">", 5.0, false)) // filter on coverage
@Test
public void filterByResourceKey() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setKeyRegexp("*:org.sonar.*"));
assertSnapshotIds(result, 4);
}
@Test
public void filterByResourceKeyIsCaseInsensitive() {
setupData("shared");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
FilterResult result = executor.execute(Filter.createForAllQualifiers().setKeyRegexp("*:ORG.SonAR.*"));
assertSnapshotIds(result, 4);
}
@Test
public void filterByMissingMeasureValue() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(3, ">", 0.0, false)); // filter on duplicated lines
@Test
public void filterByMissingMeasureValues() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(1, ">", 0.0, false)) // filter on lines
@Test
public void sortByMissingMeasureValue() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.setSortedMetricId(3, true, false); // sort by duplicated lines
@Test
public void filterByMeasureValueAndSortOnOtherMetric() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(1, ">", 0.0, false)) // lines > 0
@Test
public void intersectionOfCriteriaOnSameMetric() {
setupData("shared", "measures");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.CLASS))
.addMeasureCriterion(new MeasureCriterion(1, ">", 400.0, false)) // lines > 400
@Test
public void ignoreProjectCopiesOfViews() {
setupData("views");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setQualifiers(Sets.newHashSet(Qualifiers.PROJECT));
@Test
public void loadProjectCopiesIfPathIsAView() {
setupData("views");
- FilterExecutor executor = new FilterExecutor(getSession(), new Derby());
+ FilterExecutor executor = new FilterExecutor(getSession(), new H2());
Filter filter = new Filter()
.setPath(2, 2, "")
.setQualifiers(Sets.newHashSet(Qualifiers.SUBVIEW, Qualifiers.PROJECT));
String sql = new FilterExecutor(getSession(), new MsSql()).toSql(filter);
assertThat(sql).contains(" WITH (INDEX(measures_sid_metric)) ");
- sql = new FilterExecutor(getSession(), new Derby()).toSql(filter);
+ sql = new FilterExecutor(getSession(), new H2()).toSql(filter);
assertThat(sql).doesNotContain(" WITH (INDEX(measures_sid_metric)) ");
}
-
private void assertSnapshotIds(FilterResult result, int... snapshotIds) {
assertThat(result.size()).isEqualTo(snapshotIds.length);
for (int snapshotId : snapshotIds) {
@Test
public void shouldIgnore() {
assertThat(BatchResourcesServlet.isIgnored("sonar-batch-2.6-SNAPSHOT.jar"), is(false));
- assertThat(BatchResourcesServlet.isIgnored("derby-10.6.1.0.jar"), is(true));
- assertThat(BatchResourcesServlet.isIgnored("derbyclient-10.6.1.0.jar"), is(true));
- assertThat(BatchResourcesServlet.isIgnored("derbynet-10.6.1.0.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("h2-1.3.166.jar"), is(true));
assertThat(BatchResourcesServlet.isIgnored("mysql-connector-java-5.1.13.jar"), is(true));
assertThat(BatchResourcesServlet.isIgnored("postgresql-9.0-801.jdbc3.jar"), is(true));
assertThat(BatchResourcesServlet.isIgnored("jtds-1.2.4.jar"), is(true));
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.dbunit</groupId>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar</artifactId>
+ <version>3.2-SNAPSHOT</version>
+ </parent>
+ <artifactId>sonar-web-test</artifactId>
+ <name>Sonar :: Web Test</name>
+ <description>Test of the web site</description>
+</project>