Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate: false is always appended to schema dumps #310

Open
BuonOmo opened this issue Jan 22, 2024 · 0 comments
Open

validate: false is always appended to schema dumps #310

BuonOmo opened this issue Jan 22, 2024 · 0 comments
Labels
rails 7.1 issue introduced in rails 7.1

Comments

@BuonOmo
Copy link
Collaborator

BuonOmo commented Jan 22, 2024

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
@BuonOmo BuonOmo added the rails 7.1 issue introduced in rails 7.1 label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rails 7.1 issue introduced in rails 7.1
Projects
None yet
Development

No branches or pull requests

1 participant