I''m still confused about Migrations. I read http://api.rubyonrails.com/classes/ActiveRecord/Migration.html and I''m still not sure what to do with them. 1) Are they just for upgrades and downgrades? Or can I specify an entire table in them? (i.e. I wouldn''t have to write sql ever, just create a migration for each model) 2) Is there one Migration per model? 3) Is sqlite support coming? I''m sure there''s some place that answers these questions, but I can''t find it. Thanks, Joe
Hello Joe ! Joe Van Dyk said the following on 2005-07-13 02:25:> I''m still confused about Migrations. I read > http://api.rubyonrails.com/classes/ActiveRecord/Migration.html and I''m > still not sure what to do with them. > > 1) Are they just for upgrades and downgrades? Or can I specify an > entire table in them? (i.e. I wouldn''t have to write sql ever, just > create a migration for each model)See second example: class AddSystemSettings < ActiveRecord::Migration def self.up create_table :system_settings do |t| t.column :name, :string # [snip] end; end; end def self.down drop_table :system_settings end end> 2) Is there one Migration per model?I haven''t seen that written explicitely anywhere, but I don''t think so. What prevents you from creating two tables and updating the schema of three other ones ? It''s just a method that''s called at the appropriate time.> 3) Is sqlite support coming?There, I can''t answer you. Bye ! François
On 7/12/05, François Beausoleil <fbeausoleil-IQIa899fVSs@public.gmane.org> wrote:> Hello Joe ! > > Joe Van Dyk said the following on 2005-07-13 02:25: > > I''m still confused about Migrations. I read > > http://api.rubyonrails.com/classes/ActiveRecord/Migration.html and I''m > > still not sure what to do with them. > > > > 1) Are they just for upgrades and downgrades? Or can I specify an > > entire table in them? (i.e. I wouldn''t have to write sql ever, just > > create a migration for each model) > > See second example: > class AddSystemSettings < ActiveRecord::Migration > def self.up > create_table :system_settings do |t| > t.column :name, :string > # [snip] > end; end; end > > def self.down > drop_table :system_settings > end > end >Great, thanks. So how do I migrate back a release? When does self.down get ran?
On Jul 13, 2005, at 12:38 AM, François Beausoleil wrote:> Joe Van Dyk said the following on 2005-07-13 02:25: > >> 3) Is sqlite support coming? >> > > There, I can''t answer you.The answer is "kind of". The problem is that AR''s "add_column" and "drop_column" methods work by altering the table, and only the very latest version of SQLite3 supports adding and dropping columns via alter table. Thus, if you are using the latest version of SQLite3, most of the migration functionality should already work. Any other version of SQLite will not. - Jamis
> The answer is "kind of". The problem is that AR''s "add_column" and > "drop_column" methods work by altering the table, and only the very > latest version of SQLite3 supports adding and dropping columns via > alter table. Thus, if you are using the latest version of SQLite3, > most of the migration functionality should already work. Any other > version of SQLite will not.It actually only supports adding columns, not dropping and none of the other alter statements. However all of the migrations could be realized by renaming the table, creating a new one and moving the old data back. Anyone up for this challenge? :) -- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
Sounds like fun, I''ll take a stab! ;) /micah On 7/13/05, Tobias Luetke <tobias.luetke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > The answer is "kind of". The problem is that AR''s "add_column" and > > "drop_column" methods work by altering the table, and only the very > > latest version of SQLite3 supports adding and dropping columns via > > alter table. Thus, if you are using the latest version of SQLite3, > > most of the migration functionality should already work. Any other > > version of SQLite will not. > > It actually only supports adding columns, not dropping and none of the > other alter statements. > > However all of the migrations could be realized by renaming the table, > creating a new one and moving the old data back. > Anyone up for this challenge? :) > > -- > Tobi > http://www.snowdevil.ca - Snowboards that don''t suck > http://typo.leetsoft.com - Open source weblog engine > http://blog.leetsoft.com - Technical weblog > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-- Micah Alles micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org 616-776-6020 Software Journeyman Atomic Object LLC
Oops, looks like its already in there :( /micah On 8/13/05, Micah Alles <micah.alles-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sounds like fun, I''ll take a stab! ;) > > /micah > > On 7/13/05, Tobias Luetke <tobias.luetke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > The answer is "kind of". The problem is that AR''s "add_column" and > > > "drop_column" methods work by altering the table, and only the very > > > latest version of SQLite3 supports adding and dropping columns via > > > alter table. Thus, if you are using the latest version of SQLite3, > > > most of the migration functionality should already work. Any other > > > version of SQLite will not. > > > > It actually only supports adding columns, not dropping and none of the > > other alter statements. > > > > However all of the migrations could be realized by renaming the table, > > creating a new one and moving the old data back. > > Anyone up for this challenge? :) > > > > -- > > Tobi > > http://www.snowdevil.ca - Snowboards that don''t suck > > http://typo.leetsoft.com - Open source weblog engine > > http://blog.leetsoft.com - Technical weblog > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > -- > Micah Alles micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org > 616-776-6020 > Software Journeyman Atomic Object LLC >-- Micah Alles micah-T1YOP9nF7vWQ0r5V5wSIsA@public.gmane.org 616-776-6020 Software Journeyman Atomic Object LLC