Class: SQL::TableCreator

### Home Classes Methods

### In Files

- lib/dm-migrations/sql/table_creator.rb

### Parent

Object

### Namespace

- CLASS SQL::TableCreator::Column
- CLASS SQL::TableCreator::SqlExpr

### Methods

- ::new
- #column
- #now
- #quoted_table_name
- #to_sql
- #uuid

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Adapters
- DataMapper::Migration
- DataMapper::MigrationRunner
- DataMapper::Migrations
- DataMapper::Migrations::DataObjectsAdapter
- DataMapper::Migrations::DataObjectsAdapter::ClassMethods
- DataMapper::Migrations::DuplicateMigration
- DataMapper::Migrations::Model
- DataMapper::Migrations::MysqlAdapter
- DataMapper::Migrations::MysqlAdapter::ClassMethods
- DataMapper::Migrations::OracleAdapter
- DataMapper::Migrations::OracleAdapter::ClassMethods
- DataMapper::Migrations::PostgresAdapter
- DataMapper::Migrations::PostgresAdapter::ClassMethods
- DataMapper::Migrations::Repository
- DataMapper::Migrations::SingletonMethods
- DataMapper::Migrations::SqliteAdapter
- DataMapper::Migrations::SqliteAdapter::ClassMethods
- DataMapper::Migrations::SqlserverAdapter
- DataMapper::Migrations::SqlserverAdapter::ClassMethods
- DataMapper::Migrations::YamlAdapter
- SQL
- SQL::Column
- SQL::Mysql
- SQL::Mysql::Column
- SQL::Mysql::Table
- SQL::Postgres
- SQL::Postgres::Column
- SQL::Postgres::Table
- SQL::Sqlite
- SQL::Sqlite::Column
- SQL::Sqlite::Table
- SQL::Table
- SQL::TableCreator
- SQL::TableCreator::Column
- SQL::TableCreator::SqlExpr
- SQL::TableModifier
- Spec
- Spec::Example
- Spec::Example::MigrationExampleGroup
- Spec::Matchers
- Spec::Matchers::Migration
- Spec::Matchers::Migration::HaveColumnMatcher
- Spec::Matchers::Migration::HaveTableMatcher
- Spec::Matchers::Migration::NullableColumnMatcher
- Spec::Matchers::Migration::PrimaryKeyMatcher
- Object

No matching classes.

# SQL::TableCreator

### Attributes

opts[RW]
table_name[RW]

### Public Class Methods

new(adapter, table_name, opts = {}, &block) click to toggle source

    # File lib/dm-migrations/sql/table_creator.rb, line 10
    def initialize(adapter, table_name, opts = {}, &block)
      @adapter = adapter
      @table_name = table_name.to_s
      @opts = opts

      @columns = []

      self.instance_eval &block
    end

### Public Instance Methods

column(name, type, opts = {}) click to toggle source

    # File lib/dm-migrations/sql/table_creator.rb, line 24
    def column(name, type, opts = {})
      @columns << Column.new(@adapter, name, type, opts)
    end

now() click to toggle source

A helper for using the native NOW() SQL function in a default

    # File lib/dm-migrations/sql/table_creator.rb, line 33
    def now
      SqlExpr.new('NOW()')
    end

quoted_table_name() click to toggle source

    # File lib/dm-migrations/sql/table_creator.rb, line 20
    def quoted_table_name
      @adapter.send(:quote_name, table_name)
    end

to_sql() click to toggle source

    # File lib/dm-migrations/sql/table_creator.rb, line 28
    def to_sql
      "CREATE TABLE #{quoted_table_name} (#{@columns.map{ |c| c.to_sql }.join(', ')})#{@adapter.table_options(@opts)}"
    end

uuid() click to toggle source

A helper for using the native UUID() SQL function in a default

    # File lib/dm-migrations/sql/table_creator.rb, line 38
    def uuid
      SqlExpr.new('UUID()')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.