()
Link existing images to first department
Link existing images to first department
Link existing images to first department
def link_images_to_department():
    """Link existing images to first department"""
    from app.models import Image, db
    images = Image.query.all()
    print("Linking images to first department:")
    for image in images:
        if not image.department_id:
            sys.stdout.write(".")
            image.department_id = 1
        else:
            print("Skipped! Department already assigned")
    db.session.commit()
def link_images_to_department ( ) : from app . models import Image , db images = Image . query . all ( ) print ( "Linking images to first department:" ) for image in images : if not image . department_id : sys . stdout . write ( "." ) image . department_id = 1 else : print ( "Skipped! Department already assigned" ) db . session . commit ( )