def delete_trajectory_symbols_array(apps, _): """Delete the symbols array from all `TrajectoryData` nodes.""" DbNode = apps.get_model('db', 'DbNode') DbAttribute = apps.get_model('db', 'DbAttribute') modifier = ModelModifierV0025(apps, DbAttribute) nodes = DbNode.objects.filter(type='node.data.array.trajectory.TrajectoryData.').values_list('id', 'uuid') for pk, uuid in nodes: modifier.del_value_for_node(DbNode.objects.get(pk=pk), 'array|symbols') utils.delete_numpy_array_from_repository(uuid, 'symbols')
def upgrade(): """Migrations for the upgrade.""" # yapf:disable connection = op.get_bind() DbNode = table('db_dbnode', column('id', Integer), column('uuid', UUID), column('type', String), column('attributes', JSONB)) nodes = connection.execute( select([DbNode.c.id, DbNode.c.uuid]).where( DbNode.c.type == op.inline_literal('node.data.array.trajectory.TrajectoryData.'))).fetchall() for pk, uuid in nodes: connection.execute( text("""UPDATE db_dbnode SET attributes = attributes #- '{{array|symbols}}' WHERE id = {}""".format(pk))) utils.delete_numpy_array_from_repository(uuid, 'symbols')