Commit bd1ef521 authored by Marcia Ramos's avatar Marcia Ramos

Merge branch 'add-note-for-fk-with-index' into 'master'

Add note for index requirement with FK constraint in migration_style_guide.md

See merge request gitlab-org/gitlab-ce!28003
parents 26d608cb ff14b58d
...@@ -186,7 +186,11 @@ end ...@@ -186,7 +186,11 @@ end
When adding a foreign-key constraint to either an existing or new When adding a foreign-key constraint to either an existing or new
column remember to also add a index on the column. column remember to also add a index on the column.
This is _required_ for all foreign-keys. This is **required** for all foreign-keys, e.g., to support efficient cascading
deleting: when a lot of rows in a table get deleted, the referenced records need
to be deleted too. The database has to look for corresponding records in the
referenced table. Without an index, this will result in a sequential scan on the
table which can take a long time.
Here's an example where we add a new column with a foreign key Here's an example where we add a new column with a foreign key
constraint. Note it includes `index: true` to create an index for it. constraint. Note it includes `index: true` to create an index for it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment