def upgrade():
    from autonomie.models.task import WorkUnit
    from autonomie.models.task.estimation import EstimationLine
    from autonomie.models.task.invoice import InvoiceLine
    from autonomie.models.task.invoice import CancelInvoiceLine
    from autonomie_base.models.base import DBSESSION
    # Adding some characters to the Lines
    for table in "estimation_line", "invoice_line", "cancelinvoice_line":
        op.alter_column(table, "unity", type_=sa.String(100))

    for value in UNITS:
        unit = WorkUnit(label=value)
        DBSESSION().add(unit)
    for factory in (EstimationLine, InvoiceLine, CancelInvoiceLine):
        for line in factory.query():
            line.unity = translate_unity(line.unity)
            DBSESSION().merge(line)