diff options
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/config/environment.rb')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/config/environment.rb | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/config/environment.rb b/sonar-server/src/main/webapp/WEB-INF/config/environment.rb index 259de14ed11..98b97b52c8e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/config/environment.rb +++ b/sonar-server/src/main/webapp/WEB-INF/config/environment.rb @@ -126,7 +126,7 @@ class ActiveRecord::Migration change_column(tablename, columnname, :big_integer, :null => true) end end - + # SONAR-4178 def self.create_table(table_name, options = {}) super(table_name, options) @@ -137,12 +137,22 @@ class ActiveRecord::Migration # Do nothing end end - + + def drop_table(table_name, options = {}) + super(table_name, options) + case dialect() + when "oracle" + drop_id_trigger(table_name) + else + # Do nothing + end + end + def self.create_id_trigger(table) - execute_ddl("create trigger for table #{table}", - + execute_ddl("create trigger for table #{table}", + %{CREATE OR REPLACE TRIGGER #{table}_id_trg - BEFORE INSERT ON #{table} + BEFORE INSERT ON #{table} FOR EACH ROW BEGIN IF :new.id IS null THEN @@ -151,6 +161,21 @@ class ActiveRecord::Migration END;}) end + + def self.drop_id_trigger(table) + execute_ddl("drop trigger for table #{table}", + + %{DECLARE + e EXCEPTION; + PRAGMA EXCEPTION_INIT(e,-4080); + BEGIN + EXECUTE IMMEDIATE 'DROP TRIGGER #{table}_id_trg'; + EXCEPTION + WHEN e THEN + NULL; + END;}) + end + private def self.execute_ddl(message, ddl) @@ -192,4 +217,4 @@ DatabaseVersion.automatic_setup # Some changes have been done in activerecord-jdbc-adapter. Most of them relate to column types. # All these changes are prefixed by the comment #sonar # -#
\ No newline at end of file +# |