
Derived Models are not auto-migrated
Reported by Postmodern | July 6th, 2008 @ 01:39 AM
When creating models which are derived from an auto-migratable model, DataMapper.auto_migrate! will not migrate these derived classes. Also, the fact that one has to include AutoMigrations into a model makes it difficult to force derived classes to be auto-migratable by re-including AutoMigrations.
require 'dm-core'
DataMapper.setup(:default, {:adapter => 'sqlite3', :database => 'test.db'})
class Base
include DataMapper::Resource
include DataMapper::AutoMigrations
include DataMapper::Types
property :id, Serial
property :x, Integer
end
class Test < Base
property :y, Integer
end
DataMapper.auto_migrate!
# => #<Set: {Base}>
$ sqlite3 test.db
sqlite> .dump
BEGIN TRANSACTION;
CREATE TABLE "bases" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "x" INTEGER);
DELETE FROM sqlite_sequence;
COMMIT;
Comments and changes to this ticket
-
Postmodern July 6th, 2008 @ 09:22 PM
Also, forcibly migrating the derived models has no effect.
Test.auto_migrate! # => true
$ sqlite3 test.db sqlite> .dump BEGIN TRANSACTION; DELETE FROM sqlite_sequence; CREATE TABLE "bases" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "x" INTEGER); COMMIT;
-
Aadi Deshpande July 8th, 2008 @ 12:49 AM
i noticed you don't have any STI declarations :
property :type, Discriminator
Is that intended?
I don't think DM supports other forms of inheritance ( other than STI ) yet, so might this be related to that?
-
Dan Kubb (dkubb) July 9th, 2008 @ 11:31 PM
- State changed from new to invalid
A Discriminator property needs to be set in order to use STI. Marking this ticket as invalid.
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 »