I tried a few other things and the only thing I can get to work from migration 001_ is the id: changing names, adding additional columns, etc. will not happen. It seems like everything in 002_ will work including adding more columns.
I'm pretty confused right now. Is anyone actually using migrations? If so, could you post a working example? I'm thinking I must be doing something wrong but can't see it now. Scott On Wed, Mar 18, 2009 at 5:49 AM, Scott LaBounty <[email protected]> wrote: > Looking at this and then giving John's suggestion a try, it looks like > there's something wrong with the 001_TestMigration.rb in that the String > :column_1 is not getting picked up for some reason. Is there some syntax > thing I'm missing? Is "column_1" reserved somehow somewhere? > > Scott > > > On Tue, Mar 17, 2009 at 6:23 PM, Scott LaBounty <[email protected]>wrote: > >> Jeremy, >> >> Here's what I get from that ... >> ------------------------------------------------------- >> 001_TestMigration.rb >> class CreateAttendees < Sequel::Migration >> def up >> create_table(:table_1) do >> primary_key :id >> String :column_1 >> end >> end >> >> def down >> drop_table(:table_1) >> end >> end >> >> 002_TestMigration.rb >> class AddColumn < Sequel::Migration >> def up >> alter_table :table_1 do >> add_column :column_2, String >> end >> end >> >> def down >> alter_table :table_1 do >> drop_column :column_2 >> end >> end >> end >> Migration.rb >> require 'rubygems' >> require 'sequel' >> >> DB = Sequel.sqlite("test.db") # Create a database. >> Sequel::Migrator.apply(DB, '.', 1, 1) # To current version >> # Sequel::Migrator.apply(DB, '.', 5, 1) # To 5 from 1 >> # $ sequel -m /path/to/migrations -M 5 postgres://... >> I, [2009-03-17T18:21:37.678738 #10259] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.679517 #10259] INFO -- : CREATE TABLE >> `schema_info` (`version` integer) >> I, [2009-03-17T18:21:37.699499 #10259] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.700338 #10259] INFO -- : CREATE TABLE `table_1` >> (`id` integer PRIMARY KEY AUTOINCREMENT) >> I, [2009-03-17T18:21:37.700980 #10259] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.701292 #10259] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.701584 #10259] INFO -- : INSERT INTO >> `schema_info` (`version`) VALUES (1) >> I, [2009-03-17T18:21:37.927753 #10262] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.928689 #10262] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.929465 #10262] INFO -- : ALTER TABLE `table_1` >> ADD COLUMN `column_2` String >> I, [2009-03-17T18:21:37.930416 #10262] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.930780 #10262] INFO -- : SELECT * FROM >> `schema_info` LIMIT 1 >> I, [2009-03-17T18:21:37.931096 #10262] INFO -- : UPDATE `schema_info` SET >> `version` = 2 >> >> ------------------------------------------------------- >> >> When I look at the table, once again using the Firefox plugin, I see >> table_1 with column_2 only. Thanks again for the help. >> >> Scott >> >> >> On Tue, Mar 17, 2009 at 4:30 PM, Jeremy Evans <[email protected]>wrote: >> >>> >>> On Mar 17, 3:20 pm, Scott LaBounty <[email protected]> wrote: >>> > I guess what I was looking to do was start with no database (i.e. I >>> removed >>> > the test.db from my directory). I then wanted to run one of the two >>> commands >>> > to go to version one which is what I was trying to accomplish with what >>> I >>> > was showing below. Then I wanted check the database using the sqllite >>> > Manager that I downloaded for Firefox and check that the database had >>> the >>> > table and the first column. Then finally, run a second command to pick >>> up >>> > the 002_ file and check the database again to make sure the second >>> column >>> > got added correctly. How does Sequel know which files in a directory to >>> use. >>> > In my case I had the two migration files, the data base, and the ruby >>> file >>> > for migrating all in the same directory. Is that allowed? >>> >>> It is allowed and should work. I recommend removing the test.db file >>> again and rerunning the migrations one at a time with the -E option to >>> sequel. Then send an email with the contents of your migrations and >>> the SQL generated so we can see what is going on. So, the commands >>> you should run: >>> >>> rm test.db >>> for x in *.rb; do echo $x; cat $x; done >>> sequel -m . -M 1 -E sqlite://test.db >>> sequel -m . -M 2 -E sqlite://test.db >>> >>> Send the output that those commands produce and hopefully it'll be >>> easier to figure out what is going wrong. >>> >>> > Thanks again for the help and I'll see you at the LA Ruby conference, >>> >>> You're welcome. See you there. >>> >>> Thanks, >>> Jeremy >>> >>> >>> >> >> >> -- >> Scott >> http://steamcode.blogspot.com/ >> > > > > -- > Scott > http://steamcode.blogspot.com/ > -- Scott http://steamcode.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
