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

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_translate instead of Globalize’s translates macro.
  • 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