Sha256: 06371d14ae90fa5d8b990ae67d275be90f745847713448d39dc7188102a5014c

Contents?: true

Size: 1.22 KB

Versions: 114

Compression:

Stored size: 1.22 KB

Contents

class CreatePages < ActiveRecord::Migration
  def up
    create_table :pages do |t|
      t.integer :parent_id
      t.integer :position
      t.string  :type
      t.string  :static_uuid

      t.timestamps
    end

    create_table :page_hierarchies, :id => false do |t|
      t.integer  :ancestor_id, :null => false   # ID of the parent/grandparent/great-grandparent/... tag
      t.integer  :descendant_id, :null => false # ID of the target tag
      t.integer  :generations, :null => false   # Number of generations between the ancestor and the descendant. Parent/child = 1, for example.
    end

    create_table :page_translations do |t|
      t.references :page
      t.string     :locale

      t.string :title
      t.string :path_component
      t.text   :body
    end

    add_index :page_hierarchies,  [:ancestor_id, :descendant_id], :unique => true
    add_index :page_hierarchies,  [:descendant_id]
    add_index :page_translations, [:page_id]
    add_index :page_translations, [:locale]
    add_index :page_translations, [:path_component]

    # Reset the column info
    ApplicationPage.reset_column_information
  end

  def down
    drop_table :pages
    drop_table :page_hierarchies
    drop_table :page_translations
  end
end

Version data entries

114 entries across 57 versions & 1 rubygems

Version Path
lalala-4.0.0.dev.128 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.128 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.126 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.126 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.125 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.125 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.124 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.124 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.123 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.123 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.118 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.118 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.116 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.116 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.114 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.114 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.113 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.113 lib/generators/lalala/install/templates/migrations/3_create_pages.rb
lalala-4.0.0.dev.111 test/dummy/db/migrate/20130327213858_create_pages.rb
lalala-4.0.0.dev.111 lib/generators/lalala/install/templates/migrations/3_create_pages.rb