Replace composite_primary_keys with rails builtin support
This commit is contained in:
parent
3e085ece00
commit
46cd08b1c8
18 changed files with 18 additions and 36 deletions
1
Gemfile
1
Gemfile
|
@ -48,7 +48,6 @@ gem "active_record_union"
|
|||
gem "bootstrap", :github => "gravitystorm/bootstrap-rubygem", :branch => "dartsass_5_2_3"
|
||||
gem "bootstrap_form", "~> 5.0"
|
||||
gem "cancancan"
|
||||
# gem "composite_primary_keys", "~> 14.0.0"
|
||||
gem "config"
|
||||
gem "delayed_job_active_record"
|
||||
gem "frozen_record"
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#
|
||||
|
||||
class ChangesetTag < ApplicationRecord
|
||||
self.primary_keys = "changeset_id", "k"
|
||||
|
||||
belongs_to :changeset
|
||||
|
||||
validates :changeset, :associated => true
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#
|
||||
|
||||
class DiaryEntrySubscription < ApplicationRecord
|
||||
self.primary_keys = "user_id", "diary_entry_id"
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :diary_entry
|
||||
end
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
class NodeTag < ApplicationRecord
|
||||
self.table_name = "current_node_tags"
|
||||
self.primary_keys = "node_id", "k"
|
||||
|
||||
belongs_to :node
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ class OldNode < ApplicationRecord
|
|||
include ConsistencyValidations
|
||||
|
||||
self.table_name = "nodes"
|
||||
self.primary_keys = "node_id", "version"
|
||||
|
||||
# NOTE: this needs to be included after the table name changes, or
|
||||
# the queries generated by Redactable will use the wrong table name.
|
||||
|
@ -49,7 +48,7 @@ class OldNode < ApplicationRecord
|
|||
belongs_to :redaction, :optional => true
|
||||
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], :inverse_of => :old_node
|
||||
has_many :old_tags, :class_name => "OldNodeTag", :query_constraints => [:node_id, :version], :inverse_of => :old_node
|
||||
|
||||
def validate_position
|
||||
errors.add(:base, "Node is not in the world") unless in_world?
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# node_tags_id_fkey (node_id => nodes.node_id)
|
||||
# node_tags_id_fkey (["node_id", "version"] => nodes.["node_id", "version"])
|
||||
#
|
||||
|
||||
class OldNodeTag < ApplicationRecord
|
||||
self.table_name = "node_tags"
|
||||
self.primary_keys = "node_id", "version", "k"
|
||||
|
||||
belongs_to :old_node, :foreign_key => [:node_id, :version], :inverse_of => :old_tags
|
||||
belongs_to :old_node, :query_constraints => [:node_id, :version], :inverse_of => :old_tags
|
||||
|
||||
validates :old_node, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
|
||||
|
|
|
@ -24,7 +24,6 @@ class OldRelation < ApplicationRecord
|
|||
include ConsistencyValidations
|
||||
|
||||
self.table_name = "relations"
|
||||
self.primary_keys = "relation_id", "version"
|
||||
|
||||
# NOTE: this needs to be included after the table name changes, or
|
||||
# the queries generated by Redactable will use the wrong table name.
|
||||
|
@ -34,8 +33,8 @@ class OldRelation < ApplicationRecord
|
|||
belongs_to :redaction, :optional => true
|
||||
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], :inverse_of => :old_relation
|
||||
has_many :old_tags, :class_name => "OldRelationTag", :foreign_key => [:relation_id, :version], :inverse_of => :old_relation
|
||||
has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :query_constraints => [:relation_id, :version], :inverse_of => :old_relation
|
||||
has_many :old_tags, :class_name => "OldRelationTag", :query_constraints => [:relation_id, :version], :inverse_of => :old_relation
|
||||
|
||||
validates :changeset, :associated => true
|
||||
validates :timestamp, :presence => true
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# relation_members_id_fkey (relation_id => relations.relation_id)
|
||||
# relation_members_id_fkey (["relation_id", "version"] => relations.["relation_id", "version"])
|
||||
#
|
||||
|
||||
class OldRelationMember < ApplicationRecord
|
||||
self.table_name = "relation_members"
|
||||
self.primary_keys = "relation_id", "version", "sequence_id"
|
||||
self.primary_key = %w[relation_id version sequence_id]
|
||||
|
||||
belongs_to :old_relation, :foreign_key => [:relation_id, :version], :inverse_of => :old_members
|
||||
belongs_to :old_relation, :query_constraints => [:relation_id, :version], :inverse_of => :old_members
|
||||
# A bit messy, referring to the current tables, should do for the data browser for now
|
||||
belongs_to :member, :polymorphic => true
|
||||
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# relation_tags_id_fkey (relation_id => relations.relation_id)
|
||||
# relation_tags_id_fkey (["relation_id", "version"] => relations.["relation_id", "version"])
|
||||
#
|
||||
|
||||
class OldRelationTag < ApplicationRecord
|
||||
self.table_name = "relation_tags"
|
||||
self.primary_keys = "relation_id", "version", "k"
|
||||
|
||||
belongs_to :old_relation, :foreign_key => [:relation_id, :version], :inverse_of => :old_tags
|
||||
belongs_to :old_relation, :query_constraints => [:relation_id, :version], :inverse_of => :old_tags
|
||||
|
||||
validates :old_relation, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
|
||||
|
|
|
@ -24,7 +24,6 @@ class OldWay < ApplicationRecord
|
|||
include ConsistencyValidations
|
||||
|
||||
self.table_name = "ways"
|
||||
self.primary_keys = "way_id", "version"
|
||||
|
||||
# NOTE: this needs to be included after the table name changes, or
|
||||
# the queries generated by Redactable will use the wrong table name.
|
||||
|
@ -34,8 +33,8 @@ class OldWay < ApplicationRecord
|
|||
belongs_to :redaction, :optional => true
|
||||
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], :inverse_of => :old_way
|
||||
has_many :old_tags, :class_name => "OldWayTag", :foreign_key => [:way_id, :version], :inverse_of => :old_way
|
||||
has_many :old_nodes, :class_name => "OldWayNode", :query_constraints => [:way_id, :version], :inverse_of => :old_way
|
||||
has_many :old_tags, :class_name => "OldWayTag", :query_constraints => [:way_id, :version], :inverse_of => :old_way
|
||||
|
||||
validates :changeset, :associated => true
|
||||
validates :timestamp, :presence => true
|
||||
|
|
|
@ -13,14 +13,13 @@
|
|||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# way_nodes_id_fkey (way_id => ways.way_id)
|
||||
# way_nodes_id_fkey (["way_id", "version"] => ways.["way_id", "version"])
|
||||
#
|
||||
|
||||
class OldWayNode < ApplicationRecord
|
||||
self.table_name = "way_nodes"
|
||||
self.primary_keys = "way_id", "version", "sequence_id"
|
||||
|
||||
belongs_to :old_way, :foreign_key => [:way_id, :version], :inverse_of => :old_nodes
|
||||
belongs_to :old_way, :query_constraints => [:way_id, :version], :inverse_of => :old_nodes
|
||||
# A bit messy, referring to current nodes and ways, should do for the data browser for now
|
||||
belongs_to :node
|
||||
belongs_to :way
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# way_tags_id_fkey (way_id => ways.way_id)
|
||||
# way_tags_id_fkey (["way_id", "version"] => ways.["way_id", "version"])
|
||||
#
|
||||
|
||||
class OldWayTag < ApplicationRecord
|
||||
self.table_name = "way_tags"
|
||||
self.primary_keys = "way_id", "version", "k"
|
||||
|
||||
belongs_to :old_way, :foreign_key => [:way_id, :version], :inverse_of => :old_tags
|
||||
belongs_to :old_way, :query_constraints => [:way_id, :version], :inverse_of => :old_tags
|
||||
|
||||
validates :old_way, :associated => true
|
||||
validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }, :characters => true
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
class RelationMember < ApplicationRecord
|
||||
self.table_name = "current_relation_members"
|
||||
self.primary_keys = "relation_id", "sequence_id"
|
||||
self.primary_key = %w[relation_id sequence_id]
|
||||
|
||||
belongs_to :relation
|
||||
belongs_to :member, :polymorphic => true
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
class RelationTag < ApplicationRecord
|
||||
self.table_name = "current_relation_tags"
|
||||
self.primary_keys = "relation_id", "k"
|
||||
|
||||
belongs_to :relation
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#
|
||||
|
||||
class UserPreference < ApplicationRecord
|
||||
self.primary_keys = "user_id", "k"
|
||||
|
||||
belongs_to :user
|
||||
|
||||
validates :user, :associated => true
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
class WayNode < ApplicationRecord
|
||||
self.table_name = "current_way_nodes"
|
||||
self.primary_keys = "way_id", "sequence_id"
|
||||
|
||||
belongs_to :way
|
||||
belongs_to :node
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
class WayTag < ApplicationRecord
|
||||
self.table_name = "current_way_tags"
|
||||
self.primary_keys = "way_id", "k"
|
||||
|
||||
belongs_to :way
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ module Api
|
|||
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>"
|
||||
put node_create_path, :params => xml, :headers => auth_header
|
||||
assert_response :bad_request, "node upload did not return bad_request status"
|
||||
assert_equal ["NodeTag ", " v: is too long (maximum is 255 characters) (\"#{'x' * 256}\")"], @response.body.split(/[0-9]+,foo:/)
|
||||
assert_match(/ v: is too long \(maximum is 255 characters\) /, @response.body)
|
||||
end
|
||||
|
||||
def test_show
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue