Skip to content

Commit f12600b

Browse files
committed
Supersede previous Mobility ADR
1 parent 33f3485 commit f12600b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ADR/ADR043-use-mobility-with-column-strategy.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Date: 2025-06-09
44

55
## Status
66

7-
Accepted
7+
Superseded by [ADR046: Use Mobility's table backend strategy to store translations](ADR046-use-mobility-table-backend-strategy.md).
88

99
## Context
1010

@@ -28,58 +28,74 @@ The main strategies for storing translations are:
2828
- essentially a variant of the serialized data strategy that takes advantage of PostgreSQL's jsonb column type to make data easier to query.
2929

3030
#### Translatable columns
31+
3132
Advantages:
33+
3234
- Simple to understand and work with
3335
- Easy to query
3436

3537
Disadvantages:
38+
3639
- Since new columns need to be added to every table for every language, the maintenance burden increases as the number of locales increases
3740
- Since every new model would require new columns, maintenance burden increases as number of models increases
3841
- Inefficient use of database space
3942

4043
We currently have a small number of models and locales which mitigates the main disadvantages, so this seems like a good option for us.
4144

4245
#### Model translation tables
46+
4347
Advantages:
48+
4449
- Scales well with locales (since all locales can use the same table)
4550
- Uses space more efficiently than translatable columns
4651

4752
Disadvantages:
53+
4854
- Adds one extra table per model, so maintenance burden increases as the number of models increases
4955
- Requires table joins, creating increased complexity and risk of performance issues
5056

5157
This could be a good option for us, since we have a small number of models.
5258

5359
#### Shared translation tables
60+
5461
Advantages
62+
5563
- Versatile, no additional migrations required when adding new locales or models
5664

5765
Disadvantages
66+
5867
- Requires more complex table joins, creating increased complexity and risk of performance issues
5968
- since tables don't map 1:1 with model tables, it's harder to keep the shared table up to date with attribute renames and dropped columns
6069

6170
This could work for for us, but might be needlessly complex for the number of models and locales we're currently expecting to have.
6271

6372
#### Serialized data
73+
6474
Advantages:
75+
6576
- Simple to understand and work with
6677

6778
Disavantages:
79+
6880
- Difficult to add constraints
6981
- Difficult to query
7082

71-
We recommend against this option - the PostgreSQl jsonb strategy is functionally similar with fewer disadvantages.
83+
We recommend against this option - the PostgreSQl jsonb strategy is functionally similar with fewer disadvantages.
7284

7385
#### PostgreSQL jsonb
86+
7487
Advantages:
88+
7589
- Simple to understand and work with
7690

7791
Disavantages:
92+
7893
- Difficult to add constraints
7994

8095
We think the inability to easily add database constraints makes this a poor option for our use case.
8196

8297
### Gems
98+
8399
There are a few popular Ruby gems for dealing with translations. We looked into:
84100

85101
- [Mobility](https://github.com/shioyama/mobility)
@@ -92,6 +108,7 @@ Of these, only Mobility and Globalize have received recent updates. Mobility is
92108
Mobility also supports all of the backend strategies we've looked at, with largely the same API for each, which means it would be helpful if we decided we wanted to change strategy later.
93109

94110
We also considered the possibility of implementing our own solution without using a gem. In this case we’d:
111+
95112
- Have one less dependency
96113
- Have more control over our implementation
97114
- Have to manage database changes manually
@@ -101,6 +118,7 @@ We also considered the possibility of implementing our own solution without usin
101118
## Decision
102119

103120
We have decided to:
121+
104122
- implement translatable columns for each translatable text field
105123
- use the Mobility gem, configured with the `:column` backend strategy, to manage this
106124

0 commit comments

Comments
 (0)