From: Andy Allan Date: Wed, 2 Mar 2022 15:00:25 +0000 (+0000) Subject: Merge branch 'pull/3472' X-Git-Tag: live~1787 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/45487e1ff8e7d334792440a2b5b3b1067269bfaf Merge branch 'pull/3472' --- 45487e1ff8e7d334792440a2b5b3b1067269bfaf diff --cc app/models/old_node.rb index 979f7cb6b,1324c8139..4f5f074ab --- a/app/models/old_node.rb +++ b/app/models/old_node.rb @@@ -46,10 -46,10 +46,10 @@@ class OldNode < ApplicationRecor 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? diff --cc app/models/old_node_tag.rb index ec48c1c04,11a2efd5a..c710e48f1 --- a/app/models/old_node_tag.rb +++ b/app/models/old_node_tag.rb @@@ -16,9 -16,9 +16,9 @@@ class OldNodeTag < ApplicationRecor 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 diff --cc app/models/old_relation.rb index 39d53518d,71bd4b73d..7f9a747e6 --- a/app/models/old_relation.rb +++ b/app/models/old_relation.rb @@@ -31,13 -31,13 +31,13 @@@ class OldRelation < ApplicationRecor 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] diff --cc app/models/old_relation_tag.rb index 124c89ad5,1fccdf7a8..c3a183891 --- a/app/models/old_relation_tag.rb +++ b/app/models/old_relation_tag.rb @@@ -16,9 -16,9 +16,9 @@@ class OldRelationTag < ApplicationRecor 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 diff --cc app/models/old_way.rb index 8052899bf,1f00c46ba..acf88ddcf --- a/app/models/old_way.rb +++ b/app/models/old_way.rb @@@ -31,13 -31,13 +31,13 @@@ class OldWay < ApplicationRecor 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] diff --cc app/models/old_way_tag.rb index bbfffc2cb,e684199bf..0342cf344 --- a/app/models/old_way_tag.rb +++ b/app/models/old_way_tag.rb @@@ -16,9 -16,9 +16,9 @@@ class OldWayTag < ApplicationRecor 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