aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20150219175300_insert_default_organisation.rb2
-rw-r--r--db/migrate/20180313082623_add_custom_field_values_to_stop_areas.rb5
-rw-r--r--db/migrate/20180316115003_add_custom_field_values_to_companies.rb5
-rw-r--r--db/migrate/20180330074336_add_metadata_to_routes.rb5
-rw-r--r--db/migrate/20180330124436_add_metadata_to_other_models.rb28
-rw-r--r--db/migrate/20180403065419_remove_papertrail_tables.rb5
-rw-r--r--db/migrate/20180405133659_change_companies_custom_fields_values_type.rb8
-rw-r--r--db/schema.rb83
-rw-r--r--db/seeds/dev/custom_fields.seeds.rb52
-rw-r--r--db/seeds/development/custom_fields.seeds.rb52
-rw-r--r--db/seeds/seed_helpers.rb12
-rw-r--r--db/seeds/stif.seeds.rb53
12 files changed, 241 insertions, 69 deletions
diff --git a/db/migrate/20150219175300_insert_default_organisation.rb b/db/migrate/20150219175300_insert_default_organisation.rb
index 2734893f5..ac8ecb9b6 100644
--- a/db/migrate/20150219175300_insert_default_organisation.rb
+++ b/db/migrate/20150219175300_insert_default_organisation.rb
@@ -1,5 +1,5 @@
class InsertDefaultOrganisation < ActiveRecord::Migration
- class Organisation < ActiveRecord::Base
+ class Organisation < ApplicationModel
attr_accessor :name
end
diff --git a/db/migrate/20180313082623_add_custom_field_values_to_stop_areas.rb b/db/migrate/20180313082623_add_custom_field_values_to_stop_areas.rb
new file mode 100644
index 000000000..e49be7e40
--- /dev/null
+++ b/db/migrate/20180313082623_add_custom_field_values_to_stop_areas.rb
@@ -0,0 +1,5 @@
+class AddCustomFieldValuesToStopAreas < ActiveRecord::Migration
+ def change
+ add_column :stop_areas, :custom_field_values, :jsonb
+ end
+end
diff --git a/db/migrate/20180316115003_add_custom_field_values_to_companies.rb b/db/migrate/20180316115003_add_custom_field_values_to_companies.rb
new file mode 100644
index 000000000..1791a6970
--- /dev/null
+++ b/db/migrate/20180316115003_add_custom_field_values_to_companies.rb
@@ -0,0 +1,5 @@
+class AddCustomFieldValuesToCompanies < ActiveRecord::Migration
+ def change
+ add_column :companies, :custom_field_values, :json
+ end
+end
diff --git a/db/migrate/20180330074336_add_metadata_to_routes.rb b/db/migrate/20180330074336_add_metadata_to_routes.rb
new file mode 100644
index 000000000..1a35dbb65
--- /dev/null
+++ b/db/migrate/20180330074336_add_metadata_to_routes.rb
@@ -0,0 +1,5 @@
+class AddMetadataToRoutes < ActiveRecord::Migration
+ def change
+ add_column :routes, :metadata, :jsonb
+ end
+end
diff --git a/db/migrate/20180330124436_add_metadata_to_other_models.rb b/db/migrate/20180330124436_add_metadata_to_other_models.rb
new file mode 100644
index 000000000..db01c77df
--- /dev/null
+++ b/db/migrate/20180330124436_add_metadata_to_other_models.rb
@@ -0,0 +1,28 @@
+class AddMetadataToOtherModels < ActiveRecord::Migration
+ def change
+ [
+ Api::V1::ApiKey,
+ Calendar,
+ Chouette::AccessLink,
+ Chouette::AccessPoint,
+ Chouette::Company,
+ Chouette::ConnectionLink,
+ Chouette::GroupOfLine,
+ Chouette::JourneyPattern,
+ Chouette::Line,
+ Chouette::Network,
+ Chouette::PtLink,
+ Chouette::PurchaseWindow,
+ Chouette::RoutingConstraintZone,
+ Chouette::StopArea,
+ Chouette::StopPoint,
+ Chouette::TimeTable,
+ Chouette::Timeband,
+ Chouette::VehicleJourney,
+ ComplianceCheckSet,
+ ComplianceControlSet,
+ ].each do |model|
+ add_column model.table_name.split(".").last, :metadata, :jsonb, default: {}
+ end
+ end
+end
diff --git a/db/migrate/20180403065419_remove_papertrail_tables.rb b/db/migrate/20180403065419_remove_papertrail_tables.rb
new file mode 100644
index 000000000..8494058e1
--- /dev/null
+++ b/db/migrate/20180403065419_remove_papertrail_tables.rb
@@ -0,0 +1,5 @@
+class RemovePapertrailTables < ActiveRecord::Migration
+ def change
+ drop_table :versions
+ end
+end
diff --git a/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb b/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb
new file mode 100644
index 000000000..7248c29f6
--- /dev/null
+++ b/db/migrate/20180405133659_change_companies_custom_fields_values_type.rb
@@ -0,0 +1,8 @@
+class ChangeCompaniesCustomFieldsValuesType < ActiveRecord::Migration
+ def change
+ reversible do |dir|
+ dir.up { change_column :companies, :custom_field_values, 'jsonb USING CAST(custom_field_values AS jsonb)', :default => {} }
+ dir.down { change_column :companies, :custom_field_values, 'json USING CAST(custom_field_values AS json)', :default => {} }
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 77e35f449..7e0e9c2b5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -15,14 +15,14 @@ ActiveRecord::Schema.define(version: 20180319043333) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
- enable_extension "hstore"
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
t.integer "stop_area_id", limit: 8
- t.string "objectid", null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "name"
t.string "comment"
@@ -39,6 +39,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.string "link_orientation"
t.datetime "created_at"
t.datetime "updated_at"
+ t.jsonb "metadata", default: {}
end
add_index "access_links", ["objectid"], name: "access_links_objectid_key", unique: true, using: :btree
@@ -66,6 +67,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.text "import_xml"
t.datetime "created_at"
t.datetime "updated_at"
+ t.jsonb "metadata", default: {}
end
add_index "access_points", ["objectid"], name: "access_points_objectid_key", unique: true, using: :btree
@@ -77,6 +79,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "organisation_id", limit: 8
+ t.jsonb "metadata", default: {}
end
add_index "api_keys", ["organisation_id"], name: "index_api_keys_on_organisation_id", using: :btree
@@ -89,9 +92,10 @@ ActiveRecord::Schema.define(version: 20180319043333) 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
- t.integer "workgroup_id", limit: 8
+ t.jsonb "metadata", default: {}
end
add_index "calendars", ["organisation_id"], name: "index_calendars_on_organisation_id", using: :btree
@@ -117,13 +121,12 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.datetime "updated_at"
t.date "end_date"
t.string "date_type"
- t.string "mode"
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.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "name"
t.string "short_name"
@@ -140,6 +143,8 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.text "import_xml"
t.datetime "created_at"
t.datetime "updated_at"
+ t.jsonb "custom_field_values"
+ t.jsonb "metadata", default: {}
end
add_index "companies", ["line_referential_id"], name: "index_companies_on_line_referential_id", using: :btree
@@ -192,14 +197,15 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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.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"
t.datetime "notified_parent_at"
+ t.jsonb "metadata", default: {}
end
add_index "compliance_check_sets", ["compliance_control_set_id"], name: "index_compliance_check_sets_on_compliance_control_set_id", using: :btree
@@ -238,8 +244,9 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.jsonb "metadata", default: {}
end
add_index "compliance_control_sets", ["organisation_id"], name: "index_compliance_control_sets_on_organisation_id", using: :btree
@@ -265,7 +272,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "name"
t.string "comment"
@@ -281,6 +288,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.integer "int_user_needs"
t.datetime "created_at"
t.datetime "updated_at"
+ t.jsonb "metadata", default: {}
end
add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree
@@ -398,7 +406,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
end
create_table "group_of_lines", id: :bigserial, force: :cascade do |t|
- t.string "objectid", null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "name"
t.string "comment"
@@ -407,6 +415,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.text "import_xml"
t.datetime "created_at"
t.datetime "updated_at"
+ t.jsonb "metadata", default: {}
end
add_index "group_of_lines", ["line_referential_id"], name: "index_group_of_lines_on_line_referential_id", using: :btree
@@ -460,9 +469,9 @@ ActiveRecord::Schema.define(version: 20180319043333) 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
@@ -485,7 +494,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
create_table "journey_patterns", id: :bigserial, force: :cascade do |t|
t.integer "route_id", limit: 8
- t.string "objectid", null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "name"
t.string "comment"
@@ -499,6 +508,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.text "checksum_source"
t.string "data_source_ref"
t.json "costs"
+ t.jsonb "metadata", default: {}
end
add_index "journey_patterns", ["objectid"], name: "journey_patterns_objectid_key", unique: true, using: :btree
@@ -572,6 +582,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "seasonal"
+ t.jsonb "metadata", default: {}
end
add_index "lines", ["line_referential_id"], name: "index_lines_on_line_referential_id", using: :btree
@@ -593,7 +604,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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.string "objectid", null: false
t.integer "object_version", limit: 8
t.date "version_date"
t.string "description"
@@ -607,6 +618,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.integer "line_referential_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
+ t.jsonb "metadata", default: {}
end
add_index "networks", ["line_referential_id"], name: "index_networks_on_line_referential_id", using: :btree
@@ -631,13 +643,14 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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.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"
+ t.jsonb "metadata", default: {}
end
add_index "pt_links", ["objectid"], name: "pt_links_objectid_key", unique: true, using: :btree
@@ -645,13 +658,14 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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.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
+ t.jsonb "metadata", default: {}
end
add_index "purchase_windows", ["referential_id"], name: "index_purchase_windows_on_referential_id", using: :btree
@@ -742,6 +756,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.text "checksum_source"
t.string "data_source_ref"
t.json "costs"
+ t.jsonb "metadata"
end
add_index "routes", ["objectid"], name: "routes_objectid_key", unique: true, using: :btree
@@ -750,13 +765,14 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "objectid", null: false
+ 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.integer "stop_point_ids", limit: 8, array: true
t.string "checksum"
t.text "checksum_source"
t.string "data_source_ref"
+ t.jsonb "metadata", default: {}
end
create_table "routing_constraints_lines", id: false, force: :cascade do |t|
@@ -810,7 +826,7 @@ ActiveRecord::Schema.define(version: 20180319043333) 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 "name"
t.string "comment"
@@ -841,10 +857,9 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.integer "waiting_time"
t.string "kind"
t.jsonb "localized_names"
-
t.datetime "confirmed_at"
- t.json "custom_field_values"
-
+ t.jsonb "custom_field_values"
+ t.jsonb "metadata", default: {}
end
add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree
@@ -860,13 +875,14 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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.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"
+ t.jsonb "metadata", default: {}
end
add_index "stop_points", ["objectid"], name: "stop_points_objectid_key", unique: true, using: :btree
@@ -914,7 +930,7 @@ ActiveRecord::Schema.define(version: 20180319043333) 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.string "objectid", null: false
t.integer "object_version", limit: 8, default: 1
t.string "version"
t.string "comment"
@@ -929,6 +945,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.string "checksum"
t.text "checksum_source"
t.string "data_source_ref"
+ t.jsonb "metadata", default: {}
end
add_index "time_tables", ["calendar_id"], name: "index_time_tables_on_calendar_id", using: :btree
@@ -944,13 +961,14 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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.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.time "start_time", null: false
+ t.time "end_time", null: false
t.datetime "created_at"
t.datetime "updated_at"
+ t.jsonb "metadata", default: {}
end
create_table "users", id: :bigserial, force: :cascade do |t|
@@ -1033,6 +1051,7 @@ ActiveRecord::Schema.define(version: 20180319043333) do
t.text "checksum_source"
t.string "data_source_ref"
t.jsonb "custom_field_values", default: {}
+ t.jsonb "metadata", default: {}
end
add_index "vehicle_journeys", ["objectid"], name: "vehicle_journeys_objectid_key", unique: true, using: :btree
@@ -1074,8 +1093,10 @@ ActiveRecord::Schema.define(version: 20180319043333) do
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
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "import_types", default: [], array: true
+ t.string "export_types", default: [], array: true
end
add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey"
diff --git a/db/seeds/dev/custom_fields.seeds.rb b/db/seeds/dev/custom_fields.seeds.rb
new file mode 100644
index 000000000..eb3afc394
--- /dev/null
+++ b/db/seeds/dev/custom_fields.seeds.rb
@@ -0,0 +1,52 @@
+# coding: utf-8
+
+require_relative '../seed_helpers'
+
+Workgroup.find_each do |workgroup|
+ puts workgroup.inspect
+
+ workgroup.custom_fields.seed_by(code: "capacity") do |field|
+ field.resource_type = "VehicleJourney"
+ field.name = "Bus Capacity"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "48 places", "2": "54 places" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_commercial_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom commercial"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "OuiBus", "2": "Alsa" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_contact_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom du référent"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_list") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Liste"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "Valeur 1", "2": "Valeur 2" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_string") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Texte"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_integer") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Nomber"
+ field.field_type = "integer"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_attachment") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Piece Jointe"
+ field.field_type = "attachment"
+ end
+end
diff --git a/db/seeds/development/custom_fields.seeds.rb b/db/seeds/development/custom_fields.seeds.rb
new file mode 100644
index 000000000..eb3afc394
--- /dev/null
+++ b/db/seeds/development/custom_fields.seeds.rb
@@ -0,0 +1,52 @@
+# coding: utf-8
+
+require_relative '../seed_helpers'
+
+Workgroup.find_each do |workgroup|
+ puts workgroup.inspect
+
+ workgroup.custom_fields.seed_by(code: "capacity") do |field|
+ field.resource_type = "VehicleJourney"
+ field.name = "Bus Capacity"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "48 places", "2": "54 places" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_commercial_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom commercial"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "OuiBus", "2": "Alsa" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "company_contact_name") do |field|
+ field.resource_type = "Company"
+ field.name = "Nom du référent"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_list") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Liste"
+ field.field_type = "list"
+ field.options = { list_values: { "0": "", "1": "Valeur 1", "2": "Valeur 2" }}
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_string") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Texte"
+ field.field_type = "string"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_integer") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Nomber"
+ field.field_type = "integer"
+ end
+
+ workgroup.custom_fields.seed_by(code: "stop_area_test_attachment") do |field|
+ field.resource_type = "StopArea"
+ field.name = "Test de Piece Jointe"
+ field.field_type = "attachment"
+ end
+end
diff --git a/db/seeds/seed_helpers.rb b/db/seeds/seed_helpers.rb
new file mode 100644
index 000000000..708362a6c
--- /dev/null
+++ b/db/seeds/seed_helpers.rb
@@ -0,0 +1,12 @@
+class ActiveRecord::Base
+ def self.seed_by(key_attribute, &block)
+ model = find_or_initialize_by key_attribute
+ print "Seed #{name} #{key_attribute.inspect} "
+ yield model
+
+ puts "[#{(model.changed? ? 'updated' : 'no change')}]"
+ model.save!
+
+ model
+ end
+end
diff --git a/db/seeds/stif.seeds.rb b/db/seeds/stif.seeds.rb
index aa87b6f6c..98192385f 100644
--- a/db/seeds/stif.seeds.rb
+++ b/db/seeds/stif.seeds.rb
@@ -1,46 +1,25 @@
# coding: utf-8
-# This file should contain all the record creation needed to seed the database with its default values.
-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
-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")
+require_relative 'seed_helpers'
-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
- w.export_types = ["Export::Netex"]
+stif = Organisation.seed_by(code: "STIF") do |o|
+ o.name = 'STIF'
end
-Workbench.update_all workgroup_id: workgroup
-
-# Organisations
-stif = Organisation.find_or_create_by!(code: "STIF") do |org|
- org.name = 'STIF'
+stop_area_referential = StopAreaReferential.seed_by(name: "Reflex") do |r|
+ r.objectid_format = "stif_netex"
+ r.add_member stif, owner: true
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
-stop_area_referential.add_member stif, owner: true
-# stop_area_referential.add_member operator
+line_referential = LineReferential.seed_by(name: "CodifLigne") do |r|
+ r.objectid_format = "stif_codifligne"
+ r.add_member stif, owner: true
+end
-# 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
+workgroup = Workgroup.seed_by(name: "Gestion de l'offre théorique IDFm") do |w|
+ w.line_referential = line_referential
+ w.stop_area_referential = stop_area_referential
+ w.export_types = ["Export::Netex"]
+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) }
+Workbench.update_all workgroup_id: workgroup