20171130000000_add_embed_url_to_preview_cards.rb 508 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. require Rails.root.join('lib', 'mastodon', 'migration_helpers')
  3. class AddEmbedURLToPreviewCards < ActiveRecord::Migration[5.2]
  4. include Mastodon::MigrationHelpers
  5. disable_ddl_transaction!
  6. def up
  7. safety_assured do
  8. add_column_with_default :preview_cards, :embed_url, :string, default: '', allow_null: false
  9. end
  10. end
  11. def down
  12. execute "UPDATE preview_cards SET url=embed_url WHERE embed_url!=''"
  13. remove_column :preview_cards, :embed_url
  14. end
  15. end