diff options
Diffstat (limited to 'db')
24 files changed, 294 insertions, 23 deletions
diff --git a/db/migrate/20171212152452_create_merges.rb b/db/migrate/20171212152452_create_merges.rb new file mode 100644 index 000000000..7915bd91b --- /dev/null +++ b/db/migrate/20171212152452_create_merges.rb @@ -0,0 +1,16 @@ +class CreateMerges < ActiveRecord::Migration + def change + create_table :merges do |t| + t.bigint :workbench_id, index: true, foreign_key: true + t.bigint :referential_ids, array: true + + t.string :creator + t.string :status + + t.datetime :started_at + t.datetime :ended_at + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20171214130636_enable_unaccent_extension.rb b/db/migrate/20171214130636_enable_unaccent_extension.rb new file mode 100644 index 000000000..f7411b1f4 --- /dev/null +++ b/db/migrate/20171214130636_enable_unaccent_extension.rb @@ -0,0 +1,9 @@ +class EnableUnaccentExtension < ActiveRecord::Migration + def up + execute 'CREATE EXTENSION IF NOT EXISTS unaccent SCHEMA shared_extensions;' + end + + def down + execute 'DROP EXTENSION IF EXISTS unaccent SCHEMA shared_extensions;' + end +end diff --git a/db/migrate/20171214131755_create_business_calendars.rb b/db/migrate/20171214131755_create_business_calendars.rb new file mode 100644 index 000000000..aa7c1ab12 --- /dev/null +++ b/db/migrate/20171214131755_create_business_calendars.rb @@ -0,0 +1,14 @@ +class CreateBusinessCalendars < ActiveRecord::Migration + def change + create_table :business_calendars do |t| + t.string :name + t.string :short_name + t.string :color + t.daterange :date_ranges, array: true + t.date :dates, array: true + t.belongs_to :organisation, index: true + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20171215144543_rename_business_calendars_to_purchase_windows.rb b/db/migrate/20171215144543_rename_business_calendars_to_purchase_windows.rb new file mode 100644 index 000000000..d4467d6a7 --- /dev/null +++ b/db/migrate/20171215144543_rename_business_calendars_to_purchase_windows.rb @@ -0,0 +1,5 @@ +class RenameBusinessCalendarsToPurchaseWindows < ActiveRecord::Migration + def change + rename_table :business_calendars, :purchase_windows + end +end diff --git a/db/migrate/20171215145023_update_purchase_windows_attributes.rb b/db/migrate/20171215145023_update_purchase_windows_attributes.rb new file mode 100644 index 000000000..48dfb15bc --- /dev/null +++ b/db/migrate/20171215145023_update_purchase_windows_attributes.rb @@ -0,0 +1,13 @@ +class UpdatePurchaseWindowsAttributes < ActiveRecord::Migration + def change + add_column :purchase_windows, :objectid, :string + add_column :purchase_windows, :checksum, :string + add_column :purchase_windows, :checksum_source, :text + + remove_column :purchase_windows, :short_name, :string + remove_column :purchase_windows, :dates, :date + remove_column :purchase_windows, :organisation_id, :integer + + add_reference :purchase_windows, :referential, type: :bigint, index: true + end +end diff --git a/db/migrate/20171218174509_change_compliance_control_compliance_check_control_attributes_format_from_hstore_to_json.rb b/db/migrate/20171218174509_change_compliance_control_compliance_check_control_attributes_format_from_hstore_to_json.rb new file mode 100644 index 000000000..0576dddf2 --- /dev/null +++ b/db/migrate/20171218174509_change_compliance_control_compliance_check_control_attributes_format_from_hstore_to_json.rb @@ -0,0 +1,33 @@ +class ChangeComplianceControlComplianceCheckControlAttributesFormatFromHstoreToJson < ActiveRecord::Migration + def up + change_column :compliance_controls, + :control_attributes, + 'json USING hstore_to_json(control_attributes)' + change_column :compliance_checks, + :control_attributes, + 'json USING hstore_to_json(control_attributes)' + end + + def down + execute <<-SQL + CREATE OR REPLACE FUNCTION my_json_to_hstore(json) + RETURNS hstore + IMMUTABLE + STRICT + LANGUAGE sql + AS $func$ + SELECT hstore(array_agg(key), array_agg(value)) + FROM json_each_text($1) + $func$; + SQL + + change_column :compliance_controls, + :control_attributes, + 'hstore USING my_json_to_hstore(control_attributes)' + change_column :compliance_checks, + :control_attributes, + 'hstore USING my_json_to_hstore(control_attributes)' + + execute "DROP FUNCTION my_json_to_hstore(json)" + end +end diff --git a/db/migrate/20171219170128_add_features_to_organisations.rb b/db/migrate/20171219170128_add_features_to_organisations.rb new file mode 100644 index 000000000..bbec3297b --- /dev/null +++ b/db/migrate/20171219170128_add_features_to_organisations.rb @@ -0,0 +1,5 @@ +class AddFeaturesToOrganisations < ActiveRecord::Migration + def change + add_column :organisations, :features, :string, array: true, default: [] + end +end diff --git a/db/migrate/20171220164059_add_waiting_time_to_stop_areas.rb b/db/migrate/20171220164059_add_waiting_time_to_stop_areas.rb new file mode 100644 index 000000000..369fed3ab --- /dev/null +++ b/db/migrate/20171220164059_add_waiting_time_to_stop_areas.rb @@ -0,0 +1,5 @@ +class AddWaitingTimeToStopAreas < ActiveRecord::Migration + def change + add_column :stop_areas, :waiting_time, :integer + end +end diff --git a/db/migrate/20171227113809_create_join_table_purchase_windows_vehicle_journeys.rb b/db/migrate/20171227113809_create_join_table_purchase_windows_vehicle_journeys.rb new file mode 100644 index 000000000..5460878aa --- /dev/null +++ b/db/migrate/20171227113809_create_join_table_purchase_windows_vehicle_journeys.rb @@ -0,0 +1,8 @@ +class CreateJoinTablePurchaseWindowsVehicleJourneys < ActiveRecord::Migration + def change + create_join_table :purchase_windows, :vehicle_journeys do |t| + t.integer :purchase_window_id, limit: 8 + t.integer :vehicle_journey_id, limit: 8 + end + end +end diff --git a/db/migrate/20180103084612_add_costs_to_journey_patterns.rb b/db/migrate/20180103084612_add_costs_to_journey_patterns.rb new file mode 100644 index 000000000..6795e3671 --- /dev/null +++ b/db/migrate/20180103084612_add_costs_to_journey_patterns.rb @@ -0,0 +1,5 @@ +class AddCostsToJourneyPatterns < ActiveRecord::Migration + def change + add_column :journey_patterns, :costs, :json + end +end diff --git a/db/migrate/20180108132310_create_workgroups.rb b/db/migrate/20180108132310_create_workgroups.rb new file mode 100644 index 000000000..717f05856 --- /dev/null +++ b/db/migrate/20180108132310_create_workgroups.rb @@ -0,0 +1,11 @@ +class CreateWorkgroups < ActiveRecord::Migration + def change + create_table :workgroups do |t| + t.string :name + t.integer :line_referential_id, limit: 8 + t.integer :stop_area_referential_id, limit: 8 + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20180109133022_add_workgroup_id_to_workbenches.rb b/db/migrate/20180109133022_add_workgroup_id_to_workbenches.rb new file mode 100644 index 000000000..8736f7fbb --- /dev/null +++ b/db/migrate/20180109133022_add_workgroup_id_to_workbenches.rb @@ -0,0 +1,6 @@ +class AddWorkgroupIdToWorkbenches < ActiveRecord::Migration + def change + add_column :workbenches, :workgroup_id, :integer, limit: 8 + add_index :workbenches, :workgroup_id + end +end diff --git a/db/migrate/20180109144120_create_custom_fields.rb b/db/migrate/20180109144120_create_custom_fields.rb new file mode 100644 index 000000000..49df645c5 --- /dev/null +++ b/db/migrate/20180109144120_create_custom_fields.rb @@ -0,0 +1,14 @@ +class CreateCustomFields < ActiveRecord::Migration + def change + create_table :custom_fields do |t| + t.string :code + t.string :resource_type + t.string :name + t.string :field_type + t.json :options + t.bigint :workgroup_id + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20180109173815_add_index_resource_type_on_custom_fields.rb b/db/migrate/20180109173815_add_index_resource_type_on_custom_fields.rb new file mode 100644 index 000000000..326e85806 --- /dev/null +++ b/db/migrate/20180109173815_add_index_resource_type_on_custom_fields.rb @@ -0,0 +1,5 @@ +class AddIndexResourceTypeOnCustomFields < ActiveRecord::Migration + def change + add_index :custom_fields, :resource_type + end +end diff --git a/db/migrate/20180109180350_add_custom_field_values_to_vehicle_journeys.rb b/db/migrate/20180109180350_add_custom_field_values_to_vehicle_journeys.rb new file mode 100644 index 000000000..873dc97d4 --- /dev/null +++ b/db/migrate/20180109180350_add_custom_field_values_to_vehicle_journeys.rb @@ -0,0 +1,5 @@ +class AddCustomFieldValuesToVehicleJourneys < ActiveRecord::Migration + def change + add_column :vehicle_journeys, :custom_field_values, :jsonb, default: {} + end +end diff --git a/db/migrate/20180111200406_add_merged_at_to_referentials.rb b/db/migrate/20180111200406_add_merged_at_to_referentials.rb new file mode 100644 index 000000000..27b11fa29 --- /dev/null +++ b/db/migrate/20180111200406_add_merged_at_to_referentials.rb @@ -0,0 +1,5 @@ +class AddMergedAtToReferentials < ActiveRecord::Migration + def change + add_column :referentials, :merged_at, :datetime + end +end diff --git a/db/migrate/20180123174450_add_workgroup_id_to_calendars.rb b/db/migrate/20180123174450_add_workgroup_id_to_calendars.rb new file mode 100644 index 000000000..64ad1a752 --- /dev/null +++ b/db/migrate/20180123174450_add_workgroup_id_to_calendars.rb @@ -0,0 +1,6 @@ +class AddWorkgroupIdToCalendars < ActiveRecord::Migration + def change + add_column :calendars, :workgroup_id, :integer, limit: 8 + add_index :calendars, :workgroup_id + end +end diff --git a/db/migrate/20180124061955_add_int_day_types_to_calendars.rb b/db/migrate/20180124061955_add_int_day_types_to_calendars.rb new file mode 100644 index 000000000..5b1ff6fc1 --- /dev/null +++ b/db/migrate/20180124061955_add_int_day_types_to_calendars.rb @@ -0,0 +1,5 @@ +class AddIntDayTypesToCalendars < ActiveRecord::Migration + def change + add_column :calendars, :int_day_types, :integer + end +end diff --git a/db/migrate/20180124124215_add_excluded_dates_to_calendars.rb b/db/migrate/20180124124215_add_excluded_dates_to_calendars.rb new file mode 100644 index 000000000..b98b50717 --- /dev/null +++ b/db/migrate/20180124124215_add_excluded_dates_to_calendars.rb @@ -0,0 +1,5 @@ +class AddExcludedDatesToCalendars < ActiveRecord::Migration + def change + add_column :calendars, :excluded_dates, :date, array: true + end +end diff --git a/db/migrate/20180126134944_add_kind_to_stop_areas.rb b/db/migrate/20180126134944_add_kind_to_stop_areas.rb new file mode 100644 index 000000000..08f54a6c5 --- /dev/null +++ b/db/migrate/20180126134944_add_kind_to_stop_areas.rb @@ -0,0 +1,6 @@ +class AddKindToStopAreas < ActiveRecord::Migration + def change + add_column :stop_areas, :kind, :string + Chouette::StopArea.where.not(kind: :non_commercial).update_all kind: :commercial + end +end diff --git a/db/migrate/20180129141656_add_localized_names_to_stop_areas.rb b/db/migrate/20180129141656_add_localized_names_to_stop_areas.rb new file mode 100644 index 000000000..320ce739a --- /dev/null +++ b/db/migrate/20180129141656_add_localized_names_to_stop_areas.rb @@ -0,0 +1,5 @@ +class AddLocalizedNamesToStopAreas < ActiveRecord::Migration + def change + add_column :stop_areas, :localized_names, :jsonb + end +end diff --git a/db/migrate/20180202170009_set_stop_areas_kind_to_commercial_on_existing_records.rb b/db/migrate/20180202170009_set_stop_areas_kind_to_commercial_on_existing_records.rb new file mode 100644 index 000000000..6c6f6370e --- /dev/null +++ b/db/migrate/20180202170009_set_stop_areas_kind_to_commercial_on_existing_records.rb @@ -0,0 +1,11 @@ +class SetStopAreasKindToCommercialOnExistingRecords < ActiveRecord::Migration + def up + Chouette::StopArea + .where('kind != ? or kind is null', :non_commercial) + .update_all(kind: :commercial) + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/schema.rb b/db/schema.rb index 4a04dac26..596682ce8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,12 +11,13 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171130180144) do +ActiveRecord::Schema.define(version: 20180202170009) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "postgis" enable_extension "hstore" + enable_extension "unaccent" create_table "access_links", id: :bigserial, force: :cascade do |t| t.integer "access_point_id", limit: 8 @@ -89,10 +90,14 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.integer "organisation_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" + t.integer "workgroup_id", limit: 8 + t.integer "int_day_types" + t.date "excluded_dates", array: true 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 + add_index "calendars", ["workgroup_id"], name: "index_calendars_on_workgroup_id", using: :btree create_table "clean_up_results", id: :bigserial, force: :cascade do |t| t.string "message_key" @@ -207,7 +212,7 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.integer "compliance_check_set_id", limit: 8 t.integer "compliance_check_block_id", limit: 8 t.string "type" - t.hstore "control_attributes" + t.json "control_attributes" t.string "name" t.string "code" t.string "criticity" @@ -242,7 +247,7 @@ ActiveRecord::Schema.define(version: 20171130180144) do 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.json "control_attributes" t.string "name" t.string "code" t.string "criticity" @@ -280,6 +285,19 @@ ActiveRecord::Schema.define(version: 20171130180144) do add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree + create_table "custom_fields", id: :bigserial, force: :cascade do |t| + t.string "code" + t.string "resource_type" + t.string "name" + t.string "field_type" + t.json "options" + t.integer "workgroup_id", limit: 8 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "custom_fields", ["resource_type"], name: "index_custom_fields_on_resource_type", using: :btree + create_table "exports", id: :bigserial, force: :cascade do |t| t.integer "referential_id", limit: 8 t.string "status" @@ -402,9 +420,9 @@ ActiveRecord::Schema.define(version: 20171130180144) 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 @@ -441,6 +459,7 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.string "checksum" t.text "checksum_source" t.string "data_source_ref" + t.json "costs" end add_index "journey_patterns", ["objectid"], name: "journey_patterns_objectid_key", unique: true, using: :btree @@ -521,6 +540,19 @@ ActiveRecord::Schema.define(version: 20171130180144) do 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 "merges", id: :bigserial, force: :cascade do |t| + t.integer "workbench_id", limit: 8 + t.integer "referential_ids", limit: 8, array: true + t.string "creator" + t.string "status" + t.datetime "started_at" + t.datetime "ended_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "merges", ["workbench_id"], name: "index_merges_on_workbench_id", using: :btree + create_table "networks", id: :bigserial, force: :cascade do |t| t.string "objectid", null: false t.integer "object_version", limit: 8 @@ -551,6 +583,7 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.datetime "synced_at" t.hstore "sso_attributes" t.string "custom_view" + t.string "features", default: [], array: true end add_index "organisations", ["code"], name: "index_organisations_on_code", unique: true, using: :btree @@ -570,6 +603,25 @@ ActiveRecord::Schema.define(version: 20171130180144) do add_index "pt_links", ["objectid"], name: "pt_links_objectid_key", unique: true, using: :btree + create_table "purchase_windows", id: :bigserial, force: :cascade do |t| + t.string "name" + t.string "color" + t.daterange "date_ranges", array: true + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "objectid" + t.string "checksum" + t.text "checksum_source" + t.integer "referential_id", limit: 8 + end + + add_index "purchase_windows", ["referential_id"], name: "index_purchase_windows_on_referential_id", using: :btree + + create_table "purchase_windows_vehicle_journeys", id: false, force: :cascade do |t| + t.integer "purchase_window_id", limit: 8 + t.integer "vehicle_journey_id", limit: 8 + end + create_table "referential_clonings", id: :bigserial, force: :cascade do |t| t.string "status" t.datetime "started_at" @@ -628,6 +680,7 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.boolean "ready", default: false t.integer "referential_suite_id", limit: 8 t.string "objectid_format" + t.datetime "merged_at" end add_index "referentials", ["created_from_id"], name: "index_referentials_on_created_from_id", using: :btree @@ -736,6 +789,9 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.datetime "created_at" t.datetime "updated_at" t.string "stif_type" + t.integer "waiting_time" + t.string "kind" + t.jsonb "localized_names" end add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree @@ -906,7 +962,7 @@ ActiveRecord::Schema.define(version: 20171130180144) do 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.string "objectid", null: false t.integer "object_version", limit: 8 t.string "comment" t.string "status_value" @@ -918,12 +974,13 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.integer "number", limit: 8 t.boolean "mobility_restricted_suitability" t.boolean "flexible_service" - t.integer "journey_category", default: 0, null: false + 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" + t.jsonb "custom_field_values", default: {} end add_index "vehicle_journeys", ["objectid"], name: "vehicle_journeys_objectid_key", unique: true, using: :btree @@ -949,11 +1006,21 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.integer "stop_area_referential_id", limit: 8 t.integer "output_id", limit: 8 t.string "objectid_format" + t.integer "workgroup_id", limit: 8 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_index "workbenches", ["workgroup_id"], name: "index_workbenches_on_workgroup_id", using: :btree + + create_table "workgroups", id: :bigserial, force: :cascade do |t| + t.string "name" + t.integer "line_referential_id", limit: 8 + t.integer "stop_area_referential_id", limit: 8 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey" add_foreign_key "api_keys", "organisations" diff --git a/db/seeds/stif.seeds.rb b/db/seeds/stif.seeds.rb index 464601557..f898021ce 100644 --- a/db/seeds/stif.seeds.rb +++ b/db/seeds/stif.seeds.rb @@ -5,34 +5,41 @@ stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex", objectid_format: "stif_netex") line_referential = LineReferential.find_or_create_by!(name: "CodifLigne", objectid_format: "stif_netex") +workgroup = Workgroup.find_or_create_by!(name: "Gestion de l'offre théorique IDFm") do |w| + w.line_referential = line_referential + w.stop_area_referential = stop_area_referential +end + +Workbench.update_all workgroup_id: workgroup + # Organisations stif = Organisation.find_or_create_by!(code: "STIF") do |org| org.name = 'STIF' end -operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation| - organisation.name = "Transporteur A" -end +# operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation| +# organisation.name = "Transporteur A" +# end # Member line_referential.add_member stif, owner: true -line_referential.add_member operator +# line_referential.add_member operator stop_area_referential.add_member stif, owner: true -stop_area_referential.add_member operator +# stop_area_referential.add_member operator # Users -stif.users.find_or_create_by!(username: "admin") do |user| - user.email = 'stif-boiv@af83.com' - user.password = "secret" - user.name = "STIF Administrateur" -end - -operator.users.find_or_create_by!(username: "transporteur") do |user| - user.email = 'stif-boiv+transporteur@af83.com' - user.password = "secret" - user.name = "Martin Lejeune" -end +# stif.users.find_or_create_by!(username: "admin") do |user| +# user.email = 'stif-boiv@af83.com' +# user.password = "secret" +# user.name = "STIF Administrateur" +# end +# +# operator.users.find_or_create_by!(username: "transporteur") do |user| +# user.email = 'stif-boiv+transporteur@af83.com' +# user.password = "secret" +# user.name = "Martin Lejeune" +# end # Include all Lines in organisation functional_scope stif.update sso_attributes: { functional_scope: line_referential.lines.pluck(:objectid) } -operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) } +#operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) } |
