summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/async_constraints/validators/check_constraint_spec.rb
blob: 7622b39feb11cb18ed51c681dfed7a3f07838404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Database::AsyncConstraints::Validators::CheckConstraint, feature_category: :database do
  it_behaves_like 'async constraints validation' do
    let(:constraint_type) { :check_constraint }

    before do
      connection.create_table(table_name) do |t|
        t.integer :parent_id
      end

      connection.execute(<<~SQL.squish)
        ALTER TABLE #{table_name} ADD CONSTRAINT #{constraint_name}
          CHECK ( parent_id = 101 ) NOT VALID;
      SQL
    end
  end
end