How we've migrated from globalize to hstore-translate
Описание и применение
Миграция из Globalize в hstore-translate упрощает схему и повышает производительность в Rails‑приложении.
Задача
Globalize was causing performance and maintenance issues in a Rails application that needed a more efficient way to store translations.
Результат
The migration reduced the number of tables, simplified the schema, and improved query performance for translated attributes.
Рабочий процесс
- 1. Added the hstore-translate gem to the Gemfile and ran bundle install.
- 2. Created a migration to add an hstore column to the target tables.
- 3. Updated the model to use
hstore_translateinstead of Globalize’stranslatesmacro. - 4. Wrote a data migration script to copy existing translations from Globalize tables into the new hstore column.
- 5. Ran the migration and verified data integrity via unit tests.
- 6. Removed Globalize-related code and tables from the application.
Доказательства
We decided to replace Globalize with hstore-translate because it was more lightweight and better suited to our needs.
The migration script copies data from the Globalize translation tables into the new hstore column.
- Дата записи: 2026-10-02T11:40:54.710Z