rake db:migrate
(in /var/www/jabber)
rake aborted!
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version forthe right syntax to use near '-items' at line 1: SHOW FIELDS FROM disco-items
I think you need to not use hyphens in your table names.
Julian.
Thanks Julian, I just figure that out when I dump the DB to a test and
after erasing that table it got stuck on another one with hyphens
... but the issue here is that this is not a DB I created for my
application, instead is an already DB used by jabberd2 and I wanted to
create
a front end on RoR.. so the question is.. is there a way to make this
work? alias? using the models?
help!! :-/
One way you could probably get around it is to explicitly put quotes
around the table name. It's been a while since I've had to worry about
weird table names, but either single quotes or backticks should work.
Or maybe try escaping the hyphen, although that seems to me less
likely (but worth a quick try).
Hi Julian, I have no models so far.. I was going to start this project and got into that error a couple days a go
and I am going nuts.. first I was trying to see if I could modify the db table names but looks like jabberd2 has
this hardcoded so basically I created the project.. and when a head to tell rails about my db when I got into this mess.
Um.... I don't understand how you're getting that error if you have no models...
hmm let me explain what I have done..(excuse me for my bad english)
I have a DB that use for my jabberd2 server with around 2000 users and very populated..
I created a backup a username/password for that db for rails to use..
then I created the rails project
rails --database=mysql(or something like that)lol
then I put the DB info on config/datatabase.yml
and after this step if I am using an inheritage DB I run rake db:migrate to create a scheme under
db/schema.. not sure if this is the right thing to do.. so far it has worked fine if the DB was friendly to rails.
so I get the error right there.. when I run rake db:migrate and the rails db scheme gets only populated till I get the error..
then drops.
Thanks for the help. I have the feeling I am going to learn something I din't know about inheritage DB's
Rails won't automatically create a schema for you, unless you define
some models.
For instance, if you have a table called users, and the table name is
users, add this model to your models folder
file name: users.rb
class User < ActiveRecord::Base
end
You don't need to run rake db:migrate unless you want to do a
migration (ie execute some code that does some stuff to the database).
You can probably get around using hyphenated names by using table_name
'whatever-hyphenated-table-name' like that under the beginning of the
class. (I think that's the right syntax).
Each model you have (one per table) will wrapper a table.
Rails won't automatically create a schema for you, unless you define some models.
For instance, if you have a table called users, and the table name is users, add this model to your models folder
file name: users.rb
class User < ActiveRecord::Base
end
You don't need to run rake db:migrate unless you want to do a migration (ie execute some code that does some stuff to the database). You can probably get around using hyphenated names by using table_name 'whatever-hyphenated-table-name' like that under the beginning of the class. (I think that's the right syntax).
Each model you have (one per table) will wrapper a table.
Julian.
ohhh, this makes much more sense now.. in the book I read and the howtos it always ask you to
create the DB and of course then comes db:migrate so I have always used that way !! :-/
ok so in my particular case you are telling me to create the class like:
class Disco-items < ActiveRecord::Base
but what for the purpuse of learning what if I did wanted to add something to the DB down the road..
how will I tell/force Rails to use disco-items or make disco-items appear to ruby as Disco_items on the application
with out changing the table name in the DB?