mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 14:15:35 +08:00
Fix migration
This commit is contained in:
parent
5964a1b1f4
commit
cb5baa3d13
1 changed files with 6 additions and 1 deletions
|
@ -4,7 +4,12 @@ class ConvertActivitiesJsonToJsonb < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
change_column :activities, :values, 'jsonb USING CAST(values AS jsonb)'
|
change_column :activities, :values, 'jsonb USING CAST(values AS jsonb)'
|
||||||
ActiveRecord::Base.connection.execute("
|
ActiveRecord::Base.connection.execute("
|
||||||
UPDATE activities SET values = REGEXP_REPLACE(values::text, '^\"||\"$||\\\\', '', 'g')::jsonb
|
UPDATE activities SET
|
||||||
|
values = REGEXP_REPLACE(
|
||||||
|
REGEXP_REPLACE(
|
||||||
|
REGEXP_REPLACE(values::text, '\\\\\"', '\"', 'g'),
|
||||||
|
'^\"||\"$', '', 'g'),
|
||||||
|
'\\\\\\\\', '\\\\', 'g')::jsonb
|
||||||
")
|
")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue