Fix referential integrity checks on polymorphic points associations
parent
8dac7cac76
commit
5798249045
|
@ -3,7 +3,7 @@
|
|||
# etc.
|
||||
class ToolSlot < ApplicationRecord
|
||||
belongs_to :tool
|
||||
has_one :point, as: :pointer, dependent: :destroy
|
||||
has_one :point, as: :pointer#, dependent: :destroy
|
||||
# has_many :sequence_dependencies, dependent: :destroy, as: :dependency
|
||||
validates_uniqueness_of :tool,
|
||||
allow_blank: true,
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
class AddPolymorphicConstraints < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_polymorphic_constraints :pointer, :tool_slots
|
||||
add_polymorphic_constraints :pointer, :plants
|
||||
add_polymorphic_constraints :pointer, :generic_pointers
|
||||
add_polymorphic_constraints :pointer,
|
||||
:points,
|
||||
polymorphic_models: [:plant,
|
||||
:tool_slot,
|
||||
:generic_pointer]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,10 @@ unless Rails.env == "production"
|
|||
ENV['MQTT_HOST'] = "blooper.io"
|
||||
ENV['OS_UPDATE_SERVER'] = "http://blah.com"
|
||||
ENV['FW_UPDATE_SERVER'] = "http://test.com"
|
||||
Point.destroy_all
|
||||
ToolSlot.destroy_all
|
||||
Device.destroy_all
|
||||
User.destroy_all
|
||||
Point.destroy_all
|
||||
Users::Create.run!(name: "Administrator",
|
||||
email: "notos@notos.com",
|
||||
password: "password123",
|
||||
|
|
|
@ -139,6 +139,6 @@ result.push(enum_type :LegalKindString, HASH[:nodes].map{ |x| x[:name] }.sort.un
|
|||
result.push(enum_type :LegalSequenceKind, CeleryScriptSettingsBag::STEPS.sort)
|
||||
result.push(enum_type :DataChangeType, CeleryScriptSettingsBag::ALLOWED_CHAGES)
|
||||
result.push(enum_type :ResourceName, CeleryScriptSettingsBag::RESOURCE_NAME)
|
||||
result.push(enum_type :PointType, CeleryScriptSettingsBag::ALLOWED_POINT_TYPE)
|
||||
result.push(enum_type :PointType, CeleryScriptSettingsBag::ALLOWED_POINTER_TYPE)
|
||||
|
||||
puts result.join.gsub("\n\n\n", "\n")
|
||||
|
|
Loading…
Reference in New Issue