From 25d4efa71aa767255b9f24028b2b2ffcf0a3e80c Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Wed, 15 Feb 2023 09:59:02 +0100 Subject: [PATCH] fix(messages): migrate message bodys to richtext --- ...230215085312_migrate_message_body_to_action_text.rb | 10 ++++++++++ db/schema.rb | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20230215085312_migrate_message_body_to_action_text.rb diff --git a/db/migrate/20230215085312_migrate_message_body_to_action_text.rb b/db/migrate/20230215085312_migrate_message_body_to_action_text.rb new file mode 100644 index 00000000..64e01214 --- /dev/null +++ b/db/migrate/20230215085312_migrate_message_body_to_action_text.rb @@ -0,0 +1,10 @@ +class MigrateMessageBodyToActionText < ActiveRecord::Migration[7.0] + include ActionView::Helpers::TextHelper + def change + rename_column :messages, :body, :body_old + Message.all.each do |message| + message.update_attribute(:body, simple_format(message.body_old)) + end + remove_column :messages, :body_old + end +end diff --git a/db/schema.rb b/db/schema.rb index 9ba8eaf3..4c853039 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_02_09_105256) do +ActiveRecord::Schema[7.0].define(version: 2023_02_15_085312) do create_table "action_text_rich_texts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| t.string "name", null: false t.text "body", size: :long @@ -292,7 +292,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_09_105256) do create_table "messages", id: :integer, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| t.integer "sender_id" t.string "subject", null: false - t.text "body" t.boolean "private", default: false t.datetime "created_at", precision: nil t.integer "reply_to"