aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2017-11-30 21:05:59 +0100
committerGitHub2017-11-30 21:05:59 +0100
commit887a5985c6aba4ae65fbdd7c0c40f30186a778f2 (patch)
tree7522f3c1b895b366df15875c66a6a31506f0b6e9
parent1031b589b41fa1e61f79a880a3fb6c3e7f90b5f4 (diff)
parentf98cd834d37b007ca8f30c48d8694e1f669f32a3 (diff)
downloadchouette-core-887a5985c6aba4ae65fbdd7c0c40f30186a778f2.tar.bz2
Merge pull request #134 from af83/5130-del_fk_compliance_ctrl_set_in_compliance_check_sets
5130 del fk compliance ctrl set in compliance check sets
-rw-r--r--db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb10
-rw-r--r--db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb8
-rw-r--r--db/schema.rb54
-rw-r--r--spec/db/schema_spec.rb2
-rw-r--r--spec/models/compliance_check_set_spec.rb10
5 files changed, 66 insertions, 18 deletions
diff --git a/db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb b/db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb
new file mode 100644
index 000000000..ea94a01c1
--- /dev/null
+++ b/db/migrate/20171130172926_delete_compliance_control_set_foreign_key_for_compliance_check_set.rb
@@ -0,0 +1,10 @@
+class DeleteComplianceControlSetForeignKeyForComplianceCheckSet < ActiveRecord::Migration
+
+ def up
+ remove_foreign_key :compliance_check_sets, :compliance_control_sets
+ end
+
+ def down
+ add_foreign_key :compliance_check_sets, :compliance_control_sets
+ end
+end
diff --git a/db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb b/db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb
new file mode 100644
index 000000000..b1e6ca0a6
--- /dev/null
+++ b/db/migrate/20171130180144_change_item_id_in_versions_to_bigint.rb
@@ -0,0 +1,8 @@
+class ChangeItemIdInVersionsToBigint < ActiveRecord::Migration
+ def up
+ change_column :versions, :item_id, :integer, limit: 8, null: false
+ end
+ def down
+ change_column :versions, :item_id, :integer, null: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 323d68509..c6c3bef7e 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: 20171123110204) do
+ActiveRecord::Schema.define(version: 20171130180144) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -279,6 +279,22 @@ ActiveRecord::Schema.define(version: 20171123110204) do
add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree
+ create_table "delayed_jobs", id: :bigserial, force: :cascade do |t|
+ t.integer "priority", default: 0
+ t.integer "attempts", default: 0
+ t.text "handler"
+ t.text "last_error"
+ t.datetime "run_at"
+ t.datetime "locked_at"
+ t.datetime "failed_at"
+ t.string "locked_by", limit: 255
+ t.string "queue", limit: 255
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
+
create_table "exports", id: :bigserial, force: :cascade do |t|
t.integer "referential_id", limit: 8
t.string "status"
@@ -398,12 +414,12 @@ ActiveRecord::Schema.define(version: 20171123110204) do
t.datetime "started_at"
t.datetime "ended_at"
t.string "token_download"
- t.string "type"
+ t.string "type", limit: 255
t.integer "parent_id", limit: 8
t.string "parent_type"
+ t.integer "current_step", default: 0
+ t.integer "total_steps", default: 0
t.datetime "notified_parent_at"
- t.integer "current_step", default: 0
- t.integer "total_steps", default: 0
t.string "creator"
end
@@ -541,6 +557,11 @@ ActiveRecord::Schema.define(version: 20171123110204) do
add_index "networks", ["objectid"], name: "networks_objectid_key", unique: true, using: :btree
add_index "networks", ["registration_number"], name: "networks_registration_number_key", using: :btree
+ create_table "object_id_factories", id: :bigserial, force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "organisations", id: :bigserial, force: :cascade do |t|
t.string "name"
t.datetime "created_at"
@@ -707,7 +728,7 @@ ActiveRecord::Schema.define(version: 20171123110204) 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"
@@ -715,8 +736,8 @@ ActiveRecord::Schema.define(version: 20171123110204) do
t.string "registration_number"
t.string "nearest_topic_name"
t.integer "fare_code"
- t.decimal "longitude", precision: 19, scale: 16
- t.decimal "latitude", precision: 19, scale: 16
+ t.decimal "longitude", precision: 19, scale: 16
+ t.decimal "latitude", precision: 19, scale: 16
t.string "long_lat_type"
t.string "country_code"
t.string "street_name"
@@ -734,7 +755,7 @@ ActiveRecord::Schema.define(version: 20171123110204) do
t.datetime "deleted_at"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "stif_type"
+ t.string "stif_type", limit: 255
end
add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree
@@ -804,17 +825,17 @@ ActiveRecord::Schema.define(version: 20171123110204) 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.integer "object_version", limit: 8, default: 1
+ t.string "objectid", null: false
+ t.integer "object_version", limit: 8, default: 1
t.string "version"
t.string "comment"
- t.integer "int_day_types", default: 0
+ t.integer "int_day_types", default: 0
t.date "start_date"
t.date "end_date"
t.integer "calendar_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
- t.string "color"
+ t.string "color", limit: 255
t.integer "created_from_id", limit: 8
t.string "checksum"
t.text "checksum_source"
@@ -929,9 +950,9 @@ ActiveRecord::Schema.define(version: 20171123110204) do
add_index "vehicle_journeys", ["route_id"], name: "index_vehicle_journeys_on_route_id", using: :btree
create_table "versions", id: :bigserial, force: :cascade do |t|
- t.string "item_type", null: false
- t.integer "item_id", null: false, limit: 8
- t.string "event", null: false
+ t.string "item_type", null: false
+ t.integer "item_id", limit: 8, null: false
+ t.string "event", null: false
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
@@ -961,7 +982,6 @@ ActiveRecord::Schema.define(version: 20171123110204) do
add_foreign_key "compliance_check_messages", "compliance_check_sets"
add_foreign_key "compliance_check_messages", "compliance_checks"
add_foreign_key "compliance_check_resources", "compliance_check_sets"
- 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"
@@ -971,7 +991,9 @@ ActiveRecord::Schema.define(version: 20171123110204) do
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
+ add_foreign_key "journey_frequencies", "vehicle_journeys", name: "journey_frequencies_vehicle_journey_id_fk", on_delete: :nullify
add_foreign_key "journey_frequencies", "vehicle_journeys", on_delete: :nullify
add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", on_delete: :cascade
add_foreign_key "journey_patterns", "stop_points", column: "arrival_stop_point_id", name: "arrival_point_fkey", on_delete: :nullify
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index a7fe0a162..585636124 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -44,6 +44,6 @@ Diff: #{diff}
def diff
RSpec::Support::Differ.new(
color: RSpec::Matchers.configuration.color?
- ).diff_as_string(@original, @expected)
+ ).diff_as_string(@expected, @original)
end
end
diff --git a/spec/models/compliance_check_set_spec.rb b/spec/models/compliance_check_set_spec.rb
index fbf0f035b..b981a68bb 100644
--- a/spec/models/compliance_check_set_spec.rb
+++ b/spec/models/compliance_check_set_spec.rb
@@ -5,7 +5,6 @@ RSpec.describe ComplianceCheckSet, type: :model do
expect(FactoryGirl.build(:compliance_check_set)).to be_valid
end
-
it { should belong_to :referential }
it { should belong_to :workbench }
it { should belong_to :compliance_control_set }
@@ -91,4 +90,13 @@ RSpec.describe ComplianceCheckSet, type: :model do
expect(check_set.update_status).to be true
end
end
+
+ describe 'possibility to delete the associated compliance_control_set' do
+ let!(:compliance_check_set) { create :compliance_check_set }
+
+ it do
+ expect{ compliance_check_set.compliance_control_set.delete }
+ .to change{ ComplianceControlSet.count }.by(-1)
+ end
+ end
end