Ruby, Rake, Mysql - creating database
How to do? I tried something like:
RAILS_ENV=production rake db:create db:load
in file /lib/tasks/load_tasks.rake
and this file I tried in terminal as rake db:migrate
, but I am getting errors about syntax etc.
I entered into terminal this command (I saw it in tutorial):
rails generate scaffold Account user_name:string description:text premium:boolean \
开发者_如何学Python income:integer ranking:float fee:decimal birthday:date login_time:time
And this made me file 20110518181941_create_accounts.rb
How can I create database table - I thought the command above will create me database in mysql... I am now a bit confusing, what to do?
Which rule is playing here rake db:migrate
?
I think you are getting this error because your syntax is wrong, please put &&
between sentences:
RAILS_ENV=production rake db:create && db:schema:load
or do it in separated lines
RAILS_ENV=production rake db:create
RAILS_ENV=production rake db:schema:load
the first command will create the database, the second command will Load the db/schema.rb
file into the database
And finally you need to run your migration:
RAILS_ENV=production rake db:migrate
to create your Accounts table.
BTW if you run:
rake -T
you can see the list of rake tasks and their descriptions.
Hope this helps.
精彩评论