Extend an existing model with a new field with required=True will FAIL if Data is already in the Database?
I try to extend an existing model (calendar.event) with an new field "category" with required = True.
The addon can be installed on new databases without any problem and also the SQL constraint (NOT NULL) is successfully set for new Databases.
The Problem is that for databases with existing data the new field would need a default value for all of the existing data records or it could not set the SQL constraint and it will throw an error when installed. I really do not want to use a default value for this new field because the user should correctly enter a value!
Is there a way to set a value for all existing records in the database, so that installation would work, but no default value for added fields with required=True ?
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 8/11/15, 8:34 AM|
|Seen: 329 times|
|Last updated: 8/12/15, 12:09 AM|