class SchemaRD::MigrationContext::Loader::TableDefinition
Public Class Methods
new(table, with_comment: false)
click to toggle source
“with_comment” must be assigned, but ruby2.0 needs default value.
# File lib/schemard/schema_parser.rb, line 30 def initialize(table, with_comment: false) @table = table @parse_db_comment = with_comment end
Public Instance Methods
column(name, type, options = {})
click to toggle source
# File lib/schemard/schema_parser.rb, line 37 def column(name, type, options = {}) if options[:comment] && @parse_db_comment options[:parsed_db_comment] = options.delete(:comment) end @table.columns << SchemaRD::TableColumn.new(options.merge({ name: name, type: type })) end
index(column_name, options = {})
click to toggle source
# File lib/schemard/schema_parser.rb, line 47 def index(column_name, options = {}) column_name = [ column_name ] unless column_name.is_a?(Array) @table.indexes << SchemaRD::TableIndex.new(options.merge({ columns: column_name })) end
method_missing(name, *args)
click to toggle source
# File lib/schemard/schema_parser.rb, line 34 def method_missing(name, *args) self.column(args[0], "unknown", args[1]) end
timestamps()
click to toggle source
# File lib/schemard/schema_parser.rb, line 43 def timestamps column("created_at", :timestamp, null: false) column("updated_at", :timestamp, null: false) end