diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-06-02 14:34:26 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-06-07 17:36:55 +0200 |
commit | 4ff1aaedc29c65fca49d93fb781e3cc7d7006fba (patch) | |
tree | 2e694dee8e8ac6326dca314d851b008e0d86b4f8 /doc | |
parent | 5819ca1a249d1daf3b4feb655c217c98a1b70225 (diff) | |
download | gitlab-ce-4ff1aaedc29c65fca49d93fb781e3cc7d7006fba.tar.gz |
Document not using STIdocument-polymorphing-columns
Diffstat (limited to 'doc')
-rw-r--r-- | doc/development/README.md | 1 | ||||
-rw-r--r-- | doc/development/single_table_inheritance.md | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/development/README.md b/doc/development/README.md index 83eef9dadc3..40addfd8a4c 100644 --- a/doc/development/README.md +++ b/doc/development/README.md @@ -52,6 +52,7 @@ - [Foreign Keys & Associations](foreign_keys.md) - [Serializing Data](serializing_data.md) - [Polymorphic Associations](polymorphic_associations.md) +- [Single Table Inheritance](single_table_inheritance.md) ## i18n diff --git a/doc/development/single_table_inheritance.md b/doc/development/single_table_inheritance.md new file mode 100644 index 00000000000..27c3c4f3199 --- /dev/null +++ b/doc/development/single_table_inheritance.md @@ -0,0 +1,18 @@ +# Single Table Inheritance + +**Summary:** don't use Single Table Inheritance (STI), use separate tables +instead. + +Rails makes it possible to have multiple models stored in the same table and map +these rows to the correct models using a `type` column. This can be used to for +example store two different types of SSH keys in the same table. + +While tempting to use one should avoid this at all costs for the same reasons as +outlined in the document ["Polymorphic Associations"](polymorphic_associations.md). + +## Solution + +The solution is very simple: just use a separate table for every type you'd +otherwise store in the same table. For example, instead of having a `keys` table +with `type` set to either `Key` or `DeployKey` you'd have two separate tables: +`keys` and `deploy_keys`. |