aboutsummaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorRobert2017-09-14 08:39:37 +0200
committerRobert2017-09-14 08:39:37 +0200
commit2f52ae9e95a61878eb9baecdeddbb8ab4f55c04d (patch)
treecfa73049ddb444c631ff3198fdc9033fa87dfd0d /db
parent5d49813f7bc7b343141870fe291cea0100dad75e (diff)
parente11810f865239f5565c1b97c7e8da5f2b3108d29 (diff)
downloadchouette-core-2f52ae9e95a61878eb9baecdeddbb8ab4f55c04d.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20131029115820_create_compliance_check_results.rb23
-rw-r--r--db/migrate/20170906092619_create_new_compliance_check_results.rb (renamed from db/migrate/20170906092619_create_compliance_check_results.rb)3
-rw-r--r--db/seeds.rb62
3 files changed, 39 insertions, 49 deletions
diff --git a/db/migrate/20131029115820_create_compliance_check_results.rb b/db/migrate/20131029115820_create_compliance_check_results.rb
new file mode 100644
index 000000000..7f5c8e436
--- /dev/null
+++ b/db/migrate/20131029115820_create_compliance_check_results.rb
@@ -0,0 +1,23 @@
+class CreateComplianceCheckResults < ActiveRecord::Migration
+ def up
+ unless table_exists? :compliance_check_results
+ create_table :compliance_check_results do |t|
+ t.belongs_to :compliance_check_task , :null => :no ,:limit => 8
+ t.string :rule_code # rule code value
+ t.string :severity # warning, error, improvement
+ t.string :status # NA, OK, NOK
+ t.integer :violation_count # number of violation occurences
+ t.text :detail # detail of violation location
+ t.timestamps
+ end
+ add_foreign_key :compliance_check_results, :compliance_check_tasks, :on_delete => :cascade
+ end
+ end
+
+ def down
+ if table_exists? :compliance_check_results
+ execute "drop table compliance_check_results"
+ # drop_table :compliance_check_results
+ end
+ end
+end
diff --git a/db/migrate/20170906092619_create_compliance_check_results.rb b/db/migrate/20170906092619_create_new_compliance_check_results.rb
index e917d384e..a22800a8f 100644
--- a/db/migrate/20170906092619_create_compliance_check_results.rb
+++ b/db/migrate/20170906092619_create_new_compliance_check_results.rb
@@ -1,5 +1,6 @@
-class CreateComplianceCheckResults < ActiveRecord::Migration
+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
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)