aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorXinhui2017-11-17 12:07:58 +0100
committerXinhui2017-11-17 12:09:42 +0100
commit1261698d213964a3391fe1880198da00e7ac9831 (patch)
treebae0b1a874a47fc36106dc5c33e66e9af182b503 /db/migrate
parentf677c08029ccb3b910ab6a2401fa56ccacb2b4d9 (diff)
parent219af774c2d589446133bda55aa0f001d6526181 (diff)
downloadchouette-core-1261698d213964a3391fe1880198da00e7ac9831.tar.bz2
Merge branch '4516_cleanup_rule_parameter_set'
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20150218175300_set_organisation_id_to_rps.rb13
-rw-r--r--db/migrate/20150219175300_insert_default_organisation.rb8
-rw-r--r--db/migrate/20171114102438_drop_table_rule_parameter_sets.rb5
3 files changed, 6 insertions, 20 deletions
diff --git a/db/migrate/20150218175300_set_organisation_id_to_rps.rb b/db/migrate/20150218175300_set_organisation_id_to_rps.rb
deleted file mode 100644
index 024f5938e..000000000
--- a/db/migrate/20150218175300_set_organisation_id_to_rps.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class SetOrganisationIdToRps < ActiveRecord::Migration
- def up
- RuleParameterSet.where(organisation_id: nil).update_all "name = concat(name, ' ', id)"
-
- # RuleParameterSet.joins(...).update_all("organisation_id = referentials.organisation_id")
- # fails (see https://github.com/rails/arel/pull/294)
- execute "UPDATE rule_parameter_sets SET organisation_id = referentials.organisation_id FROM referentials WHERE referentials.id = rule_parameter_sets.referential_id;"
- end
-
- def down
- RuleParameterSet.update_all organisation_id: nil
- end
-end
diff --git a/db/migrate/20150219175300_insert_default_organisation.rb b/db/migrate/20150219175300_insert_default_organisation.rb
index c8e97b562..2734893f5 100644
--- a/db/migrate/20150219175300_insert_default_organisation.rb
+++ b/db/migrate/20150219175300_insert_default_organisation.rb
@@ -1,10 +1,8 @@
class InsertDefaultOrganisation < ActiveRecord::Migration
class Organisation < ActiveRecord::Base
attr_accessor :name
-
- has_many :rule_parameter_sets, :dependent => :destroy
end
-
+
def up
organisation = Organisation.find_or_create_by!(:name => "Chouette")
Referential.where( :organisation_id => nil).each do |r|
@@ -13,10 +11,6 @@ class InsertDefaultOrganisation < ActiveRecord::Migration
User.where( :organisation_id => nil).each do |r|
r.update_attributes :organisation_id => organisation.id
end
- Organisation.all.each do |organisation|
- RuleParameterSet.default_for_all_modes( organisation).save if organisation.rule_parameter_sets.empty?
- end
-
end
def down
diff --git a/db/migrate/20171114102438_drop_table_rule_parameter_sets.rb b/db/migrate/20171114102438_drop_table_rule_parameter_sets.rb
new file mode 100644
index 000000000..55dfd32df
--- /dev/null
+++ b/db/migrate/20171114102438_drop_table_rule_parameter_sets.rb
@@ -0,0 +1,5 @@
+class DropTableRuleParameterSets < ActiveRecord::Migration
+ def change
+ drop_table :rule_parameter_sets
+ end
+end