Hi Ted,

You could create the column with allows null = false and a default value of 
false using: 

        ERXMigrationTable securityTable = 
database.existingTableNamed("security");
        securityTable.newIntBooleanColumn("canseeprojects", false, false);

Which will set the value for all existing rows to false, and then in the next 
migration call: 

        ERXMigrationTable securityTable = 
database.existingTableNamed("security");
        ERXMigrationColumn canSeeProjects =  
securityTable.existingColumnNamed(“canseeprojects”);
        canSeeProjects.setDefault(null);

That way you aren’t writing any actual SQL.

Dave


On Mar 21, 2014, at 8:24 AM, Theodore Petrosky <[email protected]> wrote:

> I have a running D2W app and I need to add some booleans to my User.security 
> Entity.
> 
> Normally I accomplish this by:
> 
> adding the boolean to my postgresql db with migrations:
> 
>     ERXMigrationTable securityTable = database.existingTableNamed("security");
>     securityTable.newFlagBooleanColumn("canseeprojects", true);
> 
> (I am setting allowsNull to true even thought I want it to be false. )
> 
> then I update the security's new attribute to false for current security 
> entries, and change the table to not allowsNull:
> 
>    /*
>     * Fix the canseeprojects boolean
>     */
>     ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),   "UPDATE 
> security SET canseeprojects = false");
> 
>     securityTable.existingColumnNamed("canseeprojects").setAllowsNull(false);
> 
> 
> Is there an easier way, or is this just an artifact to live with?
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com
> 
> This email sent to [email protected]


—————————————————————————————
WebObjects - so easy that even Dave Avendasora can do it!™
—————————————————————————————
David Avendasora
Senior Software Abuser
Nekesto, Inc.







 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to