aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170905101656_create_compliance_control_sets.rb10
-rw-r--r--db/migrate/20170905122539_create_compliance_control_blocks.rb11
-rw-r--r--db/migrate/20170905123421_create_compliance_controls.rb16
-rw-r--r--db/migrate/20170905130413_create_compliance_check_sets.rb14
-rw-r--r--db/migrate/20170905135646_create_compliance_check_blocks.rb11
-rw-r--r--db/migrate/20170906084628_create_compliance_checks.rb16
-rw-r--r--db/migrate/20170906091136_create_compliance_check_resources.rb13
-rw-r--r--db/migrate/20170906092619_create_new_compliance_check_results.rb14
-rw-r--r--db/migrate/20170913074922_change_wayback_route_values.rb12
-rw-r--r--db/schema.rb115
-rw-r--r--db/seeds.rb62
11 files changed, 245 insertions, 49 deletions
diff --git a/db/migrate/20170905101656_create_compliance_control_sets.rb b/db/migrate/20170905101656_create_compliance_control_sets.rb
new file mode 100644
index 000000000..d074267cd
--- /dev/null
+++ b/db/migrate/20170905101656_create_compliance_control_sets.rb
@@ -0,0 +1,10 @@
+class CreateComplianceControlSets < ActiveRecord::Migration
+ def change
+ create_table :compliance_control_sets do |t|
+ t.string :name
+ t.references :organisation, index: true, foreign_key: true
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170905122539_create_compliance_control_blocks.rb b/db/migrate/20170905122539_create_compliance_control_blocks.rb
new file mode 100644
index 000000000..54ed027ff
--- /dev/null
+++ b/db/migrate/20170905122539_create_compliance_control_blocks.rb
@@ -0,0 +1,11 @@
+class CreateComplianceControlBlocks < ActiveRecord::Migration
+ def change
+ create_table :compliance_control_blocks do |t|
+ t.string :name
+ t.hstore :condition_attributes
+ t.references :compliance_control_set, index: true, foreign_key: true
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170905123421_create_compliance_controls.rb b/db/migrate/20170905123421_create_compliance_controls.rb
new file mode 100644
index 000000000..6b507bb8d
--- /dev/null
+++ b/db/migrate/20170905123421_create_compliance_controls.rb
@@ -0,0 +1,16 @@
+class CreateComplianceControls < ActiveRecord::Migration
+ def change
+ create_table :compliance_controls do |t|
+ t.references :compliance_control_set, index: true, foreign_key: true
+ t.references :compliance_control_block, index: true, foreign_key: true
+ t.string :type
+ t.json :control_attributes
+ t.string :name
+ t.string :code
+ t.integer :criticity
+ t.text :comment
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170905130413_create_compliance_check_sets.rb b/db/migrate/20170905130413_create_compliance_check_sets.rb
new file mode 100644
index 000000000..21055a3f2
--- /dev/null
+++ b/db/migrate/20170905130413_create_compliance_check_sets.rb
@@ -0,0 +1,14 @@
+class CreateComplianceCheckSets < ActiveRecord::Migration
+ def change
+ create_table :compliance_check_sets do |t|
+ t.references :referential, index: true, foreign_key: true
+ t.references :compliance_control_set, index: true, foreign_key: true
+ t.references :workbench, index: true, foreign_key: true
+ t.string :creator
+ t.string :status
+ t.references :parent, polymorphic: true, index: true
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170905135646_create_compliance_check_blocks.rb b/db/migrate/20170905135646_create_compliance_check_blocks.rb
new file mode 100644
index 000000000..c461e656b
--- /dev/null
+++ b/db/migrate/20170905135646_create_compliance_check_blocks.rb
@@ -0,0 +1,11 @@
+class CreateComplianceCheckBlocks < ActiveRecord::Migration
+ def change
+ create_table :compliance_check_blocks do |t|
+ t.string :name
+ t.hstore :condition_attributes
+ t.references :compliance_check_set, index: true, foreign_key: true
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170906084628_create_compliance_checks.rb b/db/migrate/20170906084628_create_compliance_checks.rb
new file mode 100644
index 000000000..1d6bdaaf2
--- /dev/null
+++ b/db/migrate/20170906084628_create_compliance_checks.rb
@@ -0,0 +1,16 @@
+class CreateComplianceChecks < ActiveRecord::Migration
+ def change
+ create_table :compliance_checks do |t|
+ t.references :compliance_check_set, index: true, foreign_key: true
+ t.references :compliance_check_block, index: true, foreign_key: true
+ t.string :type
+ t.json :control_attributes
+ t.string :name
+ t.string :code
+ t.integer :criticity
+ t.text :comment
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170906091136_create_compliance_check_resources.rb b/db/migrate/20170906091136_create_compliance_check_resources.rb
new file mode 100644
index 000000000..45713fed5
--- /dev/null
+++ b/db/migrate/20170906091136_create_compliance_check_resources.rb
@@ -0,0 +1,13 @@
+class CreateComplianceCheckResources < ActiveRecord::Migration
+ def change
+ create_table :compliance_check_resources do |t|
+ t.string :status
+ t.string :name
+ t.string :type
+ t.string :reference
+ t.hstore :metrics
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170906092619_create_new_compliance_check_results.rb b/db/migrate/20170906092619_create_new_compliance_check_results.rb
new file mode 100644
index 000000000..a22800a8f
--- /dev/null
+++ b/db/migrate/20170906092619_create_new_compliance_check_results.rb
@@ -0,0 +1,14 @@
+class CreateNewComplianceCheckResults < ActiveRecord::Migration
+ def change
+ drop_table :compliance_check_results if table_exists? :compliance_check_results
+ create_table :compliance_check_results do |t|
+ t.references :compliance_check, index: true, foreign_key: true
+ t.references :compliance_check_resource, index: true, foreign_key: true
+ t.string :message_key
+ t.hstore :message_attributes
+ t.hstore :resource_attributes
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20170913074922_change_wayback_route_values.rb b/db/migrate/20170913074922_change_wayback_route_values.rb
new file mode 100644
index 000000000..a547cbd55
--- /dev/null
+++ b/db/migrate/20170913074922_change_wayback_route_values.rb
@@ -0,0 +1,12 @@
+class ChangeWaybackRouteValues < ActiveRecord::Migration
+ def up
+ execute "UPDATE routes SET wayback = 'outbound' WHERE routes.wayback = 'straight_forward';"
+ execute "UPDATE routes SET wayback = 'inbound' WHERE routes.wayback = 'backward';"
+ end
+
+ def down
+ execute "UPDATE routes SET wayback = 'straight_forward' WHERE routes.wayback = 'outbound';"
+ execute "UPDATE routes SET wayback = 'backward' WHERE routes.wayback = 'inbound';"
+ end
+
+end
diff --git a/db/schema.rb b/db/schema.rb
index 28de7d5fd..5e2edf33d 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: 20170907082913) do
+ActiveRecord::Schema.define(version: 20170913074922) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -145,6 +145,107 @@ ActiveRecord::Schema.define(version: 20170907082913) do
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"
+ 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_resources", id: :bigserial, force: :cascade do |t|
+ t.string "status"
+ t.string "name"
+ t.string "type"
+ t.string "reference"
+ t.hstore "metrics"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "compliance_check_results", id: :bigserial, force: :cascade do |t|
+ t.integer "compliance_check_id"
+ t.integer "compliance_check_resource_id"
+ t.string "message_key"
+ t.hstore "message_attributes"
+ t.hstore "resource_attributes"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ add_index "compliance_check_results", ["compliance_check_id"], name: "index_compliance_check_results_on_compliance_check_id", using: :btree
+ add_index "compliance_check_results", ["compliance_check_resource_id"], name: "index_compliance_check_results_on_compliance_check_resource_id", using: :btree
+
+ create_table "compliance_check_sets", id: :bigserial, force: :cascade do |t|
+ t.integer "referential_id"
+ t.integer "compliance_control_set_id"
+ t.integer "workbench_id"
+ t.string "creator"
+ t.string "status"
+ t.integer "parent_id"
+ t.string "parent_type"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ 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"
+ t.integer "compliance_check_block_id"
+ t.string "type"
+ t.json "control_attributes"
+ t.string "name"
+ t.string "code"
+ t.integer "criticity"
+ t.text "comment"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ 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"
+ 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"
+ 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"
+ t.integer "compliance_control_block_id"
+ t.string "type"
+ t.json "control_attributes"
+ t.string "name"
+ t.string "code"
+ t.integer "criticity"
+ t.text "comment"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ 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
@@ -885,6 +986,18 @@ ActiveRecord::Schema.define(version: 20170907082913) do
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_results", "compliance_check_resources"
+ add_foreign_key "compliance_check_results", "compliance_checks"
+ add_foreign_key "compliance_check_sets", "compliance_control_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
diff --git a/db/seeds.rb b/db/seeds.rb
index 6e7f59c54..d31a35cfc 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,72 +1,38 @@
# 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).
-#
-# Examples:
-#
-# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
-# Mayor.create(:name => 'Emanuel', :city => cities.first)
-Organisation.where(code: nil).destroy_all
+stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex")
+line_referential = LineReferential.find_or_create_by!(name: "CodifLigne")
+# 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
+# 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
+
+# Users
stif.users.find_or_create_by!(username: "admin") do |user|
user.email = 'stif-boiv@af83.com'
user.password = "secret"
user.name = "STIF Administrateur"
- user.permissions = User.all_permissions
-end
-
-operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|
- organisation.name = "Transporteur A"
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"
- user.permissions = User.all_permissions
-end
-
-stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex") do |referential|
- referential.add_member stif, owner: true
- referential.add_member operator
-end
-
-10.times do |n|
- stop_area_referential.stop_areas.find_or_create_by! name: "Test #{n}", area_type: "zdep", objectid: "StopArea: #{n}"
-end
-
-line_referential = LineReferential.find_or_create_by!(name: "CodifLigne") do |referential|
- referential.add_member stif, owner: true
- referential.add_member operator
-end
-
-10.times do |n|
- line_referential.lines.find_or_create_by! name: "Test #{n}" do |l|
- l.objectid = "Chouette:Dummy:Line:00" + n.to_s
- end
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 = Workbench.find_by(name: "Gestion de l'offre")
-workbench.update_attributes(line_referential: line_referential,
- stop_area_referential: stop_area_referential)
-
-[["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.workbench = workbench
- end
-end
-
-# Clone last referential
-# Referential.new_from(Referential.last)