How we've migrated from globalize to hstore-translate
Описание и применение
Перенос переводов из Globalize в hstore-translate в Rails 3.2 упрощает схему и повышает производительность.
Задача
The Rails application used Globalize for translations, which required separate tables and complex migrations; the team wanted a simpler, more efficient solution.
Результат
The migration consolidated translation storage, reduced database complexity, and improved performance while maintaining all existing translated content.
Рабочий процесс
- 1. Added the hstore extension to PostgreSQL.
- 2. Created a migration to add an hstore column to each translatable model.
- 3. Wrote a data migration script to copy existing Globalize translations into the new hstore column.
- 4. Updated the model code to use hstore-translate instead of Globalize.
- 5. Ran tests and verified data integrity.
- 6. Removed Globalize gems and tables from the project.
Доказательства
We added the hstore extension to PostgreSQL, created a migration to add an hstore column to each translatable model, and wrote a data migration script to copy existing Globalize translations into the new hstore column.
- Дата записи: 2026-09-22T09:15:35.599Z