
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:
http://gist.github.com/121233
ruby dm_sti_auto_upgrade_bug.rb
sqlite3 ./test.db
.dump
.quit
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
-
Dan Kubb (dkubb) June 1st, 2009 @ 02:10 PM
Can you give this a try with dm-core/next and see if the problem persists with it?
-
Dan Kubb (dkubb) June 7th, 2009 @ 04:05 AM
- State changed from unconfirmed to accepted
- Assigned user set to Dan Kubb (dkubb)
-
Dan Kubb (dkubb) June 16th, 2009 @ 03:16 AM
- State changed from accepted to resolved
The attached gist no longer exhibits the incorrect behavior described in this ticket. Marking this as closed.
Postmodern: Can you confirm the problem has been resolved with your original script?
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »