Add user_uid column to file_data table

This commit is contained in:
mike cullerton 2021-07-06 17:07:47 -04:00
parent 7406bf7da1
commit 23be257db0
2 changed files with 28 additions and 0 deletions

View File

@ -69,6 +69,7 @@ class FileDataModel(db.Model):
date_created = db.Column(db.DateTime(timezone=True), server_default=func.now()) date_created = db.Column(db.DateTime(timezone=True), server_default=func.now())
file_model_id = db.Column(db.Integer, db.ForeignKey('file.id')) file_model_id = db.Column(db.Integer, db.ForeignKey('file.id'))
file_model = db.relationship("FileModel", foreign_keys=[file_model_id]) file_model = db.relationship("FileModel", foreign_keys=[file_model_id])
user_uid = db.Column(db.String, db.ForeignKey('user.uid'), nullable=True)

View File

@ -0,0 +1,27 @@
"""add user_uid column to file_data table
Revision ID: 30e017a03948
Revises: bbf064082623
Create Date: 2021-07-06 10:39:04.661704
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '30e017a03948'
down_revision = 'bbf064082623'
branch_labels = None
depends_on = None
def upgrade():
op.add_column('file_data', sa.Column('user_uid', sa.String(), nullable=True))
op.create_foreign_key(None, 'file_data', 'user', ['user_uid'], ['uid'])
def downgrade():
# op.drop_constraint('file_data_user_uid_fkey', 'file_data', type_='foreignkey')
# op.execute("update file_data set user_uid = NULL WHERE user_uid IS NOT NULL")
op.drop_column('file_data', 'user_uid')