0
votes

I wanted to play around with a single table inheritance approach in one of my tables. So i created a new git branch (for obvious reasons :) and created the STI for the table. Now when I switch back to my master branch for running some other tests, i get the single table inheritance error:

"The single-table inheritance mechanism failed to locate the subclass:'xxx'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Transaction.inheritance_column to use another column for that information."

My question being, how do I make the STI isolated to only one branch? I thought going by the branching approach, it would not create problems in my master branch. Please advice!

1
Every git branch in you repo connects to the same database. So, if you add a type column to a table using a migration in one branch, this column would also be available when you switch back to your master branch.tdgs

1 Answers

1
votes

Your DB will change if you're using STI.

MySQL itself isn't under git–you need to make sure the DB is in sync with your current branch.

Options include:

  • Creating a new, branch-specific DB, and modifying the default environments in your DB config.
  • Blowing away the DB and re-creating using migrations/dump/etc. and reloading any initial data.

I've tended towards the first (branch-specific DB) because it's a simple config file change (which is under source control) and the migrations are simple, and branch-specific. You might need to remember to delete the additional DBs when you remove a branch (or write a script that does both at the same time).

There are likely other solutions, hopefully people will edit this answer and include them.