20170901141119_truncate_preview_cards.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # frozen_string_literal: true
  2. class TruncatePreviewCards < ActiveRecord::Migration[5.1]
  3. def up
  4. rename_table :preview_cards, :deprecated_preview_cards
  5. create_table :preview_cards do |t|
  6. t.string :url, default: '', null: false, index: { unique: true }
  7. t.string :title, default: '', null: false
  8. t.string :description, default: '', null: false
  9. # The following corresponds to `t.attachment :image` in an older version of Paperclip
  10. t.string :image_file_name
  11. t.string :image_content_type
  12. t.integer :image_file_size
  13. t.datetime :image_updated_at
  14. t.integer :type, default: 0, null: false
  15. t.text :html, default: '', null: false
  16. t.string :author_name, default: '', null: false
  17. t.string :author_url, default: '', null: false
  18. t.string :provider_name, default: '', null: false
  19. t.string :provider_url, default: '', null: false
  20. t.integer :width, default: 0, null: false
  21. t.integer :height, default: 0, null: false
  22. t.timestamps
  23. end
  24. end
  25. def down
  26. raise ActiveRecord::IrreversibleMigration, 'Previous preview cards table has already been removed' unless ActiveRecord::Base.connection.table_exists? 'deprecated_preview_cards'
  27. drop_table :preview_cards
  28. rename_table :deprecated_preview_cards, :preview_cards
  29. end
  30. end