447 default = entity.defaultval |
447 default = entity.defaultval |
448 if default is not None: |
448 if default is not None: |
449 default = default.unzpickle() |
449 default = default.unzpickle() |
450 props = {'default': default, |
450 props = {'default': default, |
451 'indexed': entity.indexed, |
451 'indexed': entity.indexed, |
452 'formula': entity.formula, |
|
453 'fulltextindexed': entity.fulltextindexed, |
452 'fulltextindexed': entity.fulltextindexed, |
454 'internationalizable': entity.internationalizable} |
453 'internationalizable': entity.internationalizable} |
|
454 # entity.formula may not exist yet if we're migrating to 3.20 |
|
455 if hasattr(entity, 'formula'): |
|
456 props['formula'] = entity.formula |
455 # update the in-memory schema first |
457 # update the in-memory schema first |
456 rdefdef = self.init_rdef(**props) |
458 rdefdef = self.init_rdef(**props) |
457 # then make necessary changes to the system source database |
459 # then make necessary changes to the system source database |
458 syssource = cnx.repo.system_source |
460 syssource = cnx.repo.system_source |
459 attrtype = y2sql.type_from_constraints( |
461 attrtype = y2sql.type_from_constraints( |
503 if default is not None: |
505 if default is not None: |
504 default = convert_default_value(self.rdefdef, default) |
506 default = convert_default_value(self.rdefdef, default) |
505 cnx.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column), |
507 cnx.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column), |
506 {'default': default}) |
508 {'default': default}) |
507 # if attribute is computed, compute it |
509 # if attribute is computed, compute it |
508 if entity.formula: |
510 if getattr(entity, 'formula', None): |
509 # add rtype attribute for RelationDefinitionSchema api compat, this |
511 # add rtype attribute for RelationDefinitionSchema api compat, this |
510 # is what RecomputeAttributeOperation expect |
512 # is what RecomputeAttributeOperation expect |
511 rdefdef.rtype = rdefdef.name |
513 rdefdef.rtype = rdefdef.name |
512 RecomputeAttributeOperation.get_instance(cnx).add_data(rdefdef) |
514 RecomputeAttributeOperation.get_instance(cnx).add_data(rdefdef) |
513 |
515 |