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

How we've migrated from Globalize to hstore-translate

说明与用途

将翻译从 Globalize 迁移到 hstore-translate 简化了架构,加速了查询,并降低了维护成本。

问题

The Globalize gem 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 queries, and improved read/write performance for translated attributes.

工作流

  • 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.

证据

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.

  • 记录日期: 2026-09-11T16:32:25.612Z