Dgrady3/Task_galaxy — pull request #1 by hchood (2014-09-17 15:06:41+00:00)
Title: Hh review

Hey Joe,

You got the general idea on this, I think you just ran into some trouble setting up the migrations because of naming convention issues, and your join table wasn't quite set up properly.

**ER diagram for join table.** Your join table should represent the union of just two tables, not three. Your join table should just join the `users` and `task_lists` tables, so it shouldn't have a `task_id`. (Given that it joins `users` and `task_lists`, I'd call it something like `user_task_lists` instead of `users_tasks`.)

```ruby
class CreateUserTaskLists < ActiveRecord::Migration
create_table :user_task_lists do |t|
t.integer :user_id, null: false
t.integer :task_list_id, null: false

t.timestamps
end
end
```

**What to do when a migration gets screwed up.** You should always be able to tell immediately if a migration is screwed up when you run `rmrm`. If you run into an issue at that point, definitely change the migration. You don't want to leave it there and then have a collaborator pull down your repo, run the migrations, and have something break.

Even if you accidentally forget to run `rmrm` and later on realize a migration is broken, you should go back and fix it. (Another exception to the "don't change your migrations" rule.) Just make sure that the rest of your migrations run as expected, since changing an old migration can introduce issues if subsequent migrations depend on the changes you made in that previous one.

So in this case, you shouldn't need a bunch of `add_column` / `remove_column` migrations for adding `task_list_id` to `tasks` -- you should just use one migration, and tinker with it if it's not working for some reason. Once it does work, then commit it.

**`belongs_to` associations should be singular.** So you want `belongs_to :user`, not `belongs_to :users`, for example.

**Use descriptive migration names.** Instead of `AddAnotherColumn`, for example, use `AddTaskListIdToTasks`.

Let me know if you want to meet up to discuss migration stuff later. (Or if the clinic yesterday clarified things, that's fine too.)