Sha256: aed5f2b9e12cbc1df4b40bbed15bedf5f7d7b86c5d4d76adbdf1f068d1e474c6
Contents?: true
Size: 758 Bytes
Versions: 3
Compression:
Stored size: 758 Bytes
Contents
class AddEditorJsToPosts < ActiveRecord::Migration[7.0] def up # First, add a temporary column add_column :panda_cms_posts, :content_jsonb, :jsonb, default: {}, null: false # Copy data from the old column to the new one, converting to JSONB execute <<-SQL UPDATE panda_cms_posts SET content_jsonb = CASE WHEN content IS NULL THEN '{}'::jsonb WHEN content::text = '' THEN '{}'::jsonb ELSE content::jsonb END; SQL # Remove the old column remove_column :panda_cms_posts, :content # Rename the new column to the original name rename_column :panda_cms_posts, :content_jsonb, :content end def down change_column :panda_cms_posts, :content, :text end end
Version data entries
3 entries across 3 versions & 1 rubygems