More work on igrations

This commit is contained in:
mike cullerton 2022-04-14 18:06:08 -04:00
parent 70beba164b
commit 389d2b413e
4 changed files with 9 additions and 5 deletions

View File

@ -14,7 +14,7 @@ class DataStoreModel(db.Model):
task_spec = db.Column(db.String)
spec_id = db.Column(db.String)
user_id = db.Column(db.String, nullable=True)
file_id = db.Column(db.Integer, db.ForeignKey('file.id'), nullable=True)
# file_id = db.Column(db.Integer, db.ForeignKey('file.id'), nullable=True)
document_id = db.Column(db.Integer, db.ForeignKey('document.id'), nullable=True)
value = db.Column(db.String)

View File

@ -105,7 +105,7 @@ class FileModel(db.Model):
workflow_id = db.Column(db.Integer, db.ForeignKey('workflow.id'), nullable=True)
task_spec = db.Column(db.String, nullable=True)
irb_doc_code = db.Column(db.String, nullable=True) # Code reference to the documents.xlsx reference file.
data_stores = relationship(DataStoreModel, cascade="all,delete", backref="file")
# data_stores = relationship(DataStoreModel, cascade="all,delete", backref="file")
class File(object):

View File

@ -74,8 +74,12 @@ def upgrade():
# except Exception as e:
# app.logger.info(
# f'Error migrating file data. File ID: {file_model.id}, File Data ID: {file_data_model.id}, Original error: {e}')
op.drop_constraint('file_id_key', 'data_store', type_='foreignkey')
# op.drop_column('data_store', 'file_id')
def downgrade():
op.execute('DELETE FROM document;')
# op.add_column('data_store', sa.Column('file_id', sa.Integer(), nullable=True))
# op.create_foreign_key('file_id_key', 'data_store', 'file', ['file_id'], ['id'])
op.execute('UPDATE data_store SET document_id = null')
op.execute('DELETE FROM document;')

View File

@ -44,6 +44,6 @@ def upgrade():
def downgrade():
op.drop_constraint('document_id_key', 'data_store', type_='foreignkey')
op.drop_column('data_store', 'document_id')
op.drop_table('document')
# op.drop_column('data_store', 'document_id')
# op.drop_constraint('document_id_key', 'data_store', type_='foreignkey')