From b56e9b106f676b12e00e6ebfa75c353e2ceb50e9 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 10 Aug 2021 13:57:18 +0200 Subject: [PATCH] adding migration for recycle document model --- ...c1897ce_adding_weight_to_tradedocuments.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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()}')