20170105224407_add_shortcode_to_media_attachments.rb 422 B

1234567891011121314
  1. class AddShortcodeToMediaAttachments < ActiveRecord::Migration[5.0]
  2. def up
  3. add_column :media_attachments, :shortcode, :string, null: true, default: nil
  4. add_index :media_attachments, :shortcode, unique: true
  5. # Migrate old links
  6. MediaAttachment.local.update_all('shortcode = id')
  7. end
  8. def down
  9. remove_index :media_attachments, :shortcode
  10. remove_column :media_attachments, :shortcode
  11. end
  12. end