Class: CreateImageRotators

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/templates/db/migrate/create_image_rotators.rb

Class Method Summary collapse

Class Method Details

.downObject



29
30
31
32
33
34
# File 'lib/generators/templates/db/migrate/create_image_rotators.rb', line 29

def self.down
  UserPlugin.destroy_all({:name => "image_rotators"})

  drop_table :image_rotator_images
  drop_table :image_rotators
end

.upObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/templates/db/migrate/create_image_rotators.rb', line 3

def self.up
  create_table :image_rotators do |t|
    t.string :title
    t.string :height
    t.string :width

    t.timestamps
  end

  add_index :image_rotators, :id

  load(Rails.root.join('db', 'seeds', 'image_rotators.rb'))

  create_table :image_rotator_images do |t|
    t.integer :image_rotator_id
    t.integer :image_id
    t.text    :url
    t.text    :caption
    t.integer :position

    t.timestamps
  end

  add_index :image_rotator_images, :id
end