<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.aussiegeek.net,:/tags/migration</id>
  <link type="text/html" href="http://www.aussiegeek.net" rel="alternate"/>
  <link type="application/atom+xml" href="http://www.aussiegeek.net/tags/migration.xml" rel="self"/>
  <title>Aussiegeek.net: Posts tagged with migration</title>
  <updated>2008-06-17T14:23:00+10:00</updated>
  <entry>
    <id>tag:www.aussiegeek.net,:Post/9</id>
    <published>2008-06-17T14:25:27+10:00</published>
    <updated>2008-06-17T14:25:54+10:00</updated>
    <link type="text/html" href="http://www.aussiegeek.net/posts/9-Rails-2-1-migration" rel="alternate"/>
    <title>Rails 2.1 migration</title>
    <content type="html">I've hacked together a simple script for converting timezones from the local timezone to utc for Rails 2.1

&lt;pre&gt;
#!env ruby
class DummyTable
  def initialize(tablename)
    @@tablename=tablename
  end
  def self.method_missing(m, *args); end
  
  def self.datetime(name,options={})
    puts "execute \"UPDATE #{@@tablename} SET #{name}=CONVERT_TZ(#{name},'SYSTEM','+00:00');\""
  end
end

def create_table(tablename,options,*block)
  dummy_table=DummyTable.new(tablename)
  yield DummyTable
end

def add_index(name,fields,options={}); end

class ActiveRecord;end

class ActiveRecord::Schema
  def self.define(options={}, *block)
    yield
  end
end

require 'db/schema.rb'
&lt;/pre&gt;

Drop this file in the root of your project and just run it with plain Ruby. I wrote it this way so I could avoid ActiveRecord, it will spit out a bunch of execute commands ready for plugging in to a migration</content>
    <author>
      <name>alan harper</name>
      <email>alan@aussiegeek.net</email>
    </author>
  </entry>
</feed>
