class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
def up if table_exists?(:<%= table_name %>) warn "<%= table_name %> already exists, exiting" return end create_table :<%= table_name %> do |t| <%- fields.each do |key| -%> <%- next if %w(id message_id timestamp).include?(key.name) -%> <%- sql_type = schema_base.sql_type(key) if %w(record array map).include?(sql_type) conn = ActiveRecord::Base.connection sql_type = conn.respond_to?(:supports_json?) && conn.supports_json? ? :json : :string end -%> t.<%= sql_type %> :<%= key.name %> <%- end -%> end # TODO add indexes as necessary end def down return unless table_exists?(:<%= table_name %>) drop_table :<%= table_name %> end
end