Add script to migrate existing events to the new format
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
class MigrateExistingEventsPrefixes < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
execute <<-SQL
|
||||
UPDATE events
|
||||
SET
|
||||
action = CASE
|
||||
WHEN action = 'commented' THEN 'comment_created'
|
||||
ELSE 'card_' || action
|
||||
END,
|
||||
eventable_id = CASE
|
||||
WHEN action = 'commented' THEN json_extract(particulars, '$.comment_id')
|
||||
ELSE eventable_id
|
||||
END,
|
||||
eventable_type = CASE
|
||||
WHEN action = 'commented' THEN 'Comment'
|
||||
ELSE eventable_type
|
||||
END;
|
||||
SQL
|
||||
end
|
||||
end
|
||||
Generated
+2
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2025_04_24_105223) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2025_04_25_070025) do
|
||||
create_table "accesses", force: :cascade do |t|
|
||||
t.integer "collection_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
@@ -292,6 +292,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_04_24_105223) do
|
||||
t.datetime "created_at", null: false
|
||||
t.string "title"
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["title"], name: "index_tags_on_account_id_and_title", unique: true
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
|
||||
+18
-2
@@ -1941,7 +1941,23 @@ indexes:
|
||||
nulls_not_distinct:
|
||||
comment:
|
||||
valid: true
|
||||
tags: []
|
||||
tags:
|
||||
- !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition
|
||||
table: tags
|
||||
name: index_tags_on_account_id_and_title
|
||||
unique: true
|
||||
columns:
|
||||
- title
|
||||
lengths: {}
|
||||
orders: {}
|
||||
opclasses: {}
|
||||
where:
|
||||
type:
|
||||
using:
|
||||
include:
|
||||
nulls_not_distinct:
|
||||
comment:
|
||||
valid: true
|
||||
users:
|
||||
- !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition
|
||||
table: users
|
||||
@@ -2026,4 +2042,4 @@ indexes:
|
||||
comment:
|
||||
valid: true
|
||||
workflows: []
|
||||
version: 20250424105223
|
||||
version: 20250425070025
|
||||
|
||||
Reference in New Issue
Block a user