Discussion:
Migrate does not create table
Evan Dorn
2007-11-10 19:54:09 UTC
Permalink
I'm trying to learn RoR using Locomotive and a number of different
tutorials. (I've also tried NetBeans, but any attempt to interact
with a database generates the error "cannot convert nil to String",
so it's back to Locomotive).

In my first test project, I've created a simple create_table
migration. "rake db:migrate" runs without any errors, but the table
is not created in mySQL. I've confirmed database connectivity by
changing the database name; lots of errors are generated in that
case, starting with "unknown database". So it sees the DB, but
won't actually create the table.

Here's the code of the migration (001_people.rb)

class People < ActiveRecord::Migration
def self.up
create_table :people do |table|
table.column :firstname, :string
table.column :lastname, :string
table.column :age, :integer
end
end

def self.down
drop_table :people
end
end
SecretSanta$ rake db:migrate --trace
(in /Users/evan/Development/Ruby/SecretSanta/SecretSanta)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
SecretSanta$
That would appear to be okay, but if i investigate the DB with either
CLI tools or phpMyAdmin, the database is still empty; no tables other
than schema_info, which is empty.

How do I track this down? Please assist a noob, thanks.
Evan


Evan Dorn, Ph.D.
public-7UPuOxGa1lNWk0Htik3J/***@public.gmane.org
Paul Welty
2007-11-10 20:24:09 UTC
Permalink
Just off the top of my head...maybe your db user doesn't have
permissions to create tables?
Post by Evan Dorn
I'm trying to learn RoR using Locomotive and a number of different
tutorials. (I've also tried NetBeans, but any attempt to interact
with a database generates the error "cannot convert nil to String",
so it's back to Locomotive).
In my first test project, I've created a simple create_table
migration. "rake db:migrate" runs without any errors, but the
table is not created in mySQL. I've confirmed database
connectivity by changing the database name; lots of errors are
generated in that case, starting with "unknown database". So it
sees the DB, but won't actually create the table.
Here's the code of the migration (001_people.rb)
class People < ActiveRecord::Migration
def self.up
create_table :people do |table|
table.column :firstname, :string
table.column :lastname, :string
table.column :age, :integer
end
end
def self.down
drop_table :people
end
end
SecretSanta$ rake db:migrate --trace
(in /Users/evan/Development/Ruby/SecretSanta/SecretSanta)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
SecretSanta$
That would appear to be okay, but if i investigate the DB with
either CLI tools or phpMyAdmin, the database is still empty; no
tables other than schema_info, which is empty.
How do I track this down? Please assist a noob, thanks.
Evan
Evan Dorn, Ph.D.
_______________________________________________
Locomotive-users mailing list
http://lists.raaum.org/mailman/listinfo/locomotive-users
Evan Dorn
2007-11-10 21:10:18 UTC
Permalink
Post by Paul Welty
Just off the top of my head...maybe your db user doesn't have
permissions to create tables?
Some guy on IRC figured it out for me. There was, somehow, an
inconsistent version number in schema_info. Deleting that table
allowed migrations to work normally.

I think a permissions problem would have generated a visible error.

Thanks,
Ev



Evan Dorn, Ph.D.
public-7UPuOxGa1lNWk0Htik3J/***@public.gmane.org
Paul Welty
2007-11-11 02:07:05 UTC
Permalink
Probably so. I am glad you got it figured out anyhow.
Post by Evan Dorn
Post by Paul Welty
Just off the top of my head...maybe your db user doesn't have
permissions to create tables?
Some guy on IRC figured it out for me. There was, somehow, an
inconsistent version number in schema_info. Deleting that table
allowed migrations to work normally.
I think a permissions problem would have generated a visible error.
Thanks,
Ev
Evan Dorn, Ph.D.
_______________________________________________
Locomotive-users mailing list
http://lists.raaum.org/mailman/listinfo/locomotive-users
Loading...