aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/220_update_events_table.rb34
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/221_attach_events_to_snapshots.rb44
-rw-r--r--sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl5
6 files changed, 83 insertions, 20 deletions
diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
index f9136489b25..5700b8e0ee0 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
@@ -42,7 +42,7 @@ public class SchemaMigration {
- complete the Derby DDL file used for unit tests : sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl
*/
- public static final int LAST_VERSION = 217;
+ public static final int LAST_VERSION = 220;
public final static String TABLE_NAME = "schema_migrations";
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java
index fa2263548d6..5a5a5404c8e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java
@@ -37,10 +37,10 @@ public class Event extends BaseIdentifiable {
public static final String CATEGORY_ALERT = "Alert";
public static final String CATEGORY_PROFILE = "Profile";
- @Column(name = "name", updatable = true, nullable = true, length = 50)
+ @Column(name = "name", updatable = true, nullable = true, length = 400)
private String name;
- @Column(name = "description", updatable = true, nullable = true, length = 3072)
+ @Column(name = "description", updatable = true, nullable = true, length = 4000)
private String description;
@Column(name = "category", updatable = true, nullable = true, length = 50)
@@ -59,9 +59,6 @@ public class Event extends BaseIdentifiable {
@Column(name = "resource_id", updatable = true, nullable = true)
private Integer resourceId;
- @Column(name = "data", updatable = true, nullable = true, length = 4000)
- private String data;
-
public Event() {
}
@@ -163,15 +160,6 @@ public class Event extends BaseIdentifiable {
return this;
}
- public String getData() {
- return data;
- }
-
- public Event setData(String data) {
- this.data = data;
- return this;
- }
-
@Override
public String toString() {
return new ToStringBuilder(this)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb
index 8f842296cb4..c41e6be51b2 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/events_controller.rb
@@ -210,7 +210,6 @@ class Api::EventsController < Api::ApiController
hash[:c]=event.category
hash[:dt]=Api::Utils.format_datetime(event.event_date) if event.event_date
hash[:ds]=event.description if event.description
- hash[:data]=event.data if event.data
hash
end
@@ -230,7 +229,6 @@ class Api::EventsController < Api::ApiController
xml.category(event.category)
xml.date(Api::Utils.format_datetime(event.event_date)) if event.event_date
xml.description(event.description) if event.description
- xml.data(event.data) if event.data
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/220_update_events_table.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/220_update_events_table.rb
new file mode 100644
index 00000000000..e765d5d3194
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/220_update_events_table.rb
@@ -0,0 +1,34 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 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
+#
+
+#
+# Sonar 2.12
+#
+class UpdateEventsTable < ActiveRecord::Migration
+
+ def self.up
+ remove_column :events, :data
+ change_column :events, :name, :string, :limit => 400, :null => true
+ change_column :events, :description, :string, :limit => 4000, :null => true
+
+ Event.reset_column_information
+ end
+
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/221_attach_events_to_snapshots.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/221_attach_events_to_snapshots.rb
new file mode 100644
index 00000000000..cbb7665d3f8
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/221_attach_events_to_snapshots.rb
@@ -0,0 +1,44 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 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
+#
+
+#
+# Sonar 2.12
+#
+class AttachEventsToSnapshots < ActiveRecord::Migration
+
+ def self.up
+ Event.find(:all, :conditions => "snapshot_id IS NULL").each do |event|
+ next_snapshot = Snapshot.find(:first, :conditions => ["created_at >= ? AND project_id = ?", event.event_date, event.resource_id], :order => :created_at)
+ if next_snapshot && (event.category!='Version' || !next_snapshot.event('Version'))
+ event.snapshot = next_snapshot
+ event.event_date = next_snapshot.created_at
+ event.save!
+ else
+ previous_snapshot = Snapshot.find(:last, :conditions => ["created_at <= ? AND project_id = ?", event.event_date, event.resource_id], :order => :created_at)
+ if previous_snapshot && (event.category!='Version' || !previous_snapshot.event('Version'))
+ event.snapshot = previous_snapshot
+ event.event_date = previous_snapshot.created_at
+ event.save!
+ end
+ end
+ end
+ end
+
+end
diff --git a/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl b/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl
index 7ebfd7cdd4e..7fa023eb3f2 100644
--- a/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl
+++ b/sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl
@@ -138,14 +138,13 @@ CREATE INDEX DEPS_TO_SID ON DEPENDENCIES (TO_SNAPSHOT_ID);
create table EVENTS (
ID INTEGER not null,
- NAME VARCHAR(50),
+ NAME VARCHAR(400),
RESOURCE_ID INTEGER,
SNAPSHOT_ID INTEGER,
CATEGORY VARCHAR(50),
EVENT_DATE TIMESTAMP,
CREATED_AT TIMESTAMP,
- DESCRIPTION VARCHAR(3072),
- DATA VARCHAR(4000),
+ DESCRIPTION VARCHAR(4000),
primary key (id)
);
CREATE INDEX EVENTS_RESOURCE_ID ON EVENTS (RESOURCE_ID);