Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
4ff1aaed
Commit
4ff1aaed
authored
Jun 02, 2017
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document not using STI
parent
5819ca1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
doc/development/README.md
doc/development/README.md
+1
-0
doc/development/single_table_inheritance.md
doc/development/single_table_inheritance.md
+18
-0
No files found.
doc/development/README.md
View file @
4ff1aaed
...
...
@@ -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
...
...
doc/development/single_table_inheritance.md
0 → 100644
View file @
4ff1aaed
# 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`
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment