aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorXinhui2016-10-18 15:34:47 +0200
committerXinhui2016-10-18 15:34:53 +0200
commitf9814e27bcaabbf69c66f43989236e40a334e0c1 (patch)
tree7d16d0b33fb83d732b918fbd08d29c839ddb5478 /db
parenta9aa01e2271fda736e13d1a10bd62f45e1508330 (diff)
downloadchouette-core-f9814e27bcaabbf69c66f43989236e40a334e0c1.tar.bz2
Relation Workbench - LineReferential & StopAreaReferential
Refs #1784
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20161018121633_add_line_referential_to_workbenches.rb5
-rw-r--r--db/migrate/20161018121647_add_stop_area_referential_to_workbenches.rb5
-rw-r--r--db/schema.rb6
-rw-r--r--db/seeds.rb19
4 files changed, 27 insertions, 8 deletions
diff --git a/db/migrate/20161018121633_add_line_referential_to_workbenches.rb b/db/migrate/20161018121633_add_line_referential_to_workbenches.rb
new file mode 100644
index 000000000..2cffc4c1a
--- /dev/null
+++ b/db/migrate/20161018121633_add_line_referential_to_workbenches.rb
@@ -0,0 +1,5 @@
+class AddLineReferentialToWorkbenches < ActiveRecord::Migration
+ def change
+ add_reference :workbenches, :line_referential, index: true
+ end
+end
diff --git a/db/migrate/20161018121647_add_stop_area_referential_to_workbenches.rb b/db/migrate/20161018121647_add_stop_area_referential_to_workbenches.rb
new file mode 100644
index 000000000..5c368dd57
--- /dev/null
+++ b/db/migrate/20161018121647_add_stop_area_referential_to_workbenches.rb
@@ -0,0 +1,5 @@
+class AddStopAreaReferentialToWorkbenches < ActiveRecord::Migration
+ def change
+ add_reference :workbenches, :stop_area_referential, index: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 9b2c3f1b2..63614f440 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: 20161017091304) do
+ActiveRecord::Schema.define(version: 20161018121647) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -683,9 +683,13 @@ ActiveRecord::Schema.define(version: 20161017091304) do
t.integer "organisation_id"
t.datetime "created_at"
t.datetime "updated_at"
+ t.integer "line_referential_id"
+ t.integer "stop_area_referential_id"
end
+ add_index "workbenches", ["line_referential_id"], :name => "index_workbenches_on_line_referential_id"
add_index "workbenches", ["organisation_id"], :name => "index_workbenches_on_organisation_id"
+ add_index "workbenches", ["stop_area_referential_id"], :name => "index_workbenches_on_stop_area_referential_id"
Foreigner.load
add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey", dependent: :delete
diff --git a/db/seeds.rb b/db/seeds.rb
index dae717966..0d7748f9c 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -17,7 +17,6 @@ stif.users.find_or_create_by!(username: "admin") do |user|
user.name = "STIF Administrateur"
end
-Workbench.find_or_create_by(name: "Gestion de l'offre", organisation: stif)
operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|
organisation.name = "Transporteur A"
@@ -43,6 +42,12 @@ line_referential = LineReferential.find_or_create_by(name: "CodifLigne") do |ref
referential.add_member operator
end
+Workbench.find_or_create_by(name: "Gestion de l'offre", organisation: stif) do |workbench|
+ workbench.line_referential = line_referential
+ workbench.stop_area_referential = stop_area_referential
+end
+
+
LineReferentialSync.find_or_create_by(line_referential: line_referential)
StopAreaReferentialSync.find_or_create_by(stop_area_referential: stop_area_referential)
@@ -52,16 +57,16 @@ StopAreaReferentialSync.find_or_create_by(stop_area_referential: stop_area_refer
end
end
-
-workbench = Workbench.find_or_create_by(name: "Gestion de l'offre", organisation: operator)
+workbench = Workbench.find_or_create_by(name: "Gestion de l'offre", organisation: operator) do |workbench|
+ workbench.line_referential = line_referential
+ workbench.stop_area_referential = stop_area_referential
+end
[["parissudest201604", "Paris Sud-Est Avril 2016"],
["parissudest201605", "Paris Sud-Est Mai 2016"]].each do |slug, name|
operator.referentials.find_or_create_by!(slug: slug) do |referential|
- referential.name = name
- referential.prefix = slug
+ referential.name = name
+ referential.prefix = slug
referential.workbench = workbench
- referential.line_referential = line_referential
- referential.stop_area_referential = stop_area_referential
end
end