Skip to content

Commit 6ce95e5

Browse files
committed
Merge branch 'main' of github.com:better-together-solutions/community-engine-rails
2 parents 77a86a8 + 421374d commit 6ce95e5

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
# Ensures that all transalted name attributes are stored as strings, not text
4+
class MigrateTranslatedNameAttributesToStrings < ActiveRecord::Migration[7.2]
5+
def up
6+
# Move community and partner name translations from text to string translations
7+
# This handles cases where names were incorrectly stored as text type
8+
9+
puts "Running mobility translation migration via rake task (with bulk operations)..."
10+
11+
# Execute the rake task that contains the migration logic
12+
# This allows the migration logic to be tested and executed independently
13+
# Uses bulk operations for optimal performance:
14+
# - insert_all() for creating string translations
15+
# - delete_all() for removing text translations
16+
# - Bypasses ActiveRecord callbacks (Elasticsearch indexing)
17+
begin
18+
Rake::Task['translations:mobility:migrate_names_to_string'].invoke
19+
rescue RuntimeError
20+
Rake::Task['app:translations:mobility:migrate_names_to_string'].invoke
21+
end
22+
end
23+
24+
def down
25+
# This migration is not easily reversible since we don't know which records
26+
# were originally in text translations vs string translations.
27+
# However, you can use the rake task system to create a reverse migration if needed.
28+
raise ActiveRecord::IrreversibleMigration,
29+
"Cannot reverse migration of name translations from text to string"
30+
end
31+
end

docs/assessments/content_management_system_review.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ class BlockTemplate < ApplicationRecord
700700
belongs_to :template_block, class_name: 'BetterTogether::Content::Block'
701701
belongs_to :creator, class_name: 'BetterTogether::Person'
702702

703-
translates :name, :description, type: :string
703+
translates :name, type: :string
704+
translates :description, backend: :action_text
704705

705706
validates :name, presence: true
706707
validates :category, presence: true,

docs/developers/systems/community_social_system.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ class Community < ApplicationRecord
218218
has_many :calendars, dependent: :destroy
219219
joinable joinable_type: 'community', member_type: 'person'
220220

221-
translates :name, :description
221+
translates :name, type: :string
222+
translates :description, backend: :action_text
222223
has_one_attached :profile_image, :cover_image, :logo
223224

224225
validates :name, presence: true

spec/dummy/db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.2].define(version: 2025_11_07_222131) do
13+
ActiveRecord::Schema[7.2].define(version: 2025_11_20_160356) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pg_catalog.plpgsql"
1616
enable_extension "pgcrypto"

0 commit comments

Comments
 (0)