diff options
| author | Xinhui | 2017-08-08 11:42:26 +0200 |
|---|---|---|
| committer | Xinhui | 2017-08-08 11:42:26 +0200 |
| commit | 713da2201472799bee565af84836ce3ec5bfb89f (patch) | |
| tree | 92b05119d0f4e0500f18de12e72a31387190eeb4 | |
| parent | 4bdd39885176483c8390ba4ea72edcd05bdfa7c8 (diff) | |
| download | chouette-core-713da2201472799bee565af84836ce3ec5bfb89f.tar.bz2 | |
Append :LOC to objectid for existing records
| -rw-r--r-- | db/migrate/20170808091929_change_objectid_suffix.rb | 17 | ||||
| -rw-r--r-- | db/schema.rb | 49 |
2 files changed, 56 insertions, 10 deletions
diff --git a/db/migrate/20170808091929_change_objectid_suffix.rb b/db/migrate/20170808091929_change_objectid_suffix.rb new file mode 100644 index 000000000..da98e8b9d --- /dev/null +++ b/db/migrate/20170808091929_change_objectid_suffix.rb @@ -0,0 +1,17 @@ +class ChangeObjectidSuffix < ActiveRecord::Migration + def tables + ['routes', 'journey_patterns', 'vehicle_journeys', 'time_tables', 'routing_constraint_zones'] + end + + def up + self.tables.each do |table| + execute "UPDATE #{table} SET objectid = (objectid || ':LOC')" + end + end + + def down + self.tables.each do |table| + execute "UPDATE #{table} SET objectid = replace(objectid, ':LOC', '')" + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e64e5c04a..224518c94 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: 20170607141317) do +ActiveRecord::Schema.define(version: 20170808091929) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -211,11 +211,13 @@ ActiveRecord::Schema.define(version: 20170607141317) do end create_table "footnotes", id: :bigserial, force: :cascade do |t| - t.integer "line_id", limit: 8 + t.integer "line_id", limit: 8 t.string "code" t.string "label" t.datetime "created_at" t.datetime "updated_at" + t.string "checksum" + t.string "checksum_source" end create_table "footnotes_vehicle_journeys", id: false, force: :cascade do |t| @@ -330,6 +332,8 @@ ActiveRecord::Schema.define(version: 20170607141317) do t.integer "section_status", default: 0, null: false t.datetime "created_at" t.datetime "updated_at" + t.string "checksum" + t.string "checksum_source" end add_index "journey_patterns", ["objectid"], name: "journey_patterns_objectid_key", unique: true, using: :btree @@ -538,6 +542,8 @@ ActiveRecord::Schema.define(version: 20170607141317) do t.string "wayback" t.datetime "created_at" t.datetime "updated_at" + t.string "checksum" + t.string "checksum_source" end add_index "routes", ["objectid"], name: "routes_objectid_key", unique: true, using: :btree @@ -546,11 +552,13 @@ ActiveRecord::Schema.define(version: 20170607141317) do t.string "name" t.datetime "created_at" t.datetime "updated_at" - t.string "objectid", null: false - t.integer "object_version", limit: 8 + 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.integer "route_id", limit: 8 + t.integer "stop_point_ids", limit: 8, array: true + t.string "checksum" + t.string "checksum_source" end create_table "routing_constraints_lines", id: false, force: :cascade do |t| @@ -679,19 +687,23 @@ ActiveRecord::Schema.define(version: 20170607141317) do 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.integer "time_table_id", limit: 8, null: false t.date "date" - t.integer "position", null: false + t.integer "position", null: false t.boolean "in_out" + t.string "checksum" + t.string "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.integer "time_table_id", limit: 8, null: false t.date "period_start" t.date "period_end" - t.integer "position", null: false + t.integer "position", null: false + t.string "checksum" + t.string "checksum_source" end add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree @@ -710,6 +722,8 @@ ActiveRecord::Schema.define(version: 20170607141317) do t.datetime "updated_at" t.string "color", limit: 255 t.integer "created_from_id" + t.string "checksum" + t.string "checksum_source" end add_index "time_tables", ["calendar_id"], name: "index_time_tables_on_calendar_id", using: :btree @@ -786,6 +800,8 @@ ActiveRecord::Schema.define(version: 20170607141317) do t.string "for_alighting" t.integer "departure_day_offset", default: 0 t.integer "arrival_day_offset", default: 0 + t.string "checksum" + t.string "checksum_source" end add_index "vehicle_journey_at_stops", ["stop_point_id"], name: "index_vehicle_journey_at_stops_on_stop_pointid", using: :btree @@ -811,11 +827,23 @@ ActiveRecord::Schema.define(version: 20170607141317) do t.integer "journey_category", default: 0, null: false t.datetime "created_at" t.datetime "updated_at" + t.string "checksum" + t.string "checksum_source" 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 "worbench_object_identifiers", id: :bigserial, force: :cascade do |t| + t.string "object_class" + t.integer "last_technical_id" + t.integer "workbench_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "worbench_object_identifiers", ["workbench_id"], name: "index_worbench_object_identifiers_on_workbench_id", using: :btree + create_table "workbenches", id: :bigserial, force: :cascade do |t| t.string "name" t.integer "organisation_id", limit: 8 @@ -854,4 +882,5 @@ ActiveRecord::Schema.define(version: 20170607141317) do 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 + add_foreign_key "worbench_object_identifiers", "workbenches" end |
