From 8aa230271ec6f0cd578e479c42d95418cb9408c3 Mon Sep 17 00:00:00 2001 From: Xinhui Date: Tue, 21 Nov 2017 15:27:17 +0100 Subject: Add gem paper_trail --- db/migrate/20171121142536_create_versions.rb | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 db/migrate/20171121142536_create_versions.rb (limited to 'db') 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 -- cgit v1.2.3 From d67ff84efc39190c8b3eb4a05a461a330198a5cd Mon Sep 17 00:00:00 2001 From: Xinhui Date: Tue, 21 Nov 2017 17:35:35 +0100 Subject: Remove creator_id column --- db/migrate/20171121153506_remove_creator_id.rb | 11 ++++++++ db/schema.rb | 38 ++++++++++---------------- 2 files changed, 25 insertions(+), 24 deletions(-) create mode 100644 db/migrate/20171121153506_remove_creator_id.rb (limited to 'db') diff --git a/db/migrate/20171121153506_remove_creator_id.rb b/db/migrate/20171121153506_remove_creator_id.rb new file mode 100644 index 000000000..84be06027 --- /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 + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 349d8e5eb..f861eae1f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171123110204) do +ActiveRecord::Schema.define(version: 20171121153506) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -23,7 +23,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "stop_area_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.decimal "link_distance", precision: 19, scale: 2 @@ -46,7 +45,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "access_points", id: :bigserial, force: :cascade do |t| t.string "objectid" t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.decimal "longitude", precision: 19, scale: 16 @@ -123,7 +121,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "companies", id: :bigserial, force: :cascade do |t| t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "short_name" t.string "organizational_unit" @@ -265,7 +262,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "arrival_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.decimal "link_distance", precision: 19, scale: 2 @@ -305,7 +301,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.string "objectid", null: false t.integer "object_version", limit: 8 t.datetime "creation_time" - t.string "creator_id" t.string "name" t.string "comment" t.string "description" @@ -347,7 +342,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "group_of_lines", id: :bigserial, force: :cascade do |t| t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.string "registration_number" @@ -408,9 +402,9 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.string "type" t.integer "parent_id", limit: 8 t.string "parent_type" + t.datetime "notified_parent_at" t.integer "current_step", default: 0 t.integer "total_steps", default: 0 - t.datetime "notified_parent_at" t.string "creator" end @@ -435,7 +429,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "route_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.string "registration_number" @@ -491,8 +484,7 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.string "name" t.datetime "created_at" t.datetime "updated_at" - t.integer "sync_interval", default: 1 - t.string "objectid_format" + t.integer "sync_interval", default: 1 end create_table "lines", id: :bigserial, force: :cascade do |t| @@ -500,7 +492,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "company_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "number" t.string "published_name" @@ -532,7 +523,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "networks", id: :bigserial, force: :cascade do |t| t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.date "version_date" t.string "description" t.string "name" @@ -570,7 +560,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "route_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.decimal "link_distance", precision: 19, scale: 2 @@ -637,7 +626,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "created_from_id", limit: 8 t.boolean "ready", default: false t.integer "referential_suite_id", limit: 8 - t.string "objectid_format" end add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree @@ -647,7 +635,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "line_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.integer "opposite_route_id", limit: 8 @@ -670,7 +657,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.datetime "updated_at" t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.integer "route_id", limit: 8 t.integer "stop_point_ids", limit: 8, array: true t.string "checksum" @@ -715,14 +701,12 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.string "name" t.datetime "created_at" t.datetime "updated_at" - t.string "objectid_format" end create_table "stop_areas", id: :bigserial, force: :cascade do |t| t.integer "parent_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.string "comment" t.string "area_type" @@ -766,7 +750,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "stop_area_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.integer "position" t.string "for_boarding" t.string "for_alighting" @@ -821,7 +804,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "time_tables", id: :bigserial, force: :cascade do |t| t.string "objectid", null: false t.integer "object_version", limit: 8, default: 1 - t.string "creator_id" t.string "version" t.string "comment" t.integer "int_day_types", default: 0 @@ -852,7 +834,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "timebands", id: :bigserial, force: :cascade do |t| t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "name" t.time "start_time", null: false t.time "end_time", null: false @@ -924,7 +905,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "company_id", limit: 8 t.string "objectid", null: false t.integer "object_version", limit: 8 - t.string "creator_id" t.string "comment" t.string "status_value" t.string "transport_mode" @@ -946,6 +926,17 @@ ActiveRecord::Schema.define(version: 20171123110204) do add_index "vehicle_journeys", ["objectid"], name: "vehicle_journeys_objectid_key", unique: true, using: :btree add_index "vehicle_journeys", ["route_id"], name: "index_vehicle_journeys_on_route_id", using: :btree + create_table "versions", id: :bigserial, force: :cascade 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" + t.datetime "created_at" + end + + add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree + create_table "workbenches", id: :bigserial, force: :cascade do |t| t.string "name" t.integer "organisation_id", limit: 8 @@ -954,7 +945,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.integer "line_referential_id", limit: 8 t.integer "stop_area_referential_id", limit: 8 t.integer "output_id", limit: 8 - t.string "objectid_format" end add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree -- cgit v1.2.3 From 1e54a61308a8bbb9ad9d63341a4c9d817f414026 Mon Sep 17 00:00:00 2001 From: Xinhui Date: Tue, 21 Nov 2017 17:39:56 +0100 Subject: Remove column creator --- .../20171121163631_remove_creator_from_compliance_check_sets.rb | 5 +++++ db/migrate/20171121163832_remove_creator_from_imports.rb | 5 +++++ db/schema.rb | 4 +--- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20171121163631_remove_creator_from_compliance_check_sets.rb create mode 100644 db/migrate/20171121163832_remove_creator_from_imports.rb (limited to 'db') 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..0e8179ea5 --- /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 + end +end diff --git a/db/migrate/20171121163832_remove_creator_from_imports.rb b/db/migrate/20171121163832_remove_creator_from_imports.rb new file mode 100644 index 000000000..d672c491e --- /dev/null +++ b/db/migrate/20171121163832_remove_creator_from_imports.rb @@ -0,0 +1,5 @@ +class RemoveCreatorFromImports < ActiveRecord::Migration + def change + remove_column :imports, :creator + end +end diff --git a/db/schema.rb b/db/schema.rb index f861eae1f..0577025ba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171121153506) do +ActiveRecord::Schema.define(version: 20171121163832) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -185,7 +185,6 @@ ActiveRecord::Schema.define(version: 20171121153506) do t.integer "referential_id", limit: 8 t.integer "compliance_control_set_id", limit: 8 t.integer "workbench_id", limit: 8 - t.string "creator" t.string "status" t.integer "parent_id", limit: 8 t.string "parent_type" @@ -405,7 +404,6 @@ ActiveRecord::Schema.define(version: 20171121153506) do t.datetime "notified_parent_at" t.integer "current_step", default: 0 t.integer "total_steps", default: 0 - t.string "creator" end add_index "imports", ["referential_id"], name: "index_imports_on_referential_id", using: :btree -- cgit v1.2.3 From 4792a04f83f5a52757092e5b66f6d27f658c3c6b Mon Sep 17 00:00:00 2001 From: Xinhui Date: Wed, 22 Nov 2017 14:34:05 +0100 Subject: Refactoring move referentialSupport from chouetteController into childrens --- db/migrate/20171121153506_remove_creator_id.rb | 2 +- .../20171121163631_remove_creator_from_compliance_check_sets.rb | 2 +- db/migrate/20171121163832_remove_creator_from_imports.rb | 5 ----- db/schema.rb | 3 ++- 4 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 db/migrate/20171121163832_remove_creator_from_imports.rb (limited to 'db') diff --git a/db/migrate/20171121153506_remove_creator_id.rb b/db/migrate/20171121153506_remove_creator_id.rb index 84be06027..520941841 100644 --- a/db/migrate/20171121153506_remove_creator_id.rb +++ b/db/migrate/20171121153506_remove_creator_id.rb @@ -5,7 +5,7 @@ class RemoveCreatorId < ActiveRecord::Migration '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 + 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 index 0e8179ea5..0798b2040 100644 --- a/db/migrate/20171121163631_remove_creator_from_compliance_check_sets.rb +++ b/db/migrate/20171121163631_remove_creator_from_compliance_check_sets.rb @@ -1,5 +1,5 @@ class RemoveCreatorFromComplianceCheckSets < ActiveRecord::Migration def change - remove_column :compliance_check_sets, :creator + remove_column :compliance_check_sets, :creator, :string end end diff --git a/db/migrate/20171121163832_remove_creator_from_imports.rb b/db/migrate/20171121163832_remove_creator_from_imports.rb deleted file mode 100644 index d672c491e..000000000 --- a/db/migrate/20171121163832_remove_creator_from_imports.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveCreatorFromImports < ActiveRecord::Migration - def change - remove_column :imports, :creator - end -end diff --git a/db/schema.rb b/db/schema.rb index 0577025ba..3f2638a76 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171121163832) do +ActiveRecord::Schema.define(version: 20171121163631) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -404,6 +404,7 @@ ActiveRecord::Schema.define(version: 20171121163832) do t.datetime "notified_parent_at" t.integer "current_step", default: 0 t.integer "total_steps", default: 0 + t.string "creator" end add_index "imports", ["referential_id"], name: "index_imports_on_referential_id", using: :btree -- cgit v1.2.3 From bc7888297ae545ae3c453c5c9481d22b37a0dad4 Mon Sep 17 00:00:00 2001 From: Xinhui Date: Wed, 22 Nov 2017 14:58:06 +0100 Subject: Fix bigint spec --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 3f2638a76..c5e051a03 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -927,7 +927,7 @@ ActiveRecord::Schema.define(version: 20171121163631) do create_table "versions", id: :bigserial, force: :cascade do |t| t.string "item_type", null: false - t.integer "item_id", null: false + t.integer "item_id", null: false, limit: 8 t.string "event", null: false t.string "whodunnit" t.text "object" -- cgit v1.2.3 From fb7ad0e23e73954e6e5d172d61edb31cd686b8b4 Mon Sep 17 00:00:00 2001 From: Xinhui Date: Tue, 28 Nov 2017 15:19:22 +0100 Subject: Fix schema conflit after merge PR #127 --- db/schema.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index c5e051a03..9e9823d77 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171121163631) do +ActiveRecord::Schema.define(version: 20171123110204) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -483,7 +483,8 @@ ActiveRecord::Schema.define(version: 20171121163631) do t.string "name" t.datetime "created_at" t.datetime "updated_at" - t.integer "sync_interval", default: 1 + t.integer "sync_interval", default: 1 + t.string "objectid_format" end create_table "lines", id: :bigserial, force: :cascade do |t| @@ -625,6 +626,7 @@ ActiveRecord::Schema.define(version: 20171121163631) do t.integer "created_from_id", limit: 8 t.boolean "ready", default: false t.integer "referential_suite_id", limit: 8 + t.string "objectid_format" end add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree @@ -700,6 +702,7 @@ ActiveRecord::Schema.define(version: 20171121163631) do t.string "name" t.datetime "created_at" t.datetime "updated_at" + t.string "objectid_format" end create_table "stop_areas", id: :bigserial, force: :cascade do |t| @@ -927,7 +930,7 @@ ActiveRecord::Schema.define(version: 20171121163631) do create_table "versions", id: :bigserial, force: :cascade do |t| t.string "item_type", null: false - t.integer "item_id", null: false, limit: 8 + t.integer "item_id", null: false t.string "event", null: false t.string "whodunnit" t.text "object" @@ -944,6 +947,7 @@ ActiveRecord::Schema.define(version: 20171121163631) do t.integer "line_referential_id", limit: 8 t.integer "stop_area_referential_id", limit: 8 t.integer "output_id", limit: 8 + t.string "objectid_format" end add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree -- cgit v1.2.3 From 014b8e26c519630532902c47b9a64ca7ae25c6b1 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 30 Nov 2017 11:18:05 +0100 Subject: db schema added --- db/schema.rb | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 349d8e5eb..d482f44f0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -284,6 +284,22 @@ ActiveRecord::Schema.define(version: 20171123110204) do add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree + create_table "delayed_jobs", id: :bigserial, force: :cascade do |t| + t.integer "priority", default: 0 + t.integer "attempts", default: 0 + t.text "handler" + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by", limit: 255 + t.string "queue", limit: 255 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree + create_table "exports", id: :bigserial, force: :cascade do |t| t.integer "referential_id", limit: 8 t.string "status" @@ -405,11 +421,11 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.datetime "started_at" t.datetime "ended_at" t.string "token_download" - t.string "type" + t.string "type", limit: 255 t.integer "parent_id", limit: 8 t.string "parent_type" - t.integer "current_step", default: 0 - t.integer "total_steps", default: 0 + t.integer "current_step", default: 0 + t.integer "total_steps", default: 0 t.datetime "notified_parent_at" t.string "creator" end @@ -551,6 +567,11 @@ ActiveRecord::Schema.define(version: 20171123110204) do add_index "networks", ["objectid"], name: "networks_objectid_key", unique: true, using: :btree add_index "networks", ["registration_number"], name: "networks_registration_number_key", using: :btree + create_table "object_id_factories", id: :bigserial, force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "organisations", id: :bigserial, force: :cascade do |t| t.string "name" t.datetime "created_at" @@ -720,7 +741,7 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "stop_areas", id: :bigserial, force: :cascade do |t| t.integer "parent_id", limit: 8 - t.string "objectid", null: false + t.string "objectid", null: false t.integer "object_version", limit: 8 t.string "creator_id" t.string "name" @@ -729,8 +750,8 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.string "registration_number" t.string "nearest_topic_name" t.integer "fare_code" - t.decimal "longitude", precision: 19, scale: 16 - t.decimal "latitude", precision: 19, scale: 16 + t.decimal "longitude", precision: 19, scale: 16 + t.decimal "latitude", precision: 19, scale: 16 t.string "long_lat_type" t.string "country_code" t.string "street_name" @@ -748,7 +769,7 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.datetime "deleted_at" t.datetime "created_at" t.datetime "updated_at" - t.string "stif_type" + t.string "stif_type", limit: 255 end add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree @@ -819,18 +840,18 @@ ActiveRecord::Schema.define(version: 20171123110204) do add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree create_table "time_tables", id: :bigserial, force: :cascade do |t| - t.string "objectid", null: false - t.integer "object_version", limit: 8, default: 1 + t.string "objectid", null: false + t.integer "object_version", limit: 8, default: 1 t.string "creator_id" t.string "version" t.string "comment" - t.integer "int_day_types", default: 0 + t.integer "int_day_types", default: 0 t.date "start_date" t.date "end_date" t.integer "calendar_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" - t.string "color" + t.string "color", limit: 255 t.integer "created_from_id", limit: 8 t.string "checksum" t.text "checksum_source" @@ -978,7 +999,9 @@ ActiveRecord::Schema.define(version: 20171123110204) do add_foreign_key "compliance_controls", "compliance_control_blocks" add_foreign_key "compliance_controls", "compliance_control_sets" add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", on_delete: :cascade + add_foreign_key "journey_frequencies", "timebands", name: "journey_frequencies_timeband_id_fk", on_delete: :nullify add_foreign_key "journey_frequencies", "timebands", on_delete: :nullify + add_foreign_key "journey_frequencies", "vehicle_journeys", name: "journey_frequencies_vehicle_journey_id_fk", on_delete: :nullify add_foreign_key "journey_frequencies", "vehicle_journeys", on_delete: :nullify add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", on_delete: :cascade add_foreign_key "journey_patterns", "stop_points", column: "arrival_stop_point_id", name: "arrival_point_fkey", on_delete: :nullify -- cgit v1.2.3 From 9fe05b985b92381e876cfd692985d2c7aec8b8ab Mon Sep 17 00:00:00 2001 From: Xinhui Date: Thu, 30 Nov 2017 11:22:30 +0100 Subject: Fix db/schema_spec interger must be bigint --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 9e9823d77..323d68509 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -930,7 +930,7 @@ ActiveRecord::Schema.define(version: 20171123110204) do create_table "versions", id: :bigserial, force: :cascade do |t| t.string "item_type", null: false - t.integer "item_id", null: false + t.integer "item_id", null: false, limit: 8 t.string "event", null: false t.string "whodunnit" t.text "object" -- cgit v1.2.3 From a2896b1db4db22eef587c2ae801c7a0d393c729f Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 30 Nov 2017 18:33:36 +0100 Subject: Fixes: #5130@0.5h; Spec added, migration added --- ...rol_set_foreign_key_for_compliance_check_set.rb | 10 + db/schema.rb | 1016 ++++++++++++++++++++ 2 files changed, 1026 insertions(+) create mode 100644 db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb (limited to 'db') 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/schema.rb b/db/schema.rb index e69de29bb..af22672c6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -0,0 +1,1016 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20171130172926) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + enable_extension "postgis" + enable_extension "hstore" + + create_table "access_links", id: :bigserial, force: :cascade do |t| + t.integer "access_point_id", limit: 8 + t.integer "stop_area_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.decimal "link_distance", precision: 19, scale: 2 + t.boolean "lift_availability" + t.boolean "mobility_restricted_suitability" + t.boolean "stairs_availability" + t.time "default_duration" + t.time "frequent_traveller_duration" + t.time "occasional_traveller_duration" + t.time "mobility_restricted_traveller_duration" + t.string "link_type" + t.integer "int_user_needs" + t.string "link_orientation" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "access_links", ["objectid"], name: "access_links_objectid_key", unique: true, using: :btree + + create_table "access_points", id: :bigserial, force: :cascade do |t| + t.string "objectid" + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.decimal "longitude", precision: 19, scale: 16 + t.decimal "latitude", precision: 19, scale: 16 + t.string "long_lat_type" + t.string "country_code" + t.string "street_name" + t.string "contained_in" + t.time "openning_time" + t.time "closing_time" + t.string "access_type" + t.boolean "lift_availability" + t.boolean "mobility_restricted_suitability" + t.boolean "stairs_availability" + t.integer "stop_area_id", limit: 8 + t.string "zip_code" + t.string "city_name" + t.text "import_xml" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "access_points", ["objectid"], name: "access_points_objectid_key", unique: true, using: :btree + + create_table "api_keys", id: :bigserial, force: :cascade do |t| + t.integer "referential_id", limit: 8 + t.string "token" + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "organisation_id", limit: 8 + end + + add_index "api_keys", ["organisation_id"], name: "index_api_keys_on_organisation_id", using: :btree + + create_table "calendars", id: :bigserial, force: :cascade do |t| + t.string "name" + t.string "short_name" + t.daterange "date_ranges", array: true + t.date "dates", array: true + t.boolean "shared", default: false + t.integer "organisation_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "calendars", ["organisation_id"], name: "index_calendars_on_organisation_id", using: :btree + add_index "calendars", ["short_name"], name: "index_calendars_on_short_name", unique: true, using: :btree + + create_table "clean_up_results", id: :bigserial, force: :cascade do |t| + t.string "message_key" + t.hstore "message_attributs" + t.integer "clean_up_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "clean_up_results", ["clean_up_id"], name: "index_clean_up_results_on_clean_up_id", using: :btree + + create_table "clean_ups", id: :bigserial, force: :cascade do |t| + t.string "status" + t.datetime "started_at" + t.datetime "ended_at" + t.integer "referential_id", limit: 8 + t.date "begin_date" + t.datetime "created_at" + t.datetime "updated_at" + t.date "end_date" + t.string "date_type" + end + + add_index "clean_ups", ["referential_id"], name: "index_clean_ups_on_referential_id", using: :btree + + create_table "companies", id: :bigserial, force: :cascade do |t| + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "short_name" + t.string "organizational_unit" + t.string "operating_department_name" + t.string "code" + t.string "phone" + t.string "fax" + t.string "email" + t.string "registration_number" + t.string "url" + t.string "time_zone" + t.integer "line_referential_id", limit: 8 + t.text "import_xml" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "companies", ["line_referential_id"], name: "index_companies_on_line_referential_id", using: :btree + add_index "companies", ["objectid"], name: "companies_objectid_key", unique: true, using: :btree + add_index "companies", ["registration_number"], name: "companies_registration_number_key", using: :btree + + create_table "compliance_check_blocks", id: :bigserial, force: :cascade do |t| + t.string "name" + t.hstore "condition_attributes" + t.integer "compliance_check_set_id", limit: 8 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "compliance_check_blocks", ["compliance_check_set_id"], name: "index_compliance_check_blocks_on_compliance_check_set_id", using: :btree + + create_table "compliance_check_messages", id: :bigserial, force: :cascade do |t| + t.integer "compliance_check_id", limit: 8 + t.integer "compliance_check_resource_id", limit: 8 + t.string "message_key" + t.hstore "message_attributes" + t.hstore "resource_attributes" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "status" + t.integer "compliance_check_set_id", limit: 8 + end + + add_index "compliance_check_messages", ["compliance_check_id"], name: "index_compliance_check_messages_on_compliance_check_id", using: :btree + add_index "compliance_check_messages", ["compliance_check_resource_id"], name: "index_compliance_check_messages_on_compliance_check_resource_id", using: :btree + add_index "compliance_check_messages", ["compliance_check_set_id"], name: "index_compliance_check_messages_on_compliance_check_set_id", using: :btree + + create_table "compliance_check_resources", id: :bigserial, force: :cascade do |t| + t.string "status" + t.string "name" + t.string "resource_type" + t.string "reference" + t.hstore "metrics" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "compliance_check_set_id", limit: 8 + end + + add_index "compliance_check_resources", ["compliance_check_set_id"], name: "index_compliance_check_resources_on_compliance_check_set_id", using: :btree + + create_table "compliance_check_sets", id: :bigserial, force: :cascade do |t| + t.integer "referential_id", limit: 8 + t.integer "compliance_control_set_id", limit: 8 + t.integer "workbench_id", limit: 8 + t.string "status" + t.integer "parent_id", limit: 8 + t.string "parent_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "current_step_id" + t.float "current_step_progress" + t.string "name" + t.datetime "started_at" + t.datetime "ended_at" + end + + add_index "compliance_check_sets", ["compliance_control_set_id"], name: "index_compliance_check_sets_on_compliance_control_set_id", using: :btree + add_index "compliance_check_sets", ["parent_type", "parent_id"], name: "index_compliance_check_sets_on_parent_type_and_parent_id", using: :btree + add_index "compliance_check_sets", ["referential_id"], name: "index_compliance_check_sets_on_referential_id", using: :btree + add_index "compliance_check_sets", ["workbench_id"], name: "index_compliance_check_sets_on_workbench_id", using: :btree + + create_table "compliance_checks", id: :bigserial, force: :cascade do |t| + t.integer "compliance_check_set_id", limit: 8 + t.integer "compliance_check_block_id", limit: 8 + t.string "type" + t.hstore "control_attributes" + t.string "name" + t.string "code" + t.string "criticity" + t.text "comment" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "origin_code" + end + + add_index "compliance_checks", ["compliance_check_block_id"], name: "index_compliance_checks_on_compliance_check_block_id", using: :btree + add_index "compliance_checks", ["compliance_check_set_id"], name: "index_compliance_checks_on_compliance_check_set_id", using: :btree + + create_table "compliance_control_blocks", id: :bigserial, force: :cascade do |t| + t.string "name" + t.hstore "condition_attributes" + t.integer "compliance_control_set_id", limit: 8 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "compliance_control_blocks", ["compliance_control_set_id"], name: "index_compliance_control_blocks_on_compliance_control_set_id", using: :btree + + create_table "compliance_control_sets", id: :bigserial, force: :cascade do |t| + t.string "name" + t.integer "organisation_id", limit: 8 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "compliance_control_sets", ["organisation_id"], name: "index_compliance_control_sets_on_organisation_id", using: :btree + + create_table "compliance_controls", id: :bigserial, force: :cascade do |t| + t.integer "compliance_control_set_id", limit: 8 + t.string "type" + t.hstore "control_attributes" + t.string "name" + t.string "code" + t.string "criticity" + t.text "comment" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "origin_code" + t.integer "compliance_control_block_id", limit: 8 + end + + add_index "compliance_controls", ["code", "compliance_control_set_id"], name: "index_compliance_controls_on_code_and_compliance_control_set_id", unique: true, using: :btree + add_index "compliance_controls", ["compliance_control_block_id"], name: "index_compliance_controls_on_compliance_control_block_id", using: :btree + add_index "compliance_controls", ["compliance_control_set_id"], name: "index_compliance_controls_on_compliance_control_set_id", using: :btree + + create_table "connection_links", id: :bigserial, force: :cascade do |t| + t.integer "departure_id", limit: 8 + t.integer "arrival_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.decimal "link_distance", precision: 19, scale: 2 + t.string "link_type" + t.time "default_duration" + t.time "frequent_traveller_duration" + t.time "occasional_traveller_duration" + t.time "mobility_restricted_traveller_duration" + t.boolean "mobility_restricted_suitability" + t.boolean "stairs_availability" + t.boolean "lift_availability" + t.integer "int_user_needs" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree + + create_table "delayed_jobs", id: :bigserial, force: :cascade do |t| + t.integer "priority", default: 0 + t.integer "attempts", default: 0 + t.text "handler" + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by", limit: 255 + t.string "queue", limit: 255 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree + + create_table "exports", id: :bigserial, force: :cascade do |t| + t.integer "referential_id", limit: 8 + t.string "status" + t.string "type" + t.string "options" + t.datetime "created_at" + t.datetime "updated_at" + t.string "references_type" + t.string "reference_ids" + end + + add_index "exports", ["referential_id"], name: "index_exports_on_referential_id", using: :btree + + create_table "facilities", id: :bigserial, force: :cascade do |t| + t.integer "stop_area_id", limit: 8 + t.integer "line_id", limit: 8 + t.integer "connection_link_id", limit: 8 + t.integer "stop_point_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.datetime "creation_time" + t.string "name" + t.string "comment" + t.string "description" + t.boolean "free_access" + t.decimal "longitude", precision: 19, scale: 16 + t.decimal "latitude", precision: 19, scale: 16 + t.string "long_lat_type" + t.decimal "x", precision: 19, scale: 2 + t.decimal "y", precision: 19, scale: 2 + t.string "projection_type" + t.string "country_code" + t.string "street_name" + t.string "contained_in" + end + + add_index "facilities", ["objectid"], name: "facilities_objectid_key", unique: true, using: :btree + + create_table "facilities_features", id: false, force: :cascade do |t| + t.integer "facility_id", limit: 8 + t.integer "choice_code" + end + + create_table "footnotes", id: :bigserial, force: :cascade do |t| + t.integer "line_id", limit: 8 + t.string "code" + t.string "label" + t.datetime "created_at" + t.datetime "updated_at" + t.string "checksum" + t.text "checksum_source" + t.string "data_source_ref" + end + + create_table "footnotes_vehicle_journeys", id: false, force: :cascade do |t| + t.integer "vehicle_journey_id", limit: 8 + t.integer "footnote_id", limit: 8 + end + + create_table "group_of_lines", id: :bigserial, force: :cascade do |t| + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.string "registration_number" + t.integer "line_referential_id", limit: 8 + t.text "import_xml" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "group_of_lines", ["line_referential_id"], name: "index_group_of_lines_on_line_referential_id", using: :btree + add_index "group_of_lines", ["objectid"], name: "group_of_lines_objectid_key", unique: true, using: :btree + + create_table "group_of_lines_lines", id: false, force: :cascade do |t| + t.integer "group_of_line_id", limit: 8 + t.integer "line_id", limit: 8 + end + + create_table "import_messages", id: :bigserial, force: :cascade do |t| + t.string "criticity" + t.string "message_key" + t.hstore "message_attributes" + t.integer "import_id", limit: 8 + t.integer "resource_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + t.hstore "resource_attributes" + end + + add_index "import_messages", ["import_id"], name: "index_import_messages_on_import_id", using: :btree + add_index "import_messages", ["resource_id"], name: "index_import_messages_on_resource_id", using: :btree + + create_table "import_resources", id: :bigserial, force: :cascade do |t| + t.integer "import_id", limit: 8 + t.string "status" + t.datetime "created_at" + t.datetime "updated_at" + t.string "resource_type" + t.string "reference" + t.string "name" + t.hstore "metrics" + end + + add_index "import_resources", ["import_id"], name: "index_import_resources_on_import_id", using: :btree + + create_table "imports", id: :bigserial, force: :cascade do |t| + t.string "status" + t.string "current_step_id" + t.float "current_step_progress" + t.integer "workbench_id", limit: 8 + t.integer "referential_id", limit: 8 + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + t.string "file" + t.datetime "started_at" + t.datetime "ended_at" + t.string "token_download" + t.string "type", limit: 255 + t.integer "parent_id", limit: 8 + t.string "parent_type" + t.integer "current_step", default: 0 + t.integer "total_steps", default: 0 + t.datetime "notified_parent_at" + t.string "creator" + end + + add_index "imports", ["referential_id"], name: "index_imports_on_referential_id", using: :btree + add_index "imports", ["workbench_id"], name: "index_imports_on_workbench_id", using: :btree + + create_table "journey_frequencies", id: :bigserial, force: :cascade do |t| + t.integer "vehicle_journey_id", limit: 8 + t.time "scheduled_headway_interval", null: false + t.time "first_departure_time", null: false + t.time "last_departure_time" + t.boolean "exact_time", default: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "timeband_id", limit: 8 + end + + add_index "journey_frequencies", ["timeband_id"], name: "index_journey_frequencies_on_timeband_id", using: :btree + add_index "journey_frequencies", ["vehicle_journey_id"], name: "index_journey_frequencies_on_vehicle_journey_id", using: :btree + + create_table "journey_patterns", id: :bigserial, force: :cascade do |t| + t.integer "route_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.string "registration_number" + t.string "published_name" + t.integer "departure_stop_point_id", limit: 8 + t.integer "arrival_stop_point_id", limit: 8 + t.integer "section_status", default: 0, null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "checksum" + t.text "checksum_source" + t.string "data_source_ref" + end + + add_index "journey_patterns", ["objectid"], name: "journey_patterns_objectid_key", unique: true, using: :btree + + create_table "journey_patterns_stop_points", id: false, force: :cascade do |t| + t.integer "journey_pattern_id", limit: 8 + t.integer "stop_point_id", limit: 8 + end + + add_index "journey_patterns_stop_points", ["journey_pattern_id"], name: "index_journey_pattern_id_on_journey_patterns_stop_points", using: :btree + + create_table "line_referential_memberships", id: :bigserial, force: :cascade do |t| + t.integer "organisation_id", limit: 8 + t.integer "line_referential_id", limit: 8 + t.boolean "owner" + end + + create_table "line_referential_sync_messages", id: :bigserial, force: :cascade do |t| + t.integer "criticity" + t.string "message_key" + t.hstore "message_attributes" + t.integer "line_referential_sync_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "line_referential_sync_messages", ["line_referential_sync_id"], name: "line_referential_sync_id", using: :btree + + create_table "line_referential_syncs", id: :bigserial, force: :cascade do |t| + t.integer "line_referential_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + t.datetime "started_at" + t.datetime "ended_at" + t.string "status" + end + + add_index "line_referential_syncs", ["line_referential_id"], name: "index_line_referential_syncs_on_line_referential_id", using: :btree + + create_table "line_referentials", id: :bigserial, force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "sync_interval", default: 1 + t.string "objectid_format" + end + + create_table "lines", id: :bigserial, force: :cascade do |t| + t.integer "network_id", limit: 8 + t.integer "company_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "number" + t.string "published_name" + t.string "transport_mode" + t.string "registration_number" + t.string "comment" + t.boolean "mobility_restricted_suitability" + t.integer "int_user_needs" + t.boolean "flexible_service" + t.string "url" + t.string "color", limit: 6 + t.string "text_color", limit: 6 + t.string "stable_id" + t.integer "line_referential_id", limit: 8 + t.boolean "deactivated", default: false + t.text "import_xml" + t.string "transport_submode" + t.integer "secondary_company_ids", limit: 8, array: true + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "seasonal" + end + + add_index "lines", ["line_referential_id"], name: "index_lines_on_line_referential_id", using: :btree + add_index "lines", ["objectid"], name: "lines_objectid_key", unique: true, using: :btree + add_index "lines", ["registration_number"], name: "lines_registration_number_key", using: :btree + add_index "lines", ["secondary_company_ids"], name: "index_lines_on_secondary_company_ids", using: :gin + + create_table "networks", id: :bigserial, force: :cascade do |t| + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.date "version_date" + t.string "description" + t.string "name" + t.string "registration_number" + t.string "source_name" + t.string "source_type" + t.string "source_identifier" + t.string "comment" + t.text "import_xml" + t.integer "line_referential_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "networks", ["line_referential_id"], name: "index_networks_on_line_referential_id", using: :btree + add_index "networks", ["objectid"], name: "networks_objectid_key", unique: true, using: :btree + add_index "networks", ["registration_number"], name: "networks_registration_number_key", using: :btree + + create_table "object_id_factories", id: :bigserial, force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "organisations", id: :bigserial, force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + t.string "data_format", default: "neptune" + t.string "code" + t.datetime "synced_at" + t.hstore "sso_attributes" + t.string "custom_view" + end + + add_index "organisations", ["code"], name: "index_organisations_on_code", unique: true, using: :btree + + create_table "pt_links", id: :bigserial, force: :cascade do |t| + t.integer "start_of_link_id", limit: 8 + t.integer "end_of_link_id", limit: 8 + t.integer "route_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.decimal "link_distance", precision: 19, scale: 2 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "pt_links", ["objectid"], name: "pt_links_objectid_key", unique: true, using: :btree + + create_table "referential_clonings", id: :bigserial, force: :cascade do |t| + t.string "status" + t.datetime "started_at" + t.datetime "ended_at" + t.integer "source_referential_id", limit: 8 + t.integer "target_referential_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "referential_clonings", ["source_referential_id"], name: "index_referential_clonings_on_source_referential_id", using: :btree + add_index "referential_clonings", ["target_referential_id"], name: "index_referential_clonings_on_target_referential_id", using: :btree + + create_table "referential_metadata", id: :bigserial, force: :cascade do |t| + t.integer "referential_id", limit: 8 + t.integer "line_ids", limit: 8, array: true + t.integer "referential_source_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + t.daterange "periodes", array: true + end + + add_index "referential_metadata", ["line_ids"], name: "index_referential_metadata_on_line_ids", using: :gin + add_index "referential_metadata", ["referential_id"], name: "index_referential_metadata_on_referential_id", using: :btree + add_index "referential_metadata", ["referential_source_id"], name: "index_referential_metadata_on_referential_source_id", using: :btree + + create_table "referential_suites", id: :bigserial, force: :cascade do |t| + t.integer "new_id", limit: 8 + t.integer "current_id", limit: 8 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "referential_suites", ["current_id"], name: "index_referential_suites_on_current_id", using: :btree + add_index "referential_suites", ["new_id"], name: "index_referential_suites_on_new_id", using: :btree + + create_table "referentials", id: :bigserial, force: :cascade do |t| + t.string "name" + t.string "slug" + t.datetime "created_at" + t.datetime "updated_at" + t.string "prefix" + t.string "projection_type" + t.string "time_zone" + t.string "bounds" + t.integer "organisation_id", limit: 8 + t.text "geographical_bounds" + t.integer "user_id", limit: 8 + t.string "user_name" + t.string "data_format" + t.integer "line_referential_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 + t.integer "workbench_id", limit: 8 + t.datetime "archived_at" + t.integer "created_from_id", limit: 8 + t.boolean "ready", default: false + t.integer "referential_suite_id", limit: 8 + t.string "objectid_format" + end + + add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree + add_index "referentials", ["referential_suite_id"], name: "index_referentials_on_referential_suite_id", using: :btree + + create_table "routes", id: :bigserial, force: :cascade do |t| + t.integer "line_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.integer "opposite_route_id", limit: 8 + t.string "published_name" + t.string "number" + t.string "direction" + t.string "wayback" + t.datetime "created_at" + t.datetime "updated_at" + t.string "checksum" + t.text "checksum_source" + t.string "data_source_ref" + end + + add_index "routes", ["objectid"], name: "routes_objectid_key", unique: true, using: :btree + + create_table "routing_constraint_zones", id: :bigserial, force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.integer "route_id", limit: 8 + t.integer "stop_point_ids", limit: 8, array: true + t.string "checksum" + t.text "checksum_source" + t.string "data_source_ref" + end + + create_table "routing_constraints_lines", id: false, force: :cascade do |t| + t.integer "stop_area_id", limit: 8 + t.integer "line_id", limit: 8 + end + + create_table "stop_area_referential_memberships", id: :bigserial, force: :cascade do |t| + t.integer "organisation_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 + t.boolean "owner" + end + + create_table "stop_area_referential_sync_messages", id: :bigserial, force: :cascade do |t| + t.integer "criticity" + t.string "message_key" + t.hstore "message_attributes" + t.integer "stop_area_referential_sync_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "stop_area_referential_sync_messages", ["stop_area_referential_sync_id"], name: "stop_area_referential_sync_id", using: :btree + + create_table "stop_area_referential_syncs", id: :bigserial, force: :cascade do |t| + t.integer "stop_area_referential_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + t.datetime "ended_at" + t.datetime "started_at" + t.string "status" + end + + add_index "stop_area_referential_syncs", ["stop_area_referential_id"], name: "index_stop_area_referential_syncs_on_stop_area_referential_id", using: :btree + + create_table "stop_area_referentials", id: :bigserial, force: :cascade do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + t.string "objectid_format" + end + + create_table "stop_areas", id: :bigserial, force: :cascade do |t| + t.integer "parent_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.string "comment" + t.string "area_type" + t.string "registration_number" + t.string "nearest_topic_name" + t.integer "fare_code" + t.decimal "longitude", precision: 19, scale: 16 + t.decimal "latitude", precision: 19, scale: 16 + t.string "long_lat_type" + t.string "country_code" + t.string "street_name" + t.boolean "mobility_restricted_suitability" + t.boolean "stairs_availability" + t.boolean "lift_availability" + t.integer "int_user_needs" + t.string "zip_code" + t.string "city_name" + t.string "url" + t.string "time_zone" + t.integer "stop_area_referential_id", limit: 8 + t.string "status" + t.text "import_xml" + t.datetime "deleted_at" + t.datetime "created_at" + t.datetime "updated_at" + t.string "stif_type", limit: 255 + end + + add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree + add_index "stop_areas", ["objectid"], name: "stop_areas_objectid_key", unique: true, using: :btree + add_index "stop_areas", ["parent_id"], name: "index_stop_areas_on_parent_id", using: :btree + add_index "stop_areas", ["stop_area_referential_id"], name: "index_stop_areas_on_stop_area_referential_id", using: :btree + + create_table "stop_areas_stop_areas", id: false, force: :cascade do |t| + t.integer "child_id", limit: 8 + t.integer "parent_id", limit: 8 + end + + create_table "stop_points", id: :bigserial, force: :cascade do |t| + t.integer "route_id", limit: 8 + t.integer "stop_area_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.integer "position" + t.string "for_boarding" + t.string "for_alighting" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "stop_points", ["objectid"], name: "stop_points_objectid_key", unique: true, using: :btree + + create_table "taggings", id: :bigserial, force: :cascade do |t| + t.integer "tag_id", limit: 8 + t.integer "taggable_id", limit: 8 + t.string "taggable_type" + t.integer "tagger_id", limit: 8 + t.string "tagger_type" + t.string "context", limit: 128 + t.datetime "created_at" + end + + add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree + add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree + + create_table "tags", id: :bigserial, force: :cascade do |t| + t.string "name" + t.integer "taggings_count", default: 0 + end + + add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree + + create_table "time_table_dates", id: :bigserial, force: :cascade do |t| + t.integer "time_table_id", limit: 8, null: false + t.date "date" + t.integer "position", null: false + t.boolean "in_out" + t.string "checksum" + t.text "checksum_source" + end + + add_index "time_table_dates", ["time_table_id"], name: "index_time_table_dates_on_time_table_id", using: :btree + + create_table "time_table_periods", id: :bigserial, force: :cascade do |t| + t.integer "time_table_id", limit: 8, null: false + t.date "period_start" + t.date "period_end" + t.integer "position", null: false + t.string "checksum" + t.text "checksum_source" + end + + add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree + + create_table "time_tables", id: :bigserial, force: :cascade do |t| + t.string "objectid", null: false + t.integer "object_version", limit: 8, default: 1 + t.string "version" + t.string "comment" + t.integer "int_day_types", default: 0 + t.date "start_date" + t.date "end_date" + t.integer "calendar_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + t.string "color", limit: 255 + t.integer "created_from_id", limit: 8 + t.string "checksum" + t.text "checksum_source" + t.string "data_source_ref" + end + + add_index "time_tables", ["calendar_id"], name: "index_time_tables_on_calendar_id", using: :btree + add_index "time_tables", ["created_from_id"], name: "index_time_tables_on_created_from_id", using: :btree + add_index "time_tables", ["objectid"], name: "time_tables_objectid_key", unique: true, using: :btree + + create_table "time_tables_vehicle_journeys", id: false, force: :cascade do |t| + t.integer "time_table_id", limit: 8 + t.integer "vehicle_journey_id", limit: 8 + end + + add_index "time_tables_vehicle_journeys", ["time_table_id"], name: "index_time_tables_vehicle_journeys_on_time_table_id", using: :btree + add_index "time_tables_vehicle_journeys", ["vehicle_journey_id"], name: "index_time_tables_vehicle_journeys_on_vehicle_journey_id", using: :btree + + create_table "timebands", id: :bigserial, force: :cascade do |t| + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "name" + t.time "start_time", null: false + t.time "end_time", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "users", id: :bigserial, force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "" + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", default: 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "organisation_id", limit: 8 + t.string "name" + t.string "confirmation_token" + t.datetime "confirmed_at" + t.datetime "confirmation_sent_at" + t.string "unconfirmed_email" + t.integer "failed_attempts", default: 0 + t.string "unlock_token" + t.datetime "locked_at" + t.string "authentication_token" + t.string "invitation_token" + t.datetime "invitation_sent_at" + t.datetime "invitation_accepted_at" + t.integer "invitation_limit" + t.integer "invited_by_id", limit: 8 + t.string "invited_by_type" + t.datetime "invitation_created_at" + t.string "username" + t.datetime "synced_at" + t.string "permissions", array: true + end + + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true, using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + add_index "users", ["username"], name: "index_users_on_username", unique: true, using: :btree + + create_table "vehicle_journey_at_stops", id: :bigserial, force: :cascade do |t| + t.integer "vehicle_journey_id", limit: 8 + t.integer "stop_point_id", limit: 8 + t.string "connecting_service_id" + t.string "boarding_alighting_possibility" + t.time "arrival_time" + t.time "departure_time" + t.string "for_boarding" + t.string "for_alighting" + t.integer "departure_day_offset", default: 0 + t.integer "arrival_day_offset", default: 0 + t.string "checksum" + t.text "checksum_source" + end + + add_index "vehicle_journey_at_stops", ["stop_point_id"], name: "index_vehicle_journey_at_stops_on_stop_pointid", using: :btree + add_index "vehicle_journey_at_stops", ["vehicle_journey_id"], name: "index_vehicle_journey_at_stops_on_vehicle_journey_id", using: :btree + + create_table "vehicle_journeys", id: :bigserial, force: :cascade do |t| + t.integer "route_id", limit: 8 + t.integer "journey_pattern_id", limit: 8 + t.integer "company_id", limit: 8 + t.string "objectid", null: false + t.integer "object_version", limit: 8 + t.string "comment" + t.string "status_value" + t.string "transport_mode" + t.string "published_journey_name" + t.string "published_journey_identifier" + t.string "facility" + t.string "vehicle_type_identifier" + t.integer "number", limit: 8 + t.boolean "mobility_restricted_suitability" + t.boolean "flexible_service" + t.integer "journey_category", default: 0, null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "checksum" + t.text "checksum_source" + t.string "data_source_ref" + end + + add_index "vehicle_journeys", ["objectid"], name: "vehicle_journeys_objectid_key", unique: true, using: :btree + add_index "vehicle_journeys", ["route_id"], name: "index_vehicle_journeys_on_route_id", using: :btree + + create_table "versions", id: :bigserial, force: :cascade 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" + t.datetime "created_at" + end + + add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree + + create_table "workbenches", id: :bigserial, force: :cascade do |t| + t.string "name" + t.integer "organisation_id", limit: 8 + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line_referential_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 + t.integer "output_id", limit: 8 + t.string "objectid_format" + end + + add_index "workbenches", ["line_referential_id"], name: "index_workbenches_on_line_referential_id", using: :btree + add_index "workbenches", ["organisation_id"], name: "index_workbenches_on_organisation_id", using: :btree + add_index "workbenches", ["stop_area_referential_id"], name: "index_workbenches_on_stop_area_referential_id", using: :btree + + add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey" + add_foreign_key "api_keys", "organisations" + add_foreign_key "compliance_check_blocks", "compliance_check_sets" + add_foreign_key "compliance_check_messages", "compliance_check_resources" + add_foreign_key "compliance_check_messages", "compliance_check_sets" + add_foreign_key "compliance_check_messages", "compliance_checks" + add_foreign_key "compliance_check_resources", "compliance_check_sets" + add_foreign_key "compliance_check_sets", "referentials" + add_foreign_key "compliance_check_sets", "workbenches" + add_foreign_key "compliance_checks", "compliance_check_blocks" + add_foreign_key "compliance_checks", "compliance_check_sets" + add_foreign_key "compliance_control_blocks", "compliance_control_sets" + add_foreign_key "compliance_control_sets", "organisations" + add_foreign_key "compliance_controls", "compliance_control_blocks" + add_foreign_key "compliance_controls", "compliance_control_sets" + add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", on_delete: :cascade + add_foreign_key "journey_frequencies", "timebands", name: "journey_frequencies_timeband_id_fk", on_delete: :nullify + add_foreign_key "journey_frequencies", "timebands", on_delete: :nullify + add_foreign_key "journey_frequencies", "vehicle_journeys", name: "journey_frequencies_vehicle_journey_id_fk", on_delete: :nullify + add_foreign_key "journey_frequencies", "vehicle_journeys", on_delete: :nullify + add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", on_delete: :cascade + add_foreign_key "journey_patterns", "stop_points", column: "arrival_stop_point_id", name: "arrival_point_fkey", on_delete: :nullify + add_foreign_key "journey_patterns", "stop_points", column: "departure_stop_point_id", name: "departure_point_fkey", on_delete: :nullify + add_foreign_key "journey_patterns_stop_points", "journey_patterns", name: "jpsp_jp_fkey", on_delete: :cascade + add_foreign_key "journey_patterns_stop_points", "stop_points", name: "jpsp_stoppoint_fkey", on_delete: :cascade + add_foreign_key "referentials", "referential_suites" + add_foreign_key "routes", "routes", column: "opposite_route_id", name: "route_opposite_route_fkey" + add_foreign_key "stop_areas", "stop_areas", column: "parent_id", name: "area_parent_fkey", on_delete: :nullify + add_foreign_key "stop_areas_stop_areas", "stop_areas", column: "child_id", name: "stoparea_child_fkey", on_delete: :cascade + add_foreign_key "stop_areas_stop_areas", "stop_areas", column: "parent_id", name: "stoparea_parent_fkey", on_delete: :cascade + add_foreign_key "time_table_dates", "time_tables", name: "tm_date_fkey", on_delete: :cascade + add_foreign_key "time_table_periods", "time_tables", name: "tm_period_fkey", on_delete: :cascade + add_foreign_key "time_tables_vehicle_journeys", "time_tables", name: "vjtm_tm_fkey", on_delete: :cascade + add_foreign_key "time_tables_vehicle_journeys", "vehicle_journeys", name: "vjtm_vj_fkey", on_delete: :cascade + add_foreign_key "vehicle_journey_at_stops", "stop_points", name: "vjas_sp_fkey", on_delete: :cascade + add_foreign_key "vehicle_journey_at_stops", "vehicle_journeys", name: "vjas_vj_fkey", on_delete: :cascade + add_foreign_key "vehicle_journeys", "journey_patterns", name: "vj_jp_fkey", on_delete: :cascade + add_foreign_key "vehicle_journeys", "routes", name: "vj_route_fkey", on_delete: :cascade +end -- cgit v1.2.3 From f98cd834d37b007ca8f30c48d8694e1f669f32a3 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 30 Nov 2017 19:12:11 +0100 Subject: Fixes: #5130@0.5h; Added a quickfix for incorrect item_id type in versions --- db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb | 8 ++++++++ db/schema.rb | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb (limited to 'db') 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 diff --git a/db/schema.rb b/db/schema.rb index af22672c6..c6c3bef7e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171130172926) do +ActiveRecord::Schema.define(version: 20171130180144) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -950,9 +950,9 @@ ActiveRecord::Schema.define(version: 20171130172926) do add_index "vehicle_journeys", ["route_id"], name: "index_vehicle_journeys_on_route_id", using: :btree create_table "versions", id: :bigserial, force: :cascade do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false + t.string "item_type", null: false + t.integer "item_id", limit: 8, null: false + t.string "event", null: false t.string "whodunnit" t.text "object" t.datetime "created_at" -- cgit v1.2.3