I've got the following error: ERROR: check constraint "cc_at_least_one_mapping_needed" is violated by some row Query: ALTER TABLE integrations.tax_aggregates DROP COLUMN IF EXISTS myob_id, ADD COLUMN myob_id integrations.FOREIGN_IDENTIFIER; COMMENT ON COLUMN integrations.tax_aggregates.myob_id IS 'Foreign key for MYOB'; ALTER TABLE integrations.tax_aggregates DROP CONSTRAINT IF EXISTS cc_at_least_one_mapping_needed, ADD CONSTRAINT cc_at_least_one_mapping_needed CHECK ((("qb_id" IS NOT NULL) :: INTEGER + ("xero_id" IS NOT NULL) :: INTEGER + ("freshbooks_id" IS NOT NULL) :: INTEGER + ("myob_id" IS NOT NULL) :: INTEGER + ("ppy_id" IS NOT NULL) :: INTEGER) > 0); DROP INDEX IF EXISTS integrations.ix_tax_aggregates_myob_ids_ids; CREATE INDEX ix_tax_aggregates_myob_ids_ids ON integrations.tax_aggregates USING BTREE (myob_id) WHERE myob_id IS NOT NULL; Query 2: SELECT * FROM integrations.tax_aggregates WHERE NOT ((("qb_id" IS NOT NULL) :: INTEGER + ("xero_id" IS NOT NULL) :: INTEGER + ("freshbooks_id" IS NOT NULL) :: INTEGER + ("myob_id" IS NOT NULL) :: INTEGER + ("ppy_id" IS NOT NULL) :: INTEGER) > 0) **It retunrs 0 rows** TABLE: CREATE TABLE integrations.tax_aggregates ( tax_aggregate_id bigint NOT NULL, qb_id "integrations"."foreign_identifier" xero_id "integrations"."foreign_identifier" freshbooks_id "integrations"."foreign_identifier" myob_id "integrations"."foreign_identifier" ppy_id "integrations"."foreign_identifier" What am I doing wrong? How can I solve the problem? **UPDATED:** I got some rows with this query: SELECT * FROM integrations.customers WHERE NOT ((("qb_id" IS NOT NULL) :: INTEGER + ("xero_id" IS NOT NULL) :: INTEGER + ("freshbooks_id" IS NOT NULL) :: INTEGER + ("myob_id" IS NOT NULL) :: INTEGER + ("ppy_id" IS NOT NULL) :: INTEGER) > 0) So, it seems that the violation is in there! But still, I don't know how to solve the problem.