<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vinsol - Leading Ruby on Rails Development and Consulting Firm in India &#187; migration</title>
	<atom:link href="http://vinsol.com/blog/category/migration/feed/" rel="self" type="application/rss+xml" />
	<link>http://vinsol.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 11 Jan 2012 06:07:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Migration: Adding/Removing columns are now much easier</title>
		<link>http://vinsol.com/blog/2008/01/23/migration-addingremoving-columns-are-now-much-easier/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=migration-addingremoving-columns-are-now-much-easier</link>
		<comments>http://vinsol.com/blog/2008/01/23/migration-addingremoving-columns-are-now-much-easier/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 17:24:54 +0000</pubDate>
		<dc:creator>Akhil Bansal</dc:creator>
				<category><![CDATA[RubyonRails]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://webonrails.com/2008/01/23/migration_adding_removing_columns_are_now_much_easier/</guid>
		<description><![CDATA[You may have noticed by now, that in Rails 2.0 changeset 7422, you can specify columns you want to add/remove in your migration by passing attribute:type pairs to the migration generator. 
For example, lets assume that we need to add a column &#8216;role&#8217; in users table(User model). In this case generate a migration like:

script/generate migration [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>You may have noticed by now, that in Rails 2.0 <a href="http://dev.rubyonrails.org/changeset/7422">changeset 7422</a>, you can specify columns you want to add/remove in your migration by passing <strong>attribute:type</strong> pairs to the migration generator. </p>
<p>For example, lets assume that we need to add a column &#8216;role&#8217; in users table(User model). In this case generate a migration like:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
script/generate migration AddRoleToUser role:string
</textarea>
<p>Output:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
class AddRoleToUser < ActiveRecord::Migration
  def self.up
    add_column :users, :role, :string
  end

  def self.down
    remove_column :users, :role
  end
end
</textarea>
<p>Here <strong>Add</strong>Role<strong><em>To</em></strong><strong>User</strong> plays the main role. &#8216;Add&#8217; specifies the we want to add column(s) and &#8216;User&#8217; separated by &#8216;To&#8217; specifies the table.</p>
<p>Similarly, if we need to remove a column &#8216;role&#8217; :</p>
<textarea name="code" class="ruby" cols="50" rows="10">
 script/generate migration RemoveRoleFromUser role:string
</textarea>
<p>Output:</p>
<textarea name="code" class="ruby" cols="50" rows="10">
class RemoveRoleFromUser < ActiveRecord::Migration
  def self.up
    remove_column :users, :role
  end

  def self.down
    add_column :users, :role, :string
  end
end
</textarea>
<p>Here <strong>Remove</strong>Role<strong><em>From</em></strong><strong>User</strong> plays the main role. &#8216;Remove&#8217; specifies the we want to remove column(s) and &#8216;User&#8217; separated by &#8216;From&#8217; specifies the table.</p>
<p>Isn&#8217;t it cool?
</p>
]]></content:encoded>
			<wfw:commentRss>http://vinsol.com/blog/2008/01/23/migration-addingremoving-columns-are-now-much-easier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

