diff --git a/ereuse_devicehub/migrations/versions/3ac2bc1897ce_adding_weight_to_tradedocuments.py b/ereuse_devicehub/migrations/versions/3ac2bc1897ce_adding_weight_to_tradedocuments.py index 38fa9b69..6e259684 100644 --- a/ereuse_devicehub/migrations/versions/3ac2bc1897ce_adding_weight_to_tradedocuments.py +++ b/ereuse_devicehub/migrations/versions/3ac2bc1897ce_adding_weight_to_tradedocuments.py @@ -8,6 +8,7 @@ Create Date: 2021-08-03 16:28:38.719686 from alembic import op import sqlalchemy as sa from alembic import context +from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. @@ -26,6 +27,24 @@ def get_inv(): def upgrade(): op.add_column("trade_document", sa.Column("weight", sa.Float(decimal_return_scale=2), nullable=True), schema=f'{get_inv()}') + # DataWipeDocument table + op.create_table('recycle_document', + sa.Column('id', sa.BigInteger(), nullable=False), + sa.Column('trade_document_id', sa.BigInteger(), nullable=False), + sa.Column( + 'lot_id', + postgresql.UUID(as_uuid=True), + nullable=False + ), + sa.Column("weight", sa.Float(decimal_return_scale=2), nullable=True), + sa.ForeignKeyConstraint(['lot_id'], [f'{get_inv()}.lot.id'],), + sa.ForeignKeyConstraint(['trade_document_id'], [f'{get_inv()}.trade_document.id'], ), + sa.ForeignKeyConstraint(['id'], [f'{get_inv()}.document.id'], ), + sa.PrimaryKeyConstraint('id'), + schema=f'{get_inv()}' + ) + def downgrade(): op.drop_column('trade_document', 'weight', schema=f'{get_inv()}') + op.drop_table('recycle_document', schema=f'{get_inv()}')