Sha256: 7043ba6761dcf98ec56a94c6fe74926fd260d59552088437ac8a230c22c1e8f7

Contents?: true

Size: 1.93 KB

Versions: 4

Compression:

Stored size: 1.93 KB

Contents

class CreateComfyBlog < ActiveRecord::Migration
  
  def self.up
    create_table :blog_posts do |t|
      t.string  :title,           :null => false
      t.string  :slug,            :null => false
      t.text    :content
      t.string  :excerpt,         :limit => 1024
      t.string  :author
      t.integer :year,            :null => false, :limit => 4
      t.integer :month,           :null => false, :limit => 2
      t.boolean :is_published,    :null => false, :default => true
      t.timestamps
    end
    add_index :blog_posts, [:is_published, :year, :month, :slug],
      :name => 'index_blog_posts_on_published_year_month_slug'
    add_index :blog_posts, [:is_published, :created_at]
    add_index :blog_posts, :created_at
    
    create_table :blog_comments do |t|
      t.integer :post_id,       :null => false
      t.string  :author,        :null => false
      t.string  :email,         :null => false
      t.text    :content
      t.boolean :is_published,  :null => false, :default => false
      t.timestamps
    end
    add_index :blog_comments, [:post_id, :created_at]
    add_index :blog_comments, [:post_id, :is_published, :created_at],
      :name => 'index_blog_comments_on_post_published_created'
      
    create_table :blog_tags do |t|
      t.string  :name,            :null => false
      t.boolean :is_category,     :null => false, :default => false
      t.integer :taggings_count,  :null => false, :default => 0
    end
    add_index :blog_tags, [:name, :taggings_count], :unique => true
    add_index :blog_tags, :taggings_count
    
    create_table :blog_taggings do |t|
      t.integer   :post_id, :null => false
      t.integer   :tag_id,  :null => false
    end
    add_index :blog_taggings, [:post_id, :tag_id], :unique => true,
      :name => 'index_blog_taggings_on_post_tag'
  end
  
  def self.down
    drop_table :blog_posts
    drop_table :blog_comments
    drop_table :blog_tags
    drop_table :blog_taggings
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comfy_blog-0.1.6 db/migrate/01_create_comfy_blog.rb
comfy_blog-0.1.5 db/migrate/01_create_comfy_blog.rb
comfy_blog-0.1.4 db/migrate/01_create_comfy_blog.rb
comfy_blog-0.1.3 db/migrate/01_create_comfy_blog.rb