mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Rename tables for pipeline models
This commit is contained in:
		
							
								
								
									
										59
									
								
								migrations/versions/63b2cc26a01f_.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								migrations/versions/63b2cc26a01f_.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
"""Rename pipeline model tables
 | 
			
		||||
 | 
			
		||||
Revision ID: 63b2cc26a01f
 | 
			
		||||
Revises: 260b57d5f4e7
 | 
			
		||||
Create Date: 2022-10-11 14:32:13.227364
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
from alembic import op
 | 
			
		||||
from flask import current_app
 | 
			
		||||
import os
 | 
			
		||||
from app.models import User
 | 
			
		||||
 | 
			
		||||
# revision identifiers, used by Alembic.
 | 
			
		||||
revision = '63b2cc26a01f'
 | 
			
		||||
down_revision = '260b57d5f4e7'
 | 
			
		||||
branch_labels = None
 | 
			
		||||
depends_on = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def upgrade():
 | 
			
		||||
    # ### commands auto generated by Alembic - please adjust! ###
 | 
			
		||||
    users = User.query.all()
 | 
			
		||||
    for user in users:
 | 
			
		||||
        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! ###
 | 
			
		||||
    users = User.query.all()
 | 
			
		||||
    for user in users:
 | 
			
		||||
        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
 | 
			
		||||
        )
 | 
			
		||||
    op.rename_table('tesseract_ocr_pipeline_models', 'tesseract_ocr_models')
 | 
			
		||||
    op.rename_table('transkribus_htr_pipeline_models', 'transkribus_htr_models')
 | 
			
		||||
    # ### end Alembic commands ###
 | 
			
		||||
		Reference in New Issue
	
	Block a user