Export to GitHub

cakephp-migrations - issue #6

Default values


Posted on Mar 25, 2008 by Quick Bear

What steps will reproduce the problem? Having description of a table... users: group_id: [int, notnull, 2] username: [string, 64, notnull, unique] passwd: [string, 64, notnull] email: [string, 255, notnull, unique] active: [bool, notnull, 0] registration_token: [string, 64, notnull] registration_expires: [timestamp, notnull]

What is the expected output? What do you see instead?

Doesn't specified default values for group_id and active fields. Using "map" notation with "default" key does not work as well. It just creats fields ignoring even notnull.

Comment #1

Posted on Mar 25, 2008 by Grumpy Ox

Yes this is a known bug. It seems to ignore a default value, if it is a number.

Comment #2

Posted on Apr 2, 2008 by Massive Cat

just adding a metoo -- Joel pointed out to me that a workaround would be to use raw sql in the migration file after the table and column has been created

Comment #3

Posted on May 22, 2008 by Grumpy Ox

Unfortunately this cannot be fixed easily without breaking current beahviour. So you will need to specify the default value like this:

    users:
        active: {type:bool, notnull:true, default:0}

Status: WontFix

Labels:
Type-Defect Priority-Medium