-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Postgres does not create indexes on columns with a foreign key. They have to be created manually. Our ColumnCheck for a FK usually looks something like:
ColumnCheck('space_id', fk='space_spaces.id', required=True)My proposal would be for that format throw an exception for "Foreign key has not specified an index." The new correct options would be:
# When an index exists
ColumnCheck('space_id', fk='space_spaces.id', required=True, index='ix_categories_space_id')
# When you specifically don't want an index for some reason
ColumnCheck('space_id', fk='space_spaces.id', required=True, index=False)This at least makes it explicit.
We could query the tables indexes and see if any index has the same column/name as the FK column as it's first column, but I think explicit/manual might be better here? Actually make the dev think about what they want to do with the indexes.
Metadata
Metadata
Assignees
Labels
No labels