mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 22:25:30 +08:00
15 lines
463 B
Ruby
15 lines
463 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ConvertActivitiesJsonToJsonb < ActiveRecord::Migration[5.2]
|
|
def change
|
|
change_column :activities, :values, 'jsonb USING CAST(values AS jsonb)'
|
|
ActiveRecord::Base.connection.execute("
|
|
UPDATE activities SET
|
|
values = REGEXP_REPLACE(
|
|
REGEXP_REPLACE(
|
|
REGEXP_REPLACE(values::text, '\\\\\"', '\"', 'g'),
|
|
'^\"||\"$', '', 'g'),
|
|
'\\\\\\\\', '\\\\', 'g')::jsonb
|
|
")
|
|
end
|
|
end
|