blob: acc5dff99959bf2c5f4b7dce8ec70ca9baa9b987 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# frozen_string_literal: true
module Gitlab
module Database
module AsyncConstraints
class PostgresAsyncConstraintValidation < SharedModel
include QueueErrorHandlingConcern
self.table_name = 'postgres_async_foreign_key_validations'
MAX_IDENTIFIER_LENGTH = Gitlab::Database::MigrationHelpers::MAX_IDENTIFIER_NAME_LENGTH
MAX_LAST_ERROR_LENGTH = 10_000
validates :name, presence: true, uniqueness: { scope: :table_name }, length: { maximum: MAX_IDENTIFIER_LENGTH }
validates :table_name, presence: true, length: { maximum: MAX_IDENTIFIER_LENGTH }
enum constraint_type: { foreign_key: 0, check_constraint: 1 }
scope :ordered, -> { order(attempts: :asc, id: :asc) }
scope :foreign_key_type, -> { columns_hash.key?('constraint_type') ? foreign_key : all }
scope :check_constraint_type, -> { check_constraint }
def self.table_available?
connection.table_exists?(table_name)
end
end
end
end
end
|