Class: CreateSchema

### Home Classes Methods

### In Files

- lib/thoth/migrate/001_create_schema.rb

### Parent

Sequel::Migration

### Methods

- #down
- #up

### Files

- robots.txt

### Class/Module Index

Quicksearch

- Thoth
- Thoth::AdminController
- Thoth::ArchiveController
- Thoth::Comment
- Thoth::CommentApiController
- Thoth::CommentController
- Thoth::Config
- Thoth::Error
- Thoth::Importer
- Thoth::MainController
- Thoth::Media
- Thoth::MediaController
- Thoth::MinifyController
- Thoth::Page
- Thoth::PageApiController
- Thoth::PageController
- Thoth::Pager
- Thoth::Plugin
- Thoth::Plugin::Delicious
- Thoth::Plugin::Flickr
- Thoth::Plugin::Tags
- Thoth::Plugin::Twitter
- Thoth::Post
- Thoth::PostApiController
- Thoth::PostController
- Thoth::SchemaError
- Thoth::SearchController
- Thoth::Tag
- Thoth::TagApiController
- Thoth::TagController
- Thoth::TagsPostsMap
- Ramaze
- Ramaze::Dispatcher
- Ramaze::Dispatcher::File
- Ramaze::Helper
- Ramaze::Helper::Admin
- Ramaze::Helper::Cookie
- Ramaze::Helper::Error
- Ramaze::Helper::Pagination
- Ramaze::Helper::Sanitize
- Ramaze::Helper::Wiki
- Ramaze::Helper::Ysearch
- Ramaze::Helper::Ysearch::SearchError
- AddMediaSize
- CreateSchema
- PantsImporter
- PoseidonImporter

No matching classes.

# CreateSchema

### Public Instance Methods

down() click to toggle source

    # File lib/thoth/migrate/001_create_schema.rb, line 30
    def down
      drop_table :comments, :media, :pages, :posts, :tags, :tags_posts_map
    end

up() click to toggle source

    # File lib/thoth/migrate/001_create_schema.rb, line 34
    def up
      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?(: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?(: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

[Validate]

Generated with the Darkfish Rdoc Generator 2.