validate :validate_position
belongs_to :changeset
- belongs_to :redaction
+ belongs_to :redaction, :optional => true
- belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id"
+ belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id", :inverse_of => :old_nodes
- has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version]
+ has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version], :inverse_of => :old_node
def validate_position
errors.add(:base, "Node is not in the world") unless in_world?
self.table_name = "node_tags"
self.primary_keys = "node_id", "version", "k"
- belongs_to :old_node, :foreign_key => [:node_id, :version]
+ belongs_to :old_node, :foreign_key => [:node_id, :version], :inverse_of => :old_tags
- validates :old_node, :presence => true, :associated => true
+ validates :old_node, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => [:node_id, :version] }
end
include Redactable
belongs_to :changeset
- belongs_to :redaction
+ belongs_to :redaction, :optional => true
- belongs_to :current_relation, :class_name => "Relation", :foreign_key => "relation_id"
+ belongs_to :current_relation, :class_name => "Relation", :foreign_key => "relation_id", :inverse_of => :old_relations
- has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version]
- has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version]
+ has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version], :inverse_of => :old_relation
+ has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version], :inverse_of => :old_relation
- validates :changeset, :presence => true, :associated => true
+ validates :changeset, :associated => true
validates :timestamp, :presence => true
validates :visible, :inclusion => [true, false]
self.table_name = "relation_tags"
self.primary_keys = "relation_id", "version", "k"
- belongs_to :old_relation, :foreign_key => [:relation_id, :version]
+ belongs_to :old_relation, :foreign_key => [:relation_id, :version], :inverse_of => :old_tags
- validates :old_relation, :presence => true, :associated => true
+ validates :old_relation, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => [:relation_id, :version] }
end
include Redactable
belongs_to :changeset
- belongs_to :redaction
+ belongs_to :redaction, :optional => true
- belongs_to :current_way, :class_name => "Way", :foreign_key => "way_id"
+ belongs_to :current_way, :class_name => "Way", :foreign_key => "way_id", :inverse_of => :old_ways
- has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version]
- has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version]
+ has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version], :inverse_of => :old_way
+ has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version], :inverse_of => :old_way
- validates :changeset, :presence => true, :associated => true
+ validates :changeset, :associated => true
validates :timestamp, :presence => true
validates :visible, :inclusion => [true, false]
self.table_name = "way_tags"
self.primary_keys = "way_id", "version", "k"
- belongs_to :old_way, :foreign_key => [:way_id, :version]
+ belongs_to :old_way, :foreign_key => [:way_id, :version], :inverse_of => :old_tags
- validates :old_way, :presence => true, :associated => true
+ validates :old_way, :associated => true
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
validates :k, :uniqueness => { :scope => [:way_id, :version] }
end