#873 ✓resolved

new STI models are not auto-upgraded after the second auto-upgrade

Reported by Postmodern | June 1st, 2009 @ 12:00 AM

I noticed an interesting behavior while working on a program of mine which needs to load additional STIed models after the database has been setup/auto-upgraded, and then auto-upgrade the repository a second time. It appears that by defining new classes that inherit from STI base-classes, after the initial auto-upgrade has been executed, subsequent auto-upgrades fail to properly upgrade the tables for the STI base-classes.

A recreation of the bug is available here:

ruby dm_sti_auto_upgrade_bug.rb
sqlite3 ./test.db

As you can see the Admin model inherits from the User model, and defines an additional :group_id foreign key. After running the above mentioned script and inspecting the sqlite3 database, no :group_id key was added to the users table; although the groups table was created.

I did notice that if I defined all of the STI classes before the initial auto_upgrade, all defined properties would be upgraded in the repository. I believe that subsequent auto-upgrades should have the same effect as the initial one.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket