Forum: Ruby on Rails roobie noobie migration question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8dad1ec4d769734583f45fbbee5cd009?d=identicon&s=25 Jeff Pritchard (Guest)
on 2006-03-03 04:59
I'm just at the "reading various rails tutorials" stage.

One thing that has puzzled me a couple of times so far is the fact that
the creation of the database is not part of the "migration".

The steps as I've seen them are always:
1) $ rails myapplication
2) $ mysqladmin yadda yadda to create a table
3) $ script/generate migration myWickedTable
4) put rows and columns in the migration script
5) $ rake migrate

I'm just wondering why its not more like this:
1) $rails myapplication
2) $script/generate migration myWickedDatabase
3) put a table in the migration script
4) put rows and columns in the migration script
5) $ rake migrate

It just seems odd that the creation of the database is seen as something
special and previous to the other steps that are handled by rails.  Why
can't (or shouldn't) rails include that part of the initial setup?

thanks,
jp
34f5b045aec62235c17458650ea75353?d=identicon&s=25 Steve Koppelman (hatless)
on 2006-03-03 05:50
I don't really know, but I'll take a guess.

It's not generally considered good security practice for the web
application user ID to have broad database creation privileges. The
assumption is that at most the application's database user ID should be
constrained to mucking around only with that application's schema, in
which case something else would have to create the bare schema in the
first place and grant privileges on it to the Rails user.

While you _could_ have an initial migration create the database itself,
many real-world environments beyond a personal laptop or a cheap shared
hosting account often wouldn't allow it, so it's not a practice I'd
personally expect to see in Rails tutorials.

Then again, maybe I'm way off base.


Jeff Pritchard wrote:
> I'm just at the "reading various rails tutorials" stage.
>
> One thing that has puzzled me a couple of times so far is the fact that
> the creation of the database is not part of the "migration".
>
> The steps as I've seen them are always:
> 1) $ rails myapplication
> 2) $ mysqladmin yadda yadda to create a table
> 3) $ script/generate migration myWickedTable
> 4) put rows and columns in the migration script
> 5) $ rake migrate
>
> I'm just wondering why its not more like this:
> 1) $rails myapplication
> 2) $script/generate migration myWickedDatabase
> 3) put a table in the migration script
> 4) put rows and columns in the migration script
> 5) $ rake migrate
>
> It just seems odd that the creation of the database is seen as something
> special and previous to the other steps that are handled by rails.  Why
> can't (or shouldn't) rails include that part of the initial setup?
>
> thanks,
> jp
This topic is locked and can not be replied to.