I've been experimenting with DM 1.0.0.rc3 and auto-migrations don't
appear to be working as expected.  Specifically, it appears that
modifications to columns are not reflected in the DB if the columns
already exist.

In this example the DB is mysql.

I created a model:

  class User
    include DataMapper::Resource

    property :id, Integer, :min => 0, :max => 2**32-1, :key => true
    property :money,  Integer, :min => 0, :max => 2**32-1, :default =>
0
    property :points, Integer, :min => 0, :max => 2**32-1, :default =>
0
    property :num_logins, Integer, :default => 1
  end

And ran DataMapper.auto_upgrade!  The users table was created as
expected:

mysql> desc users;
+------------+---------------------+------+-----+---------+-------+
| Field      | Type                | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| id         | bigint(10) unsigned | NO   | PRI | NULL    |       |
| money      | bigint(10) unsigned | YES  |     | 0       |       |
| points     | bigint(10) unsigned | YES  |     | 0       |       |
| num_logins | int(11)             | YES  |     | 1       |       |
+------------+---------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)


But then, I tried to increase the size of the ID column, and also
change num_logins to unsigned:

  class User
    include DataMapper::Resource

    property :id, Integer, :min => 0, :max => 2**64-1, :key => true
    property :money,  Integer, :min => 0, :max => 2**32-1, :default =>
0
    property :points, Integer, :min => 0, :max => 2**32-1, :default =>
0
    property :num_logins, Integer, :default => 1, :min => 0
  end


When I re-ran the auto_upgrade! method though, nothing changed.

However, if I dropped the table and ran auto_upgrade!, I got the
expected table:

mysql> desc users;
+------------+---------------------+------+-----+---------+-------+
| Field      | Type                | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+-------+
| id         | bigint(20) unsigned | NO   | PRI | NULL    |       |
| money      | int(10) unsigned    | YES  |     | 0       |       |
| points     | int(10) unsigned    | YES  |     | 0       |       |
| num_logins | int(10) unsigned    | YES  |     | 1       |       |
+------------+---------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)


Notice how id is bigint(20) and num_logins is unsigned.

Thoughts?

Thanks,
Nate



-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to