diff options
| author | Marc Florisson | 2014-01-22 17:41:04 +0100 | 
|---|---|---|
| committer | Marc Florisson | 2014-01-22 17:41:04 +0100 | 
| commit | c9437fc2e96f415e38c1e72fa10337769381f289 (patch) | |
| tree | 199b39a7c8c5cc2cfef539f73f73c1b5fbea8a72 /db | |
| parent | 4e71abdc01f9f04ce6eec1989fa756ffc823fd65 (diff) | |
| download | chouette-core-c9437fc2e96f415e38c1e72fa10337769381f289.tar.bz2 | |
merge branch validation
Diffstat (limited to 'db')
19 files changed, 318 insertions, 49 deletions
diff --git a/db/migrate/20120531070108_add_type_and_options_to_import.rb b/db/migrate/20120531070108_add_type_and_options_to_import.rb index 490427c8a..0488fb6d4 100644 --- a/db/migrate/20120531070108_add_type_and_options_to_import.rb +++ b/db/migrate/20120531070108_add_type_and_options_to_import.rb @@ -3,6 +3,6 @@ class AddTypeAndOptionsToImport < ActiveRecord::Migration      change_table :imports do |t|        t.string :type, :options      end -    Import.update_all :type => "NeptuneImport" +    # Import.update_all :type => "NeptuneImport"    end  end diff --git a/db/migrate/20120612071936_add_file_type_to_import.rb b/db/migrate/20120612071936_add_file_type_to_import.rb index fccd91cce..8eacab40d 100644 --- a/db/migrate/20120612071936_add_file_type_to_import.rb +++ b/db/migrate/20120612071936_add_file_type_to_import.rb @@ -3,6 +3,6 @@ class AddFileTypeToImport < ActiveRecord::Migration      change_table :imports do |t|        t.string :file_type      end -    Import.update_all :file_type => "zip" +    #Import.update_all :file_type => "zip"    end  end diff --git a/db/migrate/20120905125251_add_organisation_id_to_file_validation.rb b/db/migrate/20120905125251_add_organisation_id_to_file_validation.rb index 996bf8dba..79929414f 100644 --- a/db/migrate/20120905125251_add_organisation_id_to_file_validation.rb +++ b/db/migrate/20120905125251_add_organisation_id_to_file_validation.rb @@ -4,9 +4,9 @@ class AddOrganisationIdToFileValidation < ActiveRecord::Migration        f.belongs_to :organisation      end -    FileValidation.reset_column_information -    organisation = Organisation.find_or_create_by_name!("Chouette") -    FileValidation.update_all :organisation_id => organisation.id +    #FileValidation.reset_column_information +    #organisation = Organisation.find_or_create_by_name!("Chouette") +    #FileValidation.update_all :organisation_id => organisation.id    end  end diff --git a/db/migrate/20131028153043_add_bounds_to_referentials.rb b/db/migrate/20131028153043_add_bounds_to_referentials.rb new file mode 100644 index 000000000..013852e3f --- /dev/null +++ b/db/migrate/20131028153043_add_bounds_to_referentials.rb @@ -0,0 +1,7 @@ +class AddBoundsToReferentials < ActiveRecord::Migration +  def change +    change_table :referentials do |t| +      t.text :geographical_bounds +    end +  end +end diff --git a/db/migrate/20131029092608_drop_import_log_messages.rb b/db/migrate/20131029092608_drop_import_log_messages.rb new file mode 100644 index 000000000..98b17a42e --- /dev/null +++ b/db/migrate/20131029092608_drop_import_log_messages.rb @@ -0,0 +1,24 @@ +class DropImportLogMessages < ActiveRecord::Migration +  def up +    if table_exists? :import_log_messages +      execute "DROP TABLE import_log_messages" # fix Foreigner bug < 1.5.0 +      # drop_table :import_log_messages +    end +  end + +  def down +    unless table_exists? :import_log_messages +      create_table :import_log_messages do |t| +        t.belongs_to :import +        t.string :key +        t.string :arguments,:limit => 1000 +        t.integer :position +        t.string :severity +        t.timestamps +      end +      add_index :import_log_messages, :import_id +    end +  end +   + +end diff --git a/db/migrate/20131029105107_drop_imports.rb b/db/migrate/20131029105107_drop_imports.rb new file mode 100644 index 000000000..12677fa1f --- /dev/null +++ b/db/migrate/20131029105107_drop_imports.rb @@ -0,0 +1,23 @@ +class DropImports < ActiveRecord::Migration +  def up +    if table_exists? :imports +      execute "DROP TABLE imports" # fix Foreigner bug < 1.5.0 +      # drop_table :imports +    end +  end + +  def down +    unless table_exists? :imports +      create_table :imports do |t| +        t.belongs_to :referential +        t.string :status +        t.string :type +        t.string :options +        t.string :file_type +        t.timestamps +      end +      add_index :imports, :referential_id +    end +  end +   +end diff --git a/db/migrate/20131029110239_create_import_tasks.rb b/db/migrate/20131029110239_create_import_tasks.rb new file mode 100644 index 000000000..fa2faec37 --- /dev/null +++ b/db/migrate/20131029110239_create_import_tasks.rb @@ -0,0 +1,27 @@ +class CreateImportTasks < ActiveRecord::Migration +  def up +    unless table_exists? :import_tasks +      create_table :import_tasks do |t| +        t.belongs_to :referential ,:limit => 8 +        t.string :status        # pending processing completed failed +        t.string :format        # NEPTUNE, CSV, NETEX, GTFS +        t.boolean :no_save      # processing no save on database (exclude level 3 conformity testing) +        t.text :parameter_set   # all parameters needed to execute the import operation +        t.integer :user_id ,:limit => 8     # id to the user who has requested this task (may be nil) +        t.string :user_name     # name of the user who has requested this task +        t.string  :file_path    # saved file +        t.text :result          # import report : objects statistics +        t.text :progress_info   # percentage of progress and step code +        t.timestamps +        t.foreign_key :referentials, :dependent => :delete +      end +    end +  end + +  def down +    if table_exists? :import_tasks +      execute "drop table import_tasks" +      # drop_table :import_tasks +    end +  end +end diff --git a/db/migrate/20131029115751_create_compliance_check_tasks.rb b/db/migrate/20131029115751_create_compliance_check_tasks.rb new file mode 100644 index 000000000..9195556b2 --- /dev/null +++ b/db/migrate/20131029115751_create_compliance_check_tasks.rb @@ -0,0 +1,26 @@ +class CreateComplianceCheckTasks < ActiveRecord::Migration +  def up +    unless table_exists? :compliance_check_tasks +      create_table :compliance_check_tasks do |t| +        t.belongs_to :referential, :null => :no ,:limit => 8 +        t.belongs_to :import_task ,:limit => 8 # optional +        t.string :status      # global status of conformity checking +        t.string :parameter_set_name       # name of parameter set used for testing +        t.text :parameter_set   # all parameters needed to execute the import operation +        t.integer :user_id  ,:limit => 8    # id to the user who has requested this task (may be nil) +        t.string :user_name     # name of the user who has requested this task +        t.text :progress_info # percentage of progress and step code +        t.timestamps +        t.foreign_key :referentials, :dependent => :delete +        t.foreign_key :import_tasks, :dependent => :delete +      end +    end +  end + +  def down +    if table_exists? :compliance_check_tasks +      execute "drop table compliance_check_tasks" +      # drop_table :compliance_check_tasks +    end +  end +end 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..8b72aa4c0 --- /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 +        t.foreign_key :compliance_check_tasks, :dependent => :delete +      end +    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/20131104110509_create_rule_parameter_sets.rb b/db/migrate/20131104110509_create_rule_parameter_sets.rb new file mode 100644 index 000000000..b2ceb0dbb --- /dev/null +++ b/db/migrate/20131104110509_create_rule_parameter_sets.rb @@ -0,0 +1,19 @@ +class CreateRuleParameterSets < ActiveRecord::Migration +  def up +    unless table_exists? :rule_parameter_sets +      create_table :rule_parameter_sets do |a| +        a.belongs_to :referential ,:limit => 8 +        a.text :parameters +        a.string :name +        a.timestamps +      end +    end +  end + +  def down +    if table_exists? :rule_parameter_sets +      execute "drop table rule_parameter_sets" +      # drop_table :rule_parameter_sets +    end +  end +end diff --git a/db/migrate/20131105063323_create_transport_mode_parameter_sets.rb b/db/migrate/20131105063323_create_transport_mode_parameter_sets.rb new file mode 100644 index 000000000..307a7f4db --- /dev/null +++ b/db/migrate/20131105063323_create_transport_mode_parameter_sets.rb @@ -0,0 +1,20 @@ +class CreateTransportModeParameterSets < ActiveRecord::Migration +  def up +    unless table_exists? :transport_mode_parameter_sets +      create_table :transport_mode_parameter_sets do |a| +	a.belongs_to :rule_parameter_set  ,:limit => 8 +	a.string :transport_mode +	a.text :parameters +	a.timestamps +      end +    end +  end + +  def down +    if table_exists? :transport_mode_parameter_sets +      execute "drop table transport_mode_parameter_sets" +      # drop_table :transport_mode_parameter_sets +    end +     +  end +end diff --git a/db/migrate/20131220083200_drop_file_validation.rb b/db/migrate/20131220083200_drop_file_validation.rb new file mode 100644 index 000000000..ff774310c --- /dev/null +++ b/db/migrate/20131220083200_drop_file_validation.rb @@ -0,0 +1,14 @@ +class DropFileValidation < ActiveRecord::Migration +  def change +    if table_exists? :file_validation_log_messages +      execute "drop table file_validation_log_messages" +      # drop_table :file_validation_log_messages +    end + +    if table_exists? :file_validations +      execute "drop table file_validations" +      # drop_table :file_validations +    end +     +  end +end diff --git a/db/migrate/20131220215103_add_reference_to_compliance_check_task.rb b/db/migrate/20131220215103_add_reference_to_compliance_check_task.rb new file mode 100644 index 000000000..225c1a974 --- /dev/null +++ b/db/migrate/20131220215103_add_reference_to_compliance_check_task.rb @@ -0,0 +1,7 @@ +class AddReferenceToComplianceCheckTask < ActiveRecord::Migration +  def change +    change_table :compliance_check_tasks do |t| +      t.string :references_type, :reference_ids +    end +  end +end diff --git a/db/migrate/20140106084920_add_rule_code_parts_to_compilance_check_results.rb b/db/migrate/20140106084920_add_rule_code_parts_to_compilance_check_results.rb new file mode 100644 index 000000000..f494a0428 --- /dev/null +++ b/db/migrate/20140106084920_add_rule_code_parts_to_compilance_check_results.rb @@ -0,0 +1,8 @@ +class AddRuleCodePartsToCompilanceCheckResults < ActiveRecord::Migration +  def change +    change_table :compliance_check_results do |t| +      t.string  :rule_target, :rule_format +      t.integer :rule_level, :rule_number +    end +  end +end diff --git a/db/migrate/20140107084816_insert_rule_parameter_sets.rb b/db/migrate/20140107084816_insert_rule_parameter_sets.rb new file mode 100644 index 000000000..fd951c765 --- /dev/null +++ b/db/migrate/20140107084816_insert_rule_parameter_sets.rb @@ -0,0 +1,10 @@ +class InsertRuleParameterSets < ActiveRecord::Migration +  def up +    Referential.all.each do |referential| +      RuleParameterSet.default_for_all_modes( referential).save if referential.rule_parameter_sets.empty? +    end +  end + +  def down +  end +end diff --git a/db/migrate/20140110090743_add_user_id_name_to_referential.rb b/db/migrate/20140110090743_add_user_id_name_to_referential.rb new file mode 100644 index 000000000..127ba5937 --- /dev/null +++ b/db/migrate/20140110090743_add_user_id_name_to_referential.rb @@ -0,0 +1,6 @@ +class AddUserIdNameToReferential < ActiveRecord::Migration +  def change +    add_column :referentials, :user_id, :integer, :limit => 8 +    add_column :referentials, :user_name, :string +  end +end diff --git a/db/migrate/20140113094406_move_options_to_parameter_set_import_task.rb b/db/migrate/20140113094406_move_options_to_parameter_set_import_task.rb new file mode 100644 index 000000000..cb12aa3c4 --- /dev/null +++ b/db/migrate/20140113094406_move_options_to_parameter_set_import_task.rb @@ -0,0 +1,19 @@ +class MoveOptionsToParameterSetImportTask < ActiveRecord::Migration +  def up +    ImportTask.all.each do |import| +      import.parameter_set.tap do |parameter_set| +        parameter_set = {} if parameter_set.nil? +        import.resources = "dummy" +        import.update_attribute :format, "Neptune" +        import.update_attribute :no_save, false +        result = import.update_attribute( :parameter_set, {  :no_save => import.attributes[ "no_save"], +                                                      :file_path => import.attributes[ "file_path"], +                                                      :format => import.attributes[ "format"]}.merge( parameter_set)) +        raise Exception.new("Echec id=#{import.id}, import.valid? #{import.valid?}, import.erros #{import.errors.inspect}") unless result +      end +    end +  end + +  def down +  end +end diff --git a/db/migrate/20140113103544_remove_format_no_save_file_path_from_import_task.rb b/db/migrate/20140113103544_remove_format_no_save_file_path_from_import_task.rb new file mode 100644 index 000000000..f1548e5b4 --- /dev/null +++ b/db/migrate/20140113103544_remove_format_no_save_file_path_from_import_task.rb @@ -0,0 +1,13 @@ +class RemoveFormatNoSaveFilePathFromImportTask < ActiveRecord::Migration +  def up +    remove_column :import_tasks, :no_save +    remove_column :import_tasks, :file_path +    remove_column :import_tasks, :format +  end + +  def down +    add_column :import_tasks, :no_save, :boolean +    add_column :import_tasks, :file_path, :datatype +    add_column :import_tasks, :format, :datatype +  end +end diff --git a/db/schema.rb b/db/schema.rb index f6e27009d..f6203e6d7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8  # This file is auto-generated from the current state of the database. Instead  # of editing this file, please use the migrations feature of Active Record to  # incrementally modify your database, and then regenerate this schema definition. @@ -10,7 +11,7 @@  #  # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130710123351) do +ActiveRecord::Schema.define(:version => 20140113103544) do    create_table "access_links", :force => true do |t|      t.integer  "access_point_id",                        :limit => 8 @@ -87,6 +88,36 @@ ActiveRecord::Schema.define(:version => 20130710123351) do    add_index "companies", ["objectid"], :name => "companies_objectid_key", :unique => true    add_index "companies", ["registration_number"], :name => "companies_registration_number_key", :unique => true +  create_table "compliance_check_results", :force => true do |t| +    t.integer  "compliance_check_task_id", :limit => 8 +    t.string   "rule_code" +    t.string   "severity" +    t.string   "status" +    t.integer  "violation_count" +    t.text     "detail" +    t.datetime "created_at",                            :null => false +    t.datetime "updated_at",                            :null => false +    t.string   "rule_target" +    t.string   "rule_format" +    t.integer  "rule_level" +    t.integer  "rule_number" +  end + +  create_table "compliance_check_tasks", :force => true do |t| +    t.integer  "referential_id",     :limit => 8 +    t.integer  "import_task_id",     :limit => 8 +    t.string   "status" +    t.string   "parameter_set_name" +    t.text     "parameter_set" +    t.integer  "user_id",            :limit => 8 +    t.string   "user_name" +    t.text     "progress_info" +    t.datetime "created_at",                      :null => false +    t.datetime "updated_at",                      :null => false +    t.string   "references_type" +    t.string   "reference_ids" +  end +    create_table "connection_links", :force => true do |t|      t.integer  "departure_id",                           :limit => 8      t.integer  "arrival_id",                             :limit => 8 @@ -182,28 +213,6 @@ ActiveRecord::Schema.define(:version => 20130710123351) do      t.integer "choice_code"    end -  create_table "file_validation_log_messages", :force => true do |t| -    t.integer  "file_validation_id", :limit => 8 -    t.string   "key" -    t.string   "arguments",          :limit => 1000 -    t.integer  "position" -    t.string   "severity" -    t.datetime "created_at",                         :null => false -    t.datetime "updated_at",                         :null => false -  end - -  add_index "file_validation_log_messages", ["file_validation_id"], :name => "index_file_validation_log_messages_on_file_validation_id" - -  create_table "file_validations", :force => true do |t| -    t.string   "status" -    t.string   "options",         :limit => 2000 -    t.string   "file_name" -    t.string   "file_type" -    t.datetime "created_at",                      :null => false -    t.datetime "updated_at",                      :null => false -    t.integer  "organisation_id", :limit => 8 -  end -    create_table "group_of_lines", :force => true do |t|      t.string   "objectid",       :null => false      t.integer  "object_version" @@ -220,30 +229,18 @@ ActiveRecord::Schema.define(:version => 20130710123351) do      t.integer "line_id",          :limit => 8    end -  create_table "import_log_messages", :force => true do |t| -    t.integer  "import_id",  :limit => 8 -    t.string   "key" -    t.string   "arguments",  :limit => 1000 -    t.integer  "position" -    t.string   "severity" -    t.datetime "created_at",                 :null => false -    t.datetime "updated_at",                 :null => false -  end - -  add_index "import_log_messages", ["import_id"], :name => "index_import_log_messages_on_import_id" - -  create_table "imports", :force => true do |t| +  create_table "import_tasks", :force => true do |t|      t.integer  "referential_id", :limit => 8      t.string   "status" +    t.text     "parameter_set" +    t.integer  "user_id",        :limit => 8 +    t.string   "user_name" +    t.text     "result" +    t.text     "progress_info"      t.datetime "created_at",                  :null => false      t.datetime "updated_at",                  :null => false -    t.string   "type" -    t.string   "options" -    t.string   "file_type"    end -  add_index "imports", ["referential_id"], :name => "index_imports_on_referential_id" -    create_table "journey_patterns", :force => true do |t|      t.integer  "route_id",                :limit => 8      t.string   "objectid",                             :null => false @@ -329,13 +326,16 @@ ActiveRecord::Schema.define(:version => 20130710123351) do    create_table "referentials", :force => true do |t|      t.string   "name"      t.string   "slug" -    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   "prefix"      t.string   "projection_type"      t.string   "time_zone"      t.string   "bounds" -    t.integer  "organisation_id", :limit => 8 +    t.integer  "organisation_id",     :limit => 8 +    t.text     "geographical_bounds" +    t.integer  "user_id",             :limit => 8 +    t.string   "user_name"    end    create_table "routes", :force => true do |t| @@ -360,6 +360,14 @@ ActiveRecord::Schema.define(:version => 20130710123351) do      t.integer "line_id",      :limit => 8    end +  create_table "rule_parameter_sets", :force => true do |t| +    t.integer  "referential_id", :limit => 8 +    t.text     "parameters" +    t.string   "name" +    t.datetime "created_at",                  :null => false +    t.datetime "updated_at",                  :null => false +  end +    create_table "stop_areas", :force => true do |t|      t.integer  "parent_id",                       :limit => 8      t.string   "objectid",                                                                     :null => false @@ -456,6 +464,14 @@ ActiveRecord::Schema.define(:version => 20130710123351) do    add_index "time_tables_vehicle_journeys", ["time_table_id"], :name => "index_time_tables_vehicle_journeys_on_time_table_id"    add_index "time_tables_vehicle_journeys", ["vehicle_journey_id"], :name => "index_time_tables_vehicle_journeys_on_vehicle_journey_id" +  create_table "transport_mode_parameter_sets", :force => true do |t| +    t.integer  "rule_parameter_set_id", :limit => 8 +    t.string   "transport_mode" +    t.text     "parameters" +    t.datetime "created_at",                         :null => false +    t.datetime "updated_at",                         :null => false +  end +    create_table "users", :force => true do |t|      t.string   "email",                                :default => "", :null => false      t.string   "encrypted_password",                   :default => "" @@ -532,12 +548,19 @@ ActiveRecord::Schema.define(:version => 20130710123351) do    add_foreign_key "access_points", "stop_areas", :name => "access_area_fkey", :dependent => :delete +  add_foreign_key "compliance_check_results", "compliance_check_tasks", :name => "compliance_check_results_compliance_check_task_id_fk", :dependent => :delete + +  add_foreign_key "compliance_check_tasks", "import_tasks", :name => "compliance_check_tasks_import_task_id_fk", :dependent => :delete +  add_foreign_key "compliance_check_tasks", "referentials", :name => "compliance_check_tasks_referential_id_fk", :dependent => :delete +    add_foreign_key "connection_links", "stop_areas", :name => "colk_endarea_fkey", :column => "arrival_id", :dependent => :delete    add_foreign_key "connection_links", "stop_areas", :name => "colk_startarea_fkey", :column => "departure_id", :dependent => :delete    add_foreign_key "group_of_lines_lines", "group_of_lines", :name => "groupofline_group_fkey", :dependent => :delete    add_foreign_key "group_of_lines_lines", "lines", :name => "groupofline_line_fkey", :dependent => :delete +  add_foreign_key "import_tasks", "referentials", :name => "import_tasks_referential_id_fk", :dependent => :delete +    add_foreign_key "journey_patterns", "routes", :name => "jp_route_fkey", :dependent => :delete    add_foreign_key "journey_patterns", "stop_points", :name => "arrival_point_fkey", :column => "arrival_stop_point_id", :dependent => :nullify    add_foreign_key "journey_patterns", "stop_points", :name => "departure_point_fkey", :column => "departure_stop_point_id", :dependent => :nullify  | 
