Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-06-08 11:30:26 +0300
committerFilipa Lacerda <filipa@gitlab.com>2017-06-08 11:30:26 +0300
commit86614aff8b65519b7513c1f7d99ec868411ab02e (patch)
treef9f674306478783a2e9c3034b2a1ff48bf838743 /doc/development/single_table_inheritance.md
parentc6d27eb8c18f50b13a740dfb7e1cb7f57fae22de (diff)
parentacdd1bf7c92b7e9cdbd579df8faca5ea7783489f (diff)
Merge branch 'master' into 33361-make-scroll-faster33361-make-scroll-faster
* master: (92 commits) Responsive table fixes remove the rouge copypasta and add notes to refactor nil-check Repository::is_ancestor? update rouge to 2.1.0 Added more negative checks for public project Fix End Syntax Error Enhancing Spec's with negative cases Improve form spec Update CHANGELOG.md for 9.0.10 Update CHANGELOG.md for 9.2.5 Fixed spec test syntax errors Update CHANGELOG.md for 9.1.7 Translate project & repository pages Converting Tests to Spec Tests Added more actions and report as abuse to all notes Add sticky confidential issue bar Fix for Login Test Problem Document not using STI Added Cop to blacklist polymorphic associations Document not using polymorphic associations ...
Diffstat (limited to 'doc/development/single_table_inheritance.md')
-rw-r--r--doc/development/single_table_inheritance.md18
1 files changed, 18 insertions, 0 deletions
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`.