Rails handles db changes with "migrations". The source files for these
are in db/migrate. Look at what's in there and you will catch on pretty
quickly. For more in depth info look at the Rails documentation for
ActiveRecord::Migration. One thing to note is that there are two
methods for every migration, "up" and "down". Up makes the changes you
want, and down reverses them. This allows rake to take the DB to any
version in the project's history.
To make your own migration, do `script/generate migration <name>` from
the root folder.
J.P.
> <http://github.com/Thav/freehub>
>
> -Tony
>
> --
> You received this message because you are subscribed to the Google
> Groups "Freehub Users" group.
> To post to this group, send email to freehu...@googlegroups.com.
> To unsubscribe from this group, send email to
> freehub-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/freehub-users?hl=en.
-Tony
I'm not sure exactly what you did, but you're not supposed to edit old
migrations, only to create new ones. Editing the old ones breaks the
reversibility of changes.
The DB keeps track of its migration level, so if you run a rake
db:migrate without creating a new migration it will see that it's at the
highest level and do nothing. If you want to rerun old migrations you
can `rake db:migrate VERSION=0`, which will take it back down to
nothing, and then `rake db:migrate` to do them again.
J.P.
I read somewhere that using the padded zeros numbering for migrations
was a little tricky with multiple developers, and that timestamps were
recommended. I'll just continue with 011 at the moment, but wanted to
see if there was any reason to switch. It doesn't seem like we'd all be
changing the migrations at once though.
If anyone wants I can add you as collaborator on my fork.
Thanks again,
-Tony
J.P.
Nope. You should create a new migration called something like 'rename
visit datetime to arrived_at' that has:
rename_column :visits, :datetime, :arrived_at
Migrations get run on the production database with new deploys. If you
remove and add the column, we will lose all existing data for the
datetime column for all visits. So you need to rename.
I assume you are also planning to add a column for the end of the
visit. You could do that in the same migration. Maybe it would then be
called something like 'add visit start and end'.
I also think 'start_at' and 'end_at' may be better names as they would
then line up with 'start_on' and 'end_on' for Service.
It's definitely worth doing some reading about Rails migrations as
they are a core component of the iterative development style
encouraged by the framework.
Alon
I wouldn't bother fixing the items you mention until after doing the
upgrade b/c enough changed in the process.
1) Failure:
test_chain_finders(VisitTest) [/test/unit/visit_test.rb:33]:
<3> expected but was
<4>.
2) Failure:
test_for_organization_in_date_range(VisitTest) [/test/unit/visit_test.rb:19]:
<99> expected but was
<98>.
1) Failure:
test_visits_for_day(VisitsControllerTest) [/test/functional/visits_controller_test.rb:113]:
<2> expected but was
<3>.
J.P.