From 1e53f000320ea53b843f87c967862dcfb5ee5c3a Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 16 Feb 2022 23:42:00 +0100 Subject: [PATCH] Add migration for converting smiles to reaction appendable --- app/models/appendable/reaction.rb | 2 ++ db/migrate/20220216150127_move_smiles_to_appendables.rb | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 app/models/appendable/reaction.rb create mode 100644 db/migrate/20220216150127_move_smiles_to_appendables.rb diff --git a/app/models/appendable/reaction.rb b/app/models/appendable/reaction.rb new file mode 100644 index 00000000..51283ff4 --- /dev/null +++ b/app/models/appendable/reaction.rb @@ -0,0 +1,2 @@ +class Appendable::Reaction < Appendable +end diff --git a/db/migrate/20220216150127_move_smiles_to_appendables.rb b/db/migrate/20220216150127_move_smiles_to_appendables.rb new file mode 100644 index 00000000..2380e146 --- /dev/null +++ b/db/migrate/20220216150127_move_smiles_to_appendables.rb @@ -0,0 +1,6 @@ +class MoveSmilesToAppendables < ActiveRecord::Migration[6.1] + def up_only + execute "INSERT INTO appendables (type, user_id, parent_id, parent_type, content, created_at, updated_at) +(SELECT 'Appendable::Reaction' AS type, user_id, answer_id as parent_id, 'Answer' as parent_type, '🙂' AS content, created_at, updated_at FROM smiles)" + end +end