aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorLuc Donnet2017-11-30 21:58:52 +0100
committerLuc Donnet2017-11-30 21:58:52 +0100
commit69a6bd72fecad790edab7e51e7d6df5ac1c7abba (patch)
treedc11c5b787d6f9059c36cc9be56e2b1fcb1c64b0 /db/migrate
parent3f5ac4764b859f97f776df565599e312b4584a03 (diff)
parent887a5985c6aba4ae65fbdd7c0c40f30186a778f2 (diff)
downloadchouette-core-69a6bd72fecad790edab7e51e7d6df5ac1c7abba.tar.bz2
Merge branch 'master' into 5093-fix_import_policy
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20171121142536_create_versions.rb34
-rw-r--r--db/migrate/20171121153506_remove_creator_id.rb11
-rw-r--r--db/migrate/20171121163631_remove_creator_from_compliance_check_sets.rb5
-rw-r--r--db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb10
-rw-r--r--db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb8
5 files changed, 68 insertions, 0 deletions
diff --git a/db/migrate/20171121142536_create_versions.rb b/db/migrate/20171121142536_create_versions.rb
new file mode 100644
index 000000000..ff794f9e1
--- /dev/null
+++ b/db/migrate/20171121142536_create_versions.rb
@@ -0,0 +1,34 @@
+class CreateVersions < ActiveRecord::Migration
+
+ # The largest text column available in all supported RDBMS is
+ # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
+ # so that MySQL will use `longtext` instead of `text`. Otherwise,
+ # when serializing very large objects, `text` might not be big enough.
+ TEXT_BYTES = 1_073_741_823
+
+ def change
+ create_table :versions do |t|
+ t.string :item_type, :null => false
+ t.integer :item_id, :null => false
+ t.string :event, :null => false
+ t.string :whodunnit
+ t.text :object, :limit => TEXT_BYTES
+
+ # Known issue in MySQL: fractional second precision
+ # -------------------------------------------------
+ #
+ # MySQL timestamp columns do not support fractional seconds unless
+ # defined with "fractional seconds precision". MySQL users should manually
+ # add fractional seconds precision to this migration, specifically, to
+ # the `created_at` column.
+ # (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)
+ #
+ # MySQL users should also upgrade to rails 4.2, which is the first
+ # version of ActiveRecord with support for fractional seconds in MySQL.
+ # (https://github.com/rails/rails/pull/14359)
+ #
+ t.datetime :created_at
+ end
+ add_index :versions, [:item_type, :item_id]
+ end
+end
diff --git a/db/migrate/20171121153506_remove_creator_id.rb b/db/migrate/20171121153506_remove_creator_id.rb
new file mode 100644
index 000000000..520941841
--- /dev/null
+++ b/db/migrate/20171121153506_remove_creator_id.rb
@@ -0,0 +1,11 @@
+class RemoveCreatorId < ActiveRecord::Migration
+ def change
+ [
+ 'companies', 'connection_links', 'facilities', 'group_of_lines',
+ 'journey_patterns', 'lines', 'networks', 'pt_links', 'routes', 'routing_constraint_zones',
+ 'stop_areas', 'stop_points', 'time_tables', 'timebands', 'vehicle_journeys', 'access_links', 'access_points'
+ ].each do |table_name|
+ remove_column table_name, :creator_id, :string
+ end
+ end
+end
diff --git a/db/migrate/20171121163631_remove_creator_from_compliance_check_sets.rb b/db/migrate/20171121163631_remove_creator_from_compliance_check_sets.rb
new file mode 100644
index 000000000..0798b2040
--- /dev/null
+++ b/db/migrate/20171121163631_remove_creator_from_compliance_check_sets.rb
@@ -0,0 +1,5 @@
+class RemoveCreatorFromComplianceCheckSets < ActiveRecord::Migration
+ def change
+ remove_column :compliance_check_sets, :creator, :string
+ end
+end
diff --git a/db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb b/db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb
new file mode 100644
index 000000000..ea94a01c1
--- /dev/null
+++ b/db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb
@@ -0,0 +1,10 @@
+class DeleteComplianceControlSetForeignKeyForComplianceCheckSet < ActiveRecord::Migration
+
+ def up
+ remove_foreign_key :compliance_check_sets, :compliance_control_sets
+ end
+
+ def down
+ add_foreign_key :compliance_check_sets, :compliance_control_sets
+ end
+end
diff --git a/db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb b/db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb
new file mode 100644
index 000000000..b1e6ca0a6
--- /dev/null
+++ b/db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb
@@ -0,0 +1,8 @@
+class ChangeItemIdInVersionsToBigint < ActiveRecord::Migration
+ def up
+ change_column :versions, :item_id, :integer, limit: 8, null: false
+ end
+ def down
+ change_column :versions, :item_id, :integer, null: false
+ end
+end