*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 411;
+ public static final int LAST_VERSION = 412;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
<mapper namespace="org.sonar.core.dashboard.ActiveDashboardMapper">
- <insert id="insert" parameterType="ActiveDashboard" useGeneratedKeys="true" keyProperty ="id">
+ <insert id="insert" parameterType="ActiveDashboard" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
INSERT INTO active_dashboards (dashboard_id, user_id, order_index)
VALUES (#{dashboardId}, #{userId}, #{orderIndex})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="ActiveDashboard" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id" >
- select active_dashboards_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO active_dashboards (id, dashboard_id, user_id, order_index)
- VALUES (#{id}, #{dashboardId}, #{userId}, #{orderIndex})
- </insert>
-
<select id="selectMaxOrderIndexForNullUser" resultType="Integer">
SELECT MAX(order_index)
FROM active_dashboards
from dashboards WHERE name=#{id} and user_id is null
</select>
- <insert id="insert" parameterType="Dashboard" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="Dashboard" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO dashboards (user_id, name, description, column_layout, shared, is_global, created_at, updated_at)
VALUES (#{userId}, #{name}, #{description},
#{columnLayout}, #{shared}, #{global}, #{createdAt}, #{updatedAt})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="Dashboard" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select dashboards_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO dashboards (id, user_id, name, description, column_layout, shared, is_global, created_at, updated_at)
- VALUES (#{id}, #{userId}, #{name}, #{description},
- #{columnLayout}, #{shared}, #{global}, #{createdAt}, #{updatedAt})
- </insert>
-
</mapper>
<mapper namespace="org.sonar.core.dashboard.WidgetMapper">
- <insert id="insert" parameterType="Widget" useGeneratedKeys="true" keyProperty ="id">
+ <insert id="insert" parameterType="Widget" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
INSERT INTO widgets (dashboard_id, widget_key, name, description, column_index, row_index, configured, created_at, updated_at, resource_id)
VALUES (#{dashboardId}, #{key}, #{name}, #{description}, #{columnIndex},
#{rowIndex}, #{configured}, #{createdAt}, #{updatedAt}, #{resourceId})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="Widget" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id" >
- select widgets_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO widgets (id, dashboard_id, widget_key, name, description, column_index, row_index, configured, created_at, updated_at, resource_id)
- VALUES (#{id}, #{dashboardId}, #{key}, #{name}, #{description}, #{columnIndex},
- #{rowIndex}, #{configured}, #{createdAt}, #{updatedAt}, #{resourceId})
- </insert>
-
</mapper>
<mapper namespace="org.sonar.core.dashboard.WidgetPropertyMapper">
- <insert id="insert" parameterType="WidgetProperty" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="WidgetProperty" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO widget_properties (widget_id, kee, text_value)
VALUES (#{widgetId}, #{key}, #{value})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="WidgetProperty" keyColumn="id" useGeneratedKeys="false" keyProperty="id">
- INSERT INTO widget_properties (id, widget_id, kee, text_value)
- VALUES (widget_properties_seq.NEXTVAL, #{widgetId}, #{key}, #{value})
- </insert>
-
</mapper>
INSERT INTO duplications_index (snapshot_id, project_snapshot_id, hash, index_in_file, start_line, end_line)
VALUES (#{snapshotId}, #{projectSnapshotId}, #{hash}, #{indexInFile}, #{startLine}, #{endLine})
</insert>
-
- <!-- Oracle -->
- <insert id="batchInsert" databaseId="oracle" parameterType="DuplicationUnit" useGeneratedKeys="false">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select duplications_index_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO duplications_index (id, snapshot_id, project_snapshot_id, hash, index_in_file, start_line, end_line)
- VALUES (#{id}, #{snapshotId}, #{projectSnapshotId}, #{hash}, #{indexInFile}, #{startLine}, #{endLine})
- </insert>
</mapper>
#{data}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="Graph" useGeneratedKeys="false" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select graphs_seq.NEXTVAL from DUAL
- </selectKey>
- insert into graphs
- (id, resource_id, snapshot_id, format, version, perspective, root_vertex_id, data, created_at, updated_at)
- values (
- #{id}, #{resourceId}, #{snapshotId}, #{format}, #{version}, #{perspective}, #{rootVertexId},
- #{data}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
- </insert>
</mapper>
p.kee as projectKey
</sql>
- <insert id="insert" parameterType="ActionPlanIssue" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="ActionPlanIssue" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO action_plans (kee, name, description, user_login, project_id, status, deadline, created_at, updated_at)
VALUES (#{kee}, #{name}, #{description}, #{userLogin}, #{projectId}, #{status}, #{deadLine}, #{createdAt}, #{updatedAt})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="ActionPlanIssue" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select issues_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO action_plans (id, kee, name, description, user_login, project_id, status, deadline, created_at, updated_at)
- VALUES (#{id}, #{kee}, #{name}, #{description}, #{userLogin}, #{projectId}, #{status}, #{deadLine}, #{createdAt}, #{updatedAt})
- </insert>
-
<update id="update" parameterType="ActionPlanIssue">
update action_plans set
name=#{name},
VALUES (#{kee}, #{issueKey}, #{userLogin}, #{changeType}, #{changeData}, #{createdAt}, #{updatedAt})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="IssueChange" keyColumn="id" useGeneratedKeys="false"
- keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select issue_changes_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO issue_changes (id, kee, issue_key, user_login, change_type, change_data, created_at, updated_at)
- VALUES (#{id}, #{kee}, #{issueKey}, #{userLogin}, #{changeType}, #{changeData}, #{createdAt}, #{updatedAt})
- </insert>
-
<delete id="delete" parameterType="string">
delete from issue_changes where kee=#{id}
</delete>
</where>
</select>
- <insert id="insert" parameterType="issueFilterFavourite" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="issueFilterFavourite" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO issue_filter_favourites (user_login, issue_filter_id, created_at)
VALUES (#{userLogin}, #{issueFilterId}, current_timestamp)
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="issueFilterFavourite" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select issue_filter_favourites_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO issue_filter_favourites (id, user_login, issue_filter_id, created_at)
- VALUES (#{id},#{userLogin}, #{issueFilterId}, current_timestamp)
- </insert>
-
<delete id="delete" parameterType="int">
delete from issue_filter_favourites where id=#{id}
</delete>
</where>
</select>
- <insert id="insert" parameterType="IssueFilter" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="IssueFilter" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO issue_filters (name, user_login, shared, description, data, created_at, updated_at)
VALUES (#{name}, #{userLogin}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="IssueFilter" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select issue_filters_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO issue_filters (id, name, user_login, shared, description, data, created_at, updated_at)
- VALUES (#{id}, #{name}, #{userLogin}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
- </insert>
-
<update id="update" parameterType="IssueFilter">
update issue_filters set
name=#{name},
#{issueUpdateDate}, #{issueCloseDate}, #{createdAt}, #{updatedAt})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="Issue" keyColumn="id" useGeneratedKeys="false"
- keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select issues_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO issues (id, kee, component_id, root_component_id, rule_id, action_plan_key, severity, manual_severity,
- message, line, effort_to_fix, status,
- resolution, checksum, reporter, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
- issue_close_date, created_at, updated_at)
- VALUES (#{id}, #{kee}, #{componentId}, #{rootComponentId}, #{ruleId}, #{actionPlanKey}, #{severity}, #{manualSeverity},
- #{message}, #{line}, #{effortToFix}, #{status},
- #{resolution}, #{checksum}, #{reporter}, #{assignee}, #{authorLogin}, #{issueAttributes}, #{issueCreationDate},
- #{issueUpdateDate}, #{issueCloseDate}, #{createdAt}, #{updatedAt})
- </insert>
-
<!--
IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
-->
from measure_filters WHERE user_id is null and name=#{id}
</select>
- <insert id="insert" parameterType="MeasureFilter" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="MeasureFilter" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO measure_filters (name, user_id, shared, description, data, created_at, updated_at)
VALUES (#{name}, #{userId}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="MeasureFilter" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select measure_filters_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO measure_filters (id, name, user_id, shared, description, data, created_at, updated_at)
- VALUES (#{id}, #{name}, #{userId}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
- </insert>
-
</mapper>
VALUES (#{name}, #{checksum}, current_timestamp, current_timestamp, #{lockedAt})
</insert>
- <insert id="initialize" databaseId="oracle" parameterType="map" useGeneratedKeys="false">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select semaphores_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO semaphores (id, name, checksum, created_at, updated_at, locked_at)
- VALUES (#{id}, #{name}, #{checksum}, current_timestamp, current_timestamp, #{lockedAt})
- </insert>
-
<select id="now" resultType="Date">
select current_timestamp
</select>
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('405');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('410');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('411');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('412');
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;
VALUES (#{key}, #{resourceId}, #{userId}, #{value})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="Property" useGeneratedKeys="false">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select properties_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO properties (id, prop_key, resource_id, user_id, text_value)
- VALUES (#{id}, #{key}, #{resourceId}, #{userId}, #{value})
- </insert>
-
<delete id="deleteGlobalProperty" parameterType="string">
delete from properties where prop_key=#{id} and resource_id is null and user_id is null
</delete>
#{resourceId}, #{rootProjectId}, #{qualifier})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="ResourceIndex" useGeneratedKeys="false">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select resource_index_seq.NEXTVAL from DUAL
- </selectKey>
- insert into resource_index (id, kee, position, name_size, resource_id, root_project_id, qualifier)
- values (#{id}, #{key}, #{position}, #{nameSize},
- #{resourceId}, #{rootProjectId}, #{qualifier})
- </insert>
-
</mapper>
</where>
</sql>
- <insert id="insert" parameterType="Resource" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="Resource" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
insert into projects
(name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, enabled, created_at)
values (
)
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="Resource" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select projects_seq.NEXTVAL from DUAL
- </selectKey>
- insert into projects
- (id, name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, enabled, created_at)
- values (
- #{id}, #{name}, #{longName}, #{description}, #{scope}, #{qualifier},
- #{key}, #{language}, #{rootId}, #{copyResourceId},
- #{personId}, #{enabled}, #{createdAt}
- )
- </insert>
-
<update id="update" parameterType="Resource">
update projects set name=#{name}, long_name=#{longName}, description=#{description},
scope=#{scope}, qualifier=#{qualifier}, kee=#{key},
values (
#{resourceId}, #{snapshotId}, #{data}, #{dataType}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
</insert>
-
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="SnapshotData" useGeneratedKeys="false" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select snapshot_data_seq.NEXTVAL from DUAL
- </selectKey>
- insert into snapshot_data
- (id, resource_id, snapshot_id, snapshot_data, data_type, created_at, updated_at)
- values (
- #{id}, #{resourceId}, #{snapshotId}, #{data}, #{dataType}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
- </insert>
</mapper>
WHERE kee = #{key} AND template_type = #{type}
</select>
- <insert id="insert" parameterType="LoadedTemplate" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="LoadedTemplate" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO loaded_templates (kee, template_type)
VALUES (#{key}, #{type})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="LoadedTemplate" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select loaded_templates_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO loaded_templates (id, kee, template_type)
- VALUES (#{id}, #{key}, #{type})
- </insert>
-
</mapper>
FROM authors WHERE person_id=#{id}
</select>
- <insert id="insert" parameterType="Author" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="Author" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO authors (person_id, login, created_at, updated_at)
VALUES (#{personId}, #{login},
#{createdAt}, #{updatedAt})
</insert>
- <!-- Oracle -->
- <insert id="insert" databaseId="oracle" parameterType="Author" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select authors_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO authors (id, person_id, login, created_at, updated_at)
- VALUES (#{id}, #{personId}, #{login},
- #{createdAt}, #{updatedAt})
- </insert>
-
</mapper>
<mapper namespace="org.sonar.core.user.RoleMapper">
- <insert id="insertGroupRole" parameterType="GroupRole" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insertGroupRole" parameterType="GroupRole" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO group_roles (group_id, resource_id, role)
VALUES (#{groupId}, #{resourceId}, #{role})
</insert>
- <!-- Oracle -->
- <insert id="insertGroupRole" databaseId="oracle" parameterType="GroupRole" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select group_roles_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO group_roles (id, group_id, resource_id, role)
- VALUES (#{id}, #{groupId}, #{resourceId}, #{role})
- </insert>
-
- <insert id="insertUserRole" parameterType="UserRole" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insertUserRole" parameterType="UserRole" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO user_roles (user_id, resource_id, role)
VALUES (#{userId}, #{resourceId}, #{role})
</insert>
- <!-- Oracle -->
- <insert id="insertUserRole" databaseId="oracle" parameterType="UserRole" useGeneratedKeys="true" keyProperty="id">
- <selectKey order="BEFORE" resultType="Long" keyProperty="id">
- select user_roles_seq.NEXTVAL from DUAL
- </selectKey>
- INSERT INTO user_roles (id, user_id, resource_id, role)
- VALUES (#{id}, #{userId}, #{resourceId}, #{role})
- </insert>
-
<delete id="deleteGroupRole" parameterType="map">
delete from group_roles where resource_id=#{resourceId} and role=#{role}
<choose>
<mapper namespace="org.sonar.api.database.model.MeasureMapper">
- <insert id="insert" parameterType="MeasureModel" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insert" parameterType="MeasureModel" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO project_measures (
value, metric_id, snapshot_id, rule_id, text_value, tendency, measure_date,
project_id, alert_status, alert_text, url, description, rule_priority, characteristic_id, variation_value_1,
)
</insert>
- <insert id="insertData" parameterType="MeasureData" useGeneratedKeys="true" keyProperty="id">
+ <insert id="insertData" parameterType="MeasureData" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO measure_data (measure_id, snapshot_id, data)
VALUES (#{measure.id}, #{measure.snapshotId}, #{data})
</insert>
WHERE id = #{id}
</update>
- <!-- ORACLE -->
- <insert id="insert" databaseId="oracle" parameterType="MeasureModel" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO project_measures (
- id,
- value, metric_id, snapshot_id, rule_id, text_value, tendency, measure_date,
- project_id, alert_status, alert_text, url, description, rule_priority, characteristic_id, variation_value_1,
- variation_value_2, variation_value_3, variation_value_4, variation_value_5, person_id)
- VALUES (
- project_measures_seq.NEXTVAL,
- #{value}, #{metricId}, #{snapshotId}, #{ruleId}, #{textValue}, #{tendency},
- #{measureDate}, #{projectId}, #{alertStatus}, #{alertText},
- #{url}, #{description}, #{rulePriority.ordinal}, #{characteristic.id}, #{variationValue1},
- #{variationValue2}, #{variationValue3}, #{variationValue4}, #{variationValue5}, #{personId}
- )
- </insert>
-
- <insert id="insertData" databaseId="oracle" parameterType="MeasureData" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO measure_data (id, measure_id, snapshot_id, data)
- VALUES (measure_data_seq.NEXTVAL, #{measure.id}, #{measure.snapshotId}, #{data})
- </insert>
-
</mapper>
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+#
+# Sonar 3.6
+# SONAR-3340
+class AddOracleIdTriggers < ActiveRecord::Migration
+
+
+ def self.up
+ case dialect()
+ when "oracle"
+ upgrade_oracle()
+ else
+ # Do nothing
+ end
+ end
+
+ private
+
+ def self.upgrade_oracle
+ create_id_trigger('action_plans')
+ create_id_trigger('active_dashboards')
+ create_id_trigger('active_rule_changes')
+ create_id_trigger('active_rule_notes')
+ create_id_trigger('active_rule_param_changes')
+ create_id_trigger('active_rule_parameters')
+ create_id_trigger('active_rules')
+ create_id_trigger('alerts')
+ create_id_trigger('authors')
+ create_id_trigger('characteristic_properties')
+ create_id_trigger('characteristics')
+ create_id_trigger('dashboards')
+ create_id_trigger('dependencies')
+ create_id_trigger('duplications_index')
+ create_id_trigger('events')
+ create_id_trigger('graphs')
+ create_id_trigger('group_roles')
+ create_id_trigger('groups')
+ create_id_trigger('groups_users')
+ create_id_trigger('issue_changes')
+ create_id_trigger('issue_filter_favourites')
+ create_id_trigger('issue_filters')
+ create_id_trigger('issues')
+ create_id_trigger('loaded_templates')
+ create_id_trigger('manual_measures')
+ create_id_trigger('measure_data')
+ create_id_trigger('measure_filter_favourites')
+ create_id_trigger('measure_filters')
+ create_id_trigger('metrics')
+ create_id_trigger('notifications')
+ create_id_trigger('project_links')
+ create_id_trigger('project_measures')
+ create_id_trigger('projects')
+ create_id_trigger('properties')
+ create_id_trigger('quality_models')
+ create_id_trigger('resource_index')
+ create_id_trigger('rule_notes')
+ create_id_trigger('rules')
+ create_id_trigger('rules_parameters')
+ create_id_trigger('rules_profiles')
+ create_id_trigger('semaphores')
+ create_id_trigger('snapshot_data')
+ create_id_trigger('snapshot_sources')
+ create_id_trigger('snapshots')
+ create_id_trigger('user_roles')
+ create_id_trigger('users')
+ create_id_trigger('widget_properties')
+ create_id_trigger('widgets')
+ end
+
+ def self.create_id_trigger(table)
+ execute_ddl('create trigger for table ' + table,
+
+ %{CREATE OR REPLACE TRIGGER #{table}_id_trg
+ BEFORE INSERT ON #{table}
+ FOR EACH ROW
+ BEGIN
+ IF :new.id IS null THEN
+ SELECT #{table}_seq.nextval INTO :new.id FROM dual;
+ END IF;
+ END;})
+ end
+
+ def self.execute_ddl(message, ddl)
+ begin
+ say_with_time(message) do
+ ActiveRecord::Base.connection.execute(ddl)
+ end
+ rescue
+ # already executed
+ end
+ end
+
+end
+