def migrate(conn, tables):
    updateTablesPriority = ["ProductionOrders", "PicklistOrders"]

    for table in updateTablesPriority:
        if len(tables[table]["fields_Common"]) == 0:
            continue

        strCommonFields = ", ".join(tables[table]["fields_Common"])
        stmt = "INSERT OR REPLACE INTO {} ({}) SELECT {} FROM old.{};"
        conn.query(stmt.format(table, strCommonFields, strCommonFields, table))
