Jeff Ward
2006-May-31 18:16 UTC
[Rails] Add 2 Records with Migrations. No errors. No new records.
I have created the following migrationg by using: "ruby script/generate migration AddFirst" But when I run: "rake migrate" it doesn''t add these two records. I don''t get any errors. The schema_info table is created and schema.rb is updated with ":version => 1". Can I not create records this way? When I load up script/console and put in the same code, it will create the records just fine. The Account and User model are already created. /db/migrate/001_add_first.rb =============================================== class AddFirst < ActiveRecord::Migration def self.up Account.create :name => "Company Inc.", :domain => "localhost", :subdomain => "" User.create :name => "Administrator", :username => "admin", :password => "1234", :email => "support@mydomain.com", :account_id => 1 end def self.down end end -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060531/ef27d26d/attachment-0001.html
Heikki Ylönen
2006-May-31 18:50 UTC
[Rails] Re: Add 2 Records with Migrations. No errors. No new records
Do you have tables for accounts and users already? (thats first migration so I assume you have created them by hand) -- Posted via http://www.ruby-forum.com/.
Jeff Ward
2006-May-31 18:54 UTC
[Rails] Re: Add 2 Records with Migrations. No errors. No new records
Yes, I have created them in schema.rb. On 5/31/06, Heikki Yl?nen <heikki74@gmail.com> wrote:> > Do you have tables for accounts and users already? > (thats first migration so I assume you have created them by hand) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060531/1c526fd3/attachment-0001.html
Heikki Ylönen
2006-May-31 19:42 UTC
[Rails] Re: Re: Add 2 Records with Migrations. No errors. No new rec
You should create tables via migrations. To my knowledge schema.rb is just for showing the current schema. Migrations edit schema.rb, you should not. -- Posted via http://www.ruby-forum.com/.
Jeff Ward
2006-May-31 20:12 UTC
[Rails] Re: Re: Add 2 Records with Migrations. No errors. No new rec
Okay, I knew in that Migrations video that "running with scissors" wasn''t a good idea. So, in my first migration I am creating all my initial tables. In the second migration I add my 2 records. I run rake migrate and it runs migration one and two and all is well. Thanks, Jeff On 5/31/06, Heikki Yl?nen <heikki74@gmail.com> wrote:> > You should create tables via migrations. To my knowledge schema.rb is > just for showing the current schema. Migrations edit schema.rb, you > should not. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060531/17e3602f/attachment.html