Skip to content

validate: false is always appended to schema dumps #310

@BuonOmo

Description

@BuonOmo

All of these tests are failing:

  • test_dump_foreign_key_targeting_different_schema
  • test_schema_dumping
  • test_schema_dumping_on_delete_and_on_update_options
  • test_schema_dumping_with_validate_false
  • test_schema_dumping_with_validate_true
  • test_schema_dumping_with_custom_fk_ignore_pattern

I haven't verified for all of them, but for most the bug is actually that the fk is not validated. This likely comes from :

https://github.com/cockroachdb/cockroach/blob/bfd7d1dfd002cf8b7d504d9732e2ae494c1abb9b/pkg/sql/backfill.go#L2593-L2605

We can't support adding a validated foreign key constraint in the same
transaction as the CREATE TABLE statement. This would require adding
the backreference to the other table and then validating the constraint
for whatever rows were inserted into the referencing table in this
transaction, which requires multiple schema changer states across
multiple transactions.

We could partially fix this by queuing a validation job to run post-
transaction. Better yet would be to absorb this into the transactional
schema change framework eventually.

For now, just always add the FK as unvalidated.

 fk.ForeignKeyDesc().Validity = descpb.ConstraintValidity_Unvalidated

Metadata

Metadata

Assignees

No one assigned

    Labels

    rails 7.1issue introduced in rails 7.1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions