I’m somewhat of a newbie - played with recent versions of rails a few
mths ago, but have decided to start from scratch with 1.0.
I want to build my new db as much as possible with migrations, so I
watched DHH’s migrations movie from rubyonrails.org.
A few things confuse me:
He generates the model (“post”) before running rake db_schema_dump.
Is that necessary or just a preference?
He says that running db_schema_dump will create not only the schema
file, but the database. He’s using sqllite, I’m using MySQL, and it
didnt work for me. That is, rake db_schema_dump issued an error
complaining that the database didnt exist.
I created the database in the MySQL console, tried again and it worked.
So question: Does db_schema_dump only create the db for sqllite, or did
DHH misspeak, or did I misunderstand?
- DHH then goes into the autogenerated schema.rb and adds code to
create the tables. He notes the warning about not modifying the
autogenerated file, but says “we’re going to run with scissors here”.
I appreciate what he’s doing here, but what concerns me is, is this the
way it’s meant to be done? Or is it some shortcut for a quick video?
I’m not criticizing here, I’m just trying to start a project from
scratch and follow the simplest path.
Is creating the tables in the db console before runing db_schema_dump
the proper way?
Is db_schema_dump really only meant to be used do dump out the schema
Should I be creating migrations files to start creating my tables, and
not be using db_schema_dump first?
Also another startup question: I’m starting my project, and I’ll be
messing with the table definitions a bit. But I have no data yet and no
real need for migrations - this is all preliminary stuff - so should I
create migrations each time for each new column, etc, or “hard code” it
all in schema.rb, or do it all in the MySQL console.
thanks for any advice offered