Add parallel fs changes to migration scripts and cleanup

This commit is contained in:
Patrick Jentsch
2022-10-26 10:34:07 +02:00
parent cbf3abb424
commit 0b656d3cf1
8 changed files with 223 additions and 210 deletions

View File

@@ -5,8 +5,8 @@ Revises: 260b57d5f4e7
Create Date: 2022-10-11 14:32:13.227364
"""
from genericpath import isdir
from alembic import op
from flask import current_app
import os
from app.models import User
@@ -18,40 +18,19 @@ depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
for user in User.query.all():
old_tesseract_ocr_pipeline_model_path = os.path.join(
user.path,
'tesseract_ocr_models'
)
new_tesseract_ocr_pipeline_model_path = os.path.join(
user.path,
'tesseract_ocr_pipeline_models'
)
os.rename(
old_tesseract_ocr_pipeline_model_path,
new_tesseract_ocr_pipeline_model_path
)
old_tesseract_ocr_pipeline_model_path = os.path.join(user.path, 'tesseract_ocr_models')
new_tesseract_ocr_pipeline_model_path = os.path.join(user.path, 'tesseract_ocr_pipeline_models')
os.rename(old_tesseract_ocr_pipeline_model_path, new_tesseract_ocr_pipeline_model_path)
op.rename_table('tesseract_ocr_models', 'tesseract_ocr_pipeline_models')
op.rename_table('transkribus_htr_models', 'transkribus_htr_pipeline_models')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
for user in User.query.all():
old_tesseract_ocr_pipeline_model_path = os.path.join(
user.path,
'tesseract_ocr_models'
)
new_tesseract_ocr_pipeline_model_path = os.path.join(
user.path,
'tesseract_ocr_pipeline_models'
)
os.rename(
new_tesseract_ocr_pipeline_model_path,
old_tesseract_ocr_pipeline_model_path
)
old_tesseract_ocr_pipeline_model_path = os.path.join(user.path, 'tesseract_ocr_models')
new_tesseract_ocr_pipeline_model_path = os.path.join(user.path, 'tesseract_ocr_pipeline_models')
os.rename(old_tesseract_ocr_pipeline_model_path, new_tesseract_ocr_pipeline_model_path)
os.rename(new_tesseract_ocr_pipeline_model_path, old_tesseract_ocr_pipeline_model_path)
op.rename_table('tesseract_ocr_pipeline_models', 'tesseract_ocr_models')
op.rename_table('transkribus_htr_pipeline_models', 'transkribus_htr_models')
# ### end Alembic commands ###