Estou tendo um erro ao criar uma Constraint.
O que poderia ser?
Segue a baixo:
*Query:*
BEGIN;
ALTER TABLE integrations.accounts
DROP COLUMN IF EXISTS myob_settings,
ADD COLUMN myob_settings JSON;
COMMENT ON COLUMN integrations.accounts.myob_settings IS 'Settings for
> MYOB';
ALTER TABLE integrations.bill_items
DROP COLUMN IF EXISTS myob_id,
ADD COLUMN myob_id integrations.FOREIGN_IDENTIFIER;
COMMENT ON COLUMN integrations.bill_items.myob_id IS 'Foreign key for MYOB';
ALTER TABLE integrations.billables
DROP COLUMN IF EXISTS myob_id,
ADD COLUMN myob_id integrations.FOREIGN_IDENTIFIER;
COMMENT ON COLUMN integrations.billables.myob_id IS 'Foreign key for MYOB';
ALTER TABLE integrations.customers
DROP COLUMN IF EXISTS myob_id,
ADD COLUMN myob_id integrations.FOREIGN_IDENTIFIER;
COMMENT ON COLUMN integrations.customers.myob_id IS 'Foreign key for MYOB';
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.taxes
DROP COLUMN IF EXISTS myob_id,
ADD COLUMN myob_id integrations.FOREIGN_IDENTIFIER;
COMMENT ON COLUMN integrations.taxes.myob_id IS 'Foreign key for MYOB';
ALTER TABLE integrations.accounts DROP CONSTRAINT IF EXISTS
> cc_at_least_one_setting_needed,
ADD CONSTRAINT cc_at_least_one_setting_needed CHECK ((("qb_settings" IS NOT
> NULL) :: INTEGER +
("xero_settings" IS
> NOT NULL) :: INTEGER +
> ("freshbooks_settings" IS NOT NULL) :: INTEGER +
("myob_settings" IS
> NOT NULL) :: INTEGER +
("ppy_settings" IS
> NOT NULL) :: INTEGER) > 0);
ALTER TABLE integrations.bill_items 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 +
> ("unleashed_id_purchase" IS NOT NULL) :: INTEGER +
("myob_id" IS NOT
> NULL) :: INTEGER +
("ppy_id" IS NOT
> NULL) :: INTEGER) > 0);
ALTER TABLE integrations.billables 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 +
("unleashed_id" IS
> NOT NULL) :: INTEGER +
("csv_data" IS NOT
> NULL) :: INTEGER +
("myob_id" IS NOT
> NULL) :: INTEGER) > 0);
ALTER TABLE integrations.bills 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 +
("unleashed_response"
> IS NOT NULL) :: INTEGER +
("myob_id" IS NOT
> NULL) :: INTEGER) > 0);
ALTER TABLE integrations.customers 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 +
("csv_data" IS NOT
> NULL) :: INTEGER +
("myob_id" IS NOT
> NULL) :: INTEGER +
("ppy_id" IS NOT
> NULL) :: INTEGER) > 0);
ALTER TABLE integrations.invoices 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) > 0);
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);
ALTER TABLE integrations.taxes DROP CONSTRAINT IF EXISTS
> cc_at_least_one_mapping_needed,
ADD CONSTRAINT cc_at_least_one_mapping_needed CHECK ((("freshbooks_id" IS
> NOT NULL) :: INTEGER +
("myob_id" IS NOT
> NULL) :: INTEGER) > 0);
DROP INDEX IF EXISTS integrations.ix_bill_items_myob_ids;
CREATE INDEX ix_bill_items_myob_ids ON integrations.bill_items USING BTREE
> (myob_id)
WHERE myob_id IS NOT NULL;
DROP INDEX IF EXISTS integrations.ix_billables_myob_ids;
CREATE INDEX ix_billables_myob_ids ON integrations.billables USING BTREE
> (myob_id)
WHERE myob_id IS NOT NULL;
DROP INDEX IF EXISTS integrations.ix_customers_myob_ids_ids;
CREATE INDEX ix_customers_myob_ids_ids ON integrations.customers USING
> BTREE (myob_id)
WHERE myob_id IS NOT NULL;
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;
DROP INDEX IF EXISTS integrations.ix_taxes_myob_ids;
CREATE INDEX ix_taxes_myob_ids ON integrations.taxes USING BTREE (myob_id)
WHERE myob_id IS NOT NULL;
ROLLBACK;
*ERROR:*
ERROR: check constraint "cc_at_least_one_mapping_needed" is violated by
> some row
ERROR: current transaction is aborted, commands ignored until end of
> transaction block
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral