Class: CreateStructureForPortfolio

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

Class Method Summary (collapse)

Class Method Details

+ (Object) down



32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/refinerycms_portfolio/templates/db/migrate/migration_number_create_structure_for_portfolio.rb', line 32

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

  Page.find_all_by_link_url("/portfolio").each do |page|
    page.destroy!
  end

  drop_table :images_portfolio_entries
  drop_table :portfolio_entries
end

+ (Object) up



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
28
29
30
# File 'lib/generators/refinerycms_portfolio/templates/db/migrate/migration_number_create_structure_for_portfolio.rb', line 3

def self.up
  create_table :images_portfolio_entries, :id => false, :force => true do |t|
    t.integer :image_id
    t.integer :portfolio_entry_id
    t.integer :position
  end

  # people should be allowed to have the same image twice, if they really want to.
  add_index :images_portfolio_entries, [:image_id, :portfolio_entry_id], :name => 'composite_key_index', :unique => false

  create_table :portfolio_entries, :force => true do |t|
    t.string   :title
    t.text     :body
    t.integer  :parent_id
    t.integer  :lft
    t.integer  :rgt
    t.integer  :depth
    t.integer  :title_image_id
    t.timestamps
  end

  add_index :portfolio_entries, :id
  add_index :portfolio_entries, :parent_id
  add_index :portfolio_entries, :lft
  add_index :portfolio_entries, :rgt

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