Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How we've migrated from Globalize to hstore-translate

Description and use

Migrating translations from Globalize to hstore-translate simplifies the schema, speeds up queries, and eases maintenance.

Problem

The Globalize gem was causing performance and maintenance issues in a Rails application that needed a more efficient way to store translations.

Outcome

The migration reduced the number of tables, simplified queries, and improved read/write performance for translated attributes.

Workflow

  • 1. Added the hstore extension to PostgreSQL.
  • 2. Created a migration to add an hstore column (e.g., translations) to each model that required translations.
  • 3. Wrote a script to copy existing Globalize data into the new hstore column, mapping locale keys to translated values.
  • 4. Updated model code to use the hstore_translate gem for accessing and setting translations via the hstore column.
  • 5. Removed Globalize gems and related tables from the schema.
  • 6. Ran tests and performed performance benchmarks to confirm improvements.

Evidence

We added the hstore extension and a new column to each model, then wrote a script to copy data from Globalize tables into the hstore column.

  • Record date: 2026-09-11T16:32:25.612Z