Forum: Ruby on Rails how to maintain data while using migration

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
52f877dd98422f0299937b9e8e73dc7d?d=identicon&s=25 Rohit Mehra (ror-user)
on 2006-02-03 14:47
(Received via mailing list)
hi all
  started using migration , gr8 stuff
  but how can i maintain old data , or import it alongwith schema with
same easiness,
  as in migration we only import schema ?
  thanks
  rohit
311849893e0a9c683419fd77e6c52e7e?d=identicon&s=25 Mikkel Bruun (Guest)
on 2006-02-03 14:53
(Received via mailing list)
You can write all kinds of ruby code in a migration...So everything is
actually possible...
33bb150cf13d87bce4e80569ca317647?d=identicon&s=25 Siva Jagadeesan (Guest)
on 2006-02-04 16:27
(Received via mailing list)
When using migration, you probably will be using Alter , add_columns etc
to
ur old table. That should not affect the data that are already there


--
Rgds,
--Siva Jagadeesan
http://www.varcasa.com/
My First Rails Project.
Education Through Collabration
Ae97ad0da5c7887be291561eb1720093?d=identicon&s=25 Alex Soto (asoto)
on 2006-02-05 21:40
(Received via mailing list)
rohit mehra <rohitm2010@...> writes:

>
>
> hi all   started using migration , gr8 stuff  but how can i maintain old data
, or import it alongwith schema with same easiness,   as in migration we
only
import schema ?  thanks   rohit

Well, I don't pretend to stay database agnostic in my migrations so I
use strictly execute() calls to run whatever sql I want.  For example,
you could create a temp table, copy the data into it, and copy it back.
In postgres, temp tables are automatically dropped at the end of the
transaction.

As another said, you can also use whatever ruby code you what instead
of using SQL.
This topic is locked and can not be replied to.