Sha256: ff8da7e9f173862208731153a16a278450b312c999c8a4d6a35f1d76a0f97c0f
Contents?: true
Size: 803 Bytes
Versions: 2
Compression:
Stored size: 803 Bytes
Contents
class <%= class_name %>Migration < ActiveRecord::Migration def self.up create_table :<%= table_name %><%= ', :id => false' if fields.collect {|f| f['field']}.include?('id') %> do |t| <% for field in fields %> t.<%= field['type'] %> :<%= field['field'] %><%= ', :limit => %s' % field['size'] if field['size'] %><%= "\n" %> <% end %> end <% if fields.collect {|f| f['field']}.include?('id') %> execute "ALTER TABLE <%= table_name %> ADD PRIMARY KEY (id)" <% end %> <% if indexes.size > 1 %> add_index :<%= table_name %>, [<%= indexes.collect {|i| ":%s" % i }.join(",") %>] <% elsif indexes.size == 1 %> add_index :<%= table_name %>, :<%= indexes[0] %><%= "\n" %> <% end %> end def self.down drop_table :<%= table_name %><%= "\n" %> end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
databasion-0.1.1 | lib/databasion/templates/migration.erb |
databasion-0.1.0 | lib/databasion/templates/migration.erb |