class CreateSchema
Public Instance Methods
down()
click to toggle source
# File lib/thoth/migrate/001_create_schema.rb, line 30 def down drop_table :tags_posts_map, :comments, :media, :pages, :posts, :tags end
up()
click to toggle source
# File lib/thoth/migrate/001_create_schema.rb, line 34 def up unless table_exists?(:posts) create_table :posts do primary_key :id varchar :title, :null => false, :unique => true varchar :name, :null => false, :unique => true text :body, :null => false text :body_rendered, :null => false datetime :created_at, :null => false datetime :updated_at, :null => false end end unless table_exists?(:comments) create_table :comments do primary_key :id varchar :author, :null => false varchar :author_url varchar :title, :null => false text :body, :default => '' text :body_rendered, :default => '' varchar :ip datetime :created_at, :null => false datetime :updated_at, :null => false foreign_key :post_id, :table => :posts index :post_id end end unless table_exists?(:media) create_table :media do primary_key :id varchar :filename, :null => false, :unique => true varchar :mimetype, :null => false datetime :created_at, :null => false datetime :updated_at, :null => false end end unless table_exists?(:pages) create_table :pages do primary_key :id varchar :title, :null => false, :unique => true varchar :name, :null => false, :unique => true text :body, :null => false text :body_rendered, :null => false datetime :created_at, :null => false datetime :updated_at, :null => false end end unless table_exists?(:tags) create_table :tags do primary_key :id varchar :name, :null => false, :unique => true end end unless table_exists?(:tags_posts_map) create_table :tags_posts_map do primary_key :id foreign_key :post_id, :table => :posts foreign_key :tag_id, :table => :tags unique([:post_id, :tag_id]) end end end