Using Locomotive - Problem making database tables

Hi,

Im using a macbook and Im still trying to get rails running properly!
I’ve went through the basic locomotive help file and have no problems
up until ‘Prepare your database tables’.
Here is what im trying to do:

"Prepare your database tables

We will prepare our database using Migrations. Using migrations, you
code your table schemas in ruby. The migrations system is set up to
facilitate the evolution (and devolution!) of your schema over time
(versions/features/etc.).

Select your application in the Locomotive main window and choose
Applications > Open Terminal
On the command line in the terminal type:
ruby script/generate migration add_monkeys_table

(The name you choose for your migration is not all that important to
rails; it should not include spaces and it should be meaningful to
you).
Open the newly created ‘001_add_monkeys_table.rb’ in db/migrate in your
favorite text editor. It should look something like this:
class AddMonkeysTable < ActiveRecord::Migration
def self.up
end

def self.down
end
end

Modify this code to look like this:
class AddMonkeysTable < ActiveRecord::Migration
def self.up
create_table :monkeys do |t|
t.column :name, :string
t.column :angry?, :boolean
end
end

def self.down
drop_table :monkeys
end
end

To create the table specified by this migration, from the command line
in the terminal (opened previously from Locomotive), type:
rake migrate

Success! Move on to generating scaffolding to make use of your new
database table."

No problems up until the step 6, rake migrate. Here is the error:

"c0a80004:~/Documents/work/depot jim$ ruby script/generate migration
add_monkeys_table
create db/migrate
create db/migrate/001_add_monkeys_table.rb
c0a80004:~/Documents/work/depot jim$ rake migrate
(in /Users/jim/Documents/work/depot)
rake aborted!
Unknown database ‘depot_development’

(See full trace by running task with --trace)
c0a80004:~/Documents/work/depot jim$ "

I can see it is obviously something with the database, I have a clean
install of mySQL installed as recommended on the locomotive site. Can
anyone help me identify what I am doing wrong so I can get coding with
Rails!

Help much appreciated, thankyou in advance.

cmcfarland wrote:

Unknown database ‘depot_development’

I don’t know about locomotive, but generally you have to manually create
your actual database, rails can’t do that for you. Using whatever
database admin that you use you must create a database called
depot_development, or point it to different database name in
config/database.yml

Than you migration should work like a charm.

Then the question is exactly how do I manually create the database? Any
pointers on this. I’m finding it hard to understand how my locomotive
setup and my mysql setup (which allows me to do nothing other than run
it or turn it off) connect and how I get these databases and tables set
up.

Any help is appreciated.

This procedure talks about MySQL 4, but the stuff like setting the
root password has to be done with MySQL 5 too.
http://www.entropy.ch/software/macosx/mysql/

For creating databases:
http://cocoamysql.sourceforge.net/beta/CocoaMySQL_0.7b5.zip

For creating your table structure: use migrations that are
automatically created in the db folder when generating models. Check
the Rails API for instructions.

On 08 Dec 2006, at 21:57, cmcfarland wrote:

Then the question is exactly how do I manually create the database?
Any
pointers on this. I’m finding it hard to understand how my locomotive
setup and my mysql setup (which allows me to do nothing other than run
it or turn it off) connect and how I get these databases and tables
set
up.

Best regards

Peter De Berdt

On Jan 10, 7:54 am, “cmcfarland” [email protected] wrote:

install)
Also just to check I have this right… After I have the databases made
I just need to set the details in config/database.yml and then I can
start creating my table structures using migrations?

Is there an easier way to make a database? Or can someone give me some
help making the requred databases to use with the above example.

Help greatly appreciated. I’m getting frustrated just trying to get
things set up so I can start coding!

Thanks for your help.
Hi,

I would (very strongly) suggest using sqlite to start - you don’t need
what mysql provides over sqlite at this point in your exploration of
rails (you may never need what mysql provides over sqlite!).
Configuring sqlite is also substantially easier as the migration
can create the database for sqlite.

Set up your database.yml to have (remove the username: password: etc
lines altogether)

development:
adapter: sqlite3
database: db/dev.db

and you’re done! Run the migration and it will create the db and the
tables. (The database will be the file /path/to/yourapp/db/dev.db)

Best,

-r

Thankyou for your comments. I know have mysql installed properly as far
as I can see.

How do I actually make these databases? I’ve installed CocaMysql2 and
when I try to make a new database for depot_development, to work with
the above that ive been trying to get working, im having problems.

From File > New, Ive completed the fields:
Host: localhost
User: root
Password: (i have added my password that i set following the mysql
install)
Database: depot_development

I dont know about SSH Password etc so I havent completed that part.

When I try to connect it just errors ‘connection failed’.

Out of the example on locomotive and also from the examples in a rails
book, it never seems to mention making the databases so i am completely
confused how to make them. Obviously I need to get this figured out!

Also just to check I have this right… After I have the databases made
I just need to set the details in config/database.yml and then I can
start creating my table structures using migrations?

Is there an easier way to make a database? Or can someone give me some
help making the requred databases to use with the above example.

Help greatly appreciated. I’m getting frustrated just trying to get
things set up so I can start coding!

Thanks for your help.

cmcfarland wrote:

Thankyou for your comments. I know have mysql installed properly as far
as I can see.

How do I actually make these databases? I’ve installed CocaMysql2 and
when I try to make a new database for depot_development, to work with
the above that ive been trying to get working, im having problems.

From File > New, Ive completed the fields:
Host: localhost
User: root
Password: (i have added my password that i set following the mysql
install)
Database: depot_development

I dont know about SSH Password etc so I havent completed that part.

When I try to connect it just errors ‘connection failed’.

Sounds like the MySQL server hasn’t started. Install the system
preference pane and start it up. CocaMysql should then be able to login
to the DB server. From there create a new database by clicking the “+”
icon found under “Choose database”.

Ryan is right in recommending sqlite - it makes life a lot easier and
will do the job for most smallish projects.