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

Investigate missing index on auto-create foreign keys #98

Closed
aeneasr opened this issue Sep 1, 2020 · 1 comment · Fixed by #99
Closed

Investigate missing index on auto-create foreign keys #98

aeneasr opened this issue Sep 1, 2020 · 1 comment · Fixed by #99
Assignees
Labels
bug Something isn't working

Comments

@aeneasr
Copy link
Member

aeneasr commented Sep 1, 2020

The CRDB meta schema appears to ignore auto-generated indices used for foreign keys when the foreign key is part of the create table statement.

@aeneasr aeneasr added the bug Something isn't working label Sep 1, 2020
@aeneasr aeneasr self-assigned this Sep 1, 2020
@aeneasr
Copy link
Member Author

aeneasr commented Sep 1, 2020

To reproduce

create_table("identity_recovery_tokens") {
  t.Column("id", "uuid", {primary: true})

  t.ForeignKey("selfservice_recovery_request_id", {"selfservice_recovery_requests": ["id"]}, {"on_delete": "cascade"})
}

and later

change_column("identity_recovery_tokens", "selfservice_recovery_flow_id", "uuid", {"null": true})

aeneasr added a commit that referenced this issue Sep 3, 2020
This patch reverts a behavior introduced earlier and adds a test to prevent future regressions. With this patch, it is possible to use `change_column` on columns with foreign key references but without explicitly defined indices. Without this patch, those changes fail because CRDB needs an index on the referencing column when creating foreign key checks.

Closes #98
stanislas-m pushed a commit that referenced this issue Nov 4, 2020
This patch reverts a behavior introduced earlier and adds a test to prevent future regressions. With this patch, it is possible to use `change_column` on columns with foreign key references but without explicitly defined indices. Without this patch, those changes fail because CRDB needs an index on the referencing column when creating foreign key checks.

Closes #98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant