<?xml version="1.0" encoding="UTF-8"?>
<codes type="array">
  <code>
    <code># first, create the method import_sql:

class ActiveRecord::ConnectionAdapters::MysqlAdapter
  def import_sql(file)
    conf = ActiveRecord::Base.configurations[RAILS_ENV]
    sql_file = File.join(RAILS_ROOT, 'db', file + '.sql')
    cmd_line = &quot;mysql -h &quot;+conf[&quot;host&quot;]+&quot; -D &quot;+conf[&quot;database&quot;]+ &quot; --user=&quot;+conf[&quot;username&quot;]+&quot; --password=&quot;+conf[&quot;password&quot;]+&quot; &lt; &quot;+sql_file
    raise Exception, &quot;Error executing &quot; + cmd_line unless system(cmd_line)    
  end
end


# create a migration. ex:

./script/generate migration sql_external_test

# save your sql file with sql commands in db/. migration's sample:

class SqlExternalTest &lt; ActiveRecord::Migration
  def self.up
    import_sql(&quot;test&quot;)
  end

  def self.down
  end
end

</code>
    <created-at type="datetime">2009-02-02T18:46:51Z</created-at>
    <description>it's a small how to import a file in migrations.

from: http://code-ronin.com/articles/rails-migrations-directly-import-sql</description>
    <id type="integer">151</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>import sql files into migrations</title>
    <updated-at type="datetime">2009-02-02T18:46:51Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>  create_table :table do |t|
    t.column # adds an ordinary column. Ex: t.column(:name, :string)
    t.index # adds a new index.
    t.timestamps
    t.change # changes the column definition. Ex: t.change(:name, :string, :limit =&gt; 80)
    t.change_default # changes the column default value.
    t.rename # changes the name of the column.
    t.references
    t.belongs_to
    t.string
    t.text
    t.integer
    t.float
    t.decimal
    t.datetime
    t.timestamp
    t.time
    t.date
    t.binary
    t.boolean
    t.remove
    t.remove_references
    t.remove_belongs_to
    t.remove_index
    t.remove_timestamps
  end</code>
    <created-at type="datetime">2008-12-14T13:38:12Z</created-at>
    <description></description>
    <id type="integer">132</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>[rails] create_table methods</title>
    <updated-at type="datetime">2008-12-14T13:38:12Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
  <code>
    <code>config.active_record.timestamped_migrations = false</code>
    <created-at type="datetime">2008-11-26T23:34:49Z</created-at>
    <description>set in your environment.rb</description>
    <id type="integer">120</id>
    <language-id type="integer">39</language-id>
    <privated type="boolean">false</privated>
    <title>migrations without timestamp</title>
    <updated-at type="datetime">2008-11-26T23:34:49Z</updated-at>
    <user-id type="integer">7</user-id>
  </code>
</codes>
