Forum: Ruby on Rails Add 2 Records with Migrations. No errors. No new records.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jeff W. (Guest)
on 2006-05-31 22:21
(Received via mailing list)
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
any errors. The schema_info table is created and schema.rb is updated
":version => 1".

Can I not create records this way? When I load up script/console and put
the same code, it will create the records just fine. The Account and
model are already created.


class AddFirst < ActiveRecord::Migration
  def self.up
    Account.create :name => "Company Inc.", :domain => "localhost",
:subdomain => ""
    User.create :name => "Administrator", :username => "admin",
:password =>
"1234", :email => "removed_email_address@domain.invalid", :account_id => 1

  def self.down
Heikki Y. (Guest)
on 2006-05-31 22:50
Do you have tables for accounts and users already?
(thats first migration so I assume you have created them by hand)
Jeff W. (Guest)
on 2006-05-31 22:56
(Received via mailing list)
Yes, I have created them in schema.rb.
Heikki Y. (Guest)
on 2006-05-31 23:40
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.
Jeff W. (Guest)
on 2006-06-01 00:15
(Received via mailing list)
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
migration I add my 2 records. I run rake migrate and it runs migration
and two and all is well.


This topic is locked and can not be replied to.