I would pretty much ignore schema.rb, and just generate new migration
files, then run "rake migrate" to update your database.
Schema.rb basically is all your migrations in one file, so good for when
you distribute/deploy an application.
Schema.rb gets created when you run db_schema_dump or gets created
automatically if you un-comment "config.active_record.schema_format =
:ruby" in enviroment.rb.
As far as I am aware you have to create a database first then run rake
migrate. I guess you could have the database created automatically if
you add create_database to the first migration file, but I have not
tried it because some developers may have different database names in
database.yml depending on their local setup, so there is no need to
force a database name, only table/field names.
If your messing with tables to start with you could do it without
migrations using command line or GUI but when you are done do a
db_schema_dump, and copy the code in schema.rb to your first migration
file.
I hope that helps...
Kris.
rover rhubarb wrote:>
> 1. He generates the model ("post") before running rake
db_schema_dump.
> Is that necessary or just a preference?
>
> 2. 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?
>
> 3. 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
> later?
> 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
--
Posted via http://www.ruby-forum.com/.