debian-mirror-gitlab/lib/gitlab/database/postgres_foreign_key.rb

22 lines
695 B
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
module Gitlab
module Database
2021-11-11 11:23:49 +05:30
class PostgresForeignKey < SharedModel
2021-10-27 15:23:28 +05:30
self.primary_key = :oid
scope :by_referenced_table_identifier, ->(identifier) do
raise ArgumentError, "Referenced table name is not fully qualified with a schema: #{identifier}" unless identifier =~ /^\w+\.\w+$/
where(referenced_table_identifier: identifier)
end
2021-12-11 22:18:48 +05:30
scope :by_constrained_table_identifier, ->(identifier) do
raise ArgumentError, "Constrained table name is not fully qualified with a schema: #{identifier}" unless identifier =~ /^\w+\.\w+$/
where(constrained_table_identifier: identifier)
end
2021-10-27 15:23:28 +05:30
end
end
end