Skip to content

Commit

Permalink
Undo colin_event_id model changes (bcgov#3032)
Browse files Browse the repository at this point in the history
  • Loading branch information
leodube-aot authored Oct 21, 2024
1 parent b902dcd commit abad7a9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 117 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Undo colin_event_ids changes.
Revision ID: f3b30f43aa86
Revises: 698885b80fc0
Create Date: 2024-10-21 11:09:24.413272
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f3b30f43aa86'
down_revision = '698885b80fc0'
branch_labels = None
depends_on = None


def upgrade():
op.drop_constraint('colin_event_ids_batch_processing_id_fkey', 'colin_event_ids', type_='foreignkey')
op.drop_column('colin_event_ids', 'batch_processing_id')
op.drop_column('colin_event_ids', 'batch_processing_step')

def downgrade():
op.add_column('colin_event_ids', sa.Column('batch_processing_id', sa.Integer(), nullable=True))
op.add_column('colin_event_ids', sa.Column('batch_processing_step', sa.Enum(name='batch_processing_step'), nullable=True))
op.create_foreign_key('colin_event_ids_batch_processing_id_fkey', 'colin_event_ids', 'batch_processing', ['batch_processing_id'], ['id'])
16 changes: 0 additions & 16 deletions legal-api/src/legal_api/models/colin_event_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
The ColinEventId class and Schema are held in this module.
"""
from legal_api.models import BatchProcessing

from .db import db

Expand All @@ -27,11 +26,6 @@ class ColinEventId(db.Model): # pylint: disable=too-few-public-methods

colin_event_id = db.Column('colin_event_id', db.Integer, unique=True, primary_key=True)
filing_id = db.Column('filing_id', db.Integer, db.ForeignKey('filings.id'))
batch_processing_id = db.Column('batch_processing_id', db.Integer, db.ForeignKey('batch_processing.id'))
batch_processing_step = db.Column('batch_processing_step', db.Enum(BatchProcessing.BatchProcessingStep))

# relationships
batch_processing = db.relationship('BatchProcessing', lazy='select', uselist=False)

def save(self):
"""Save the object to the database immediately."""
Expand All @@ -53,13 +47,3 @@ def get_by_colin_id(colin_id):
colin_event_id_obj =\
db.session.query(ColinEventId).filter(ColinEventId.colin_event_id == colin_id).one_or_none()
return colin_event_id_obj

@staticmethod
def get_by_batch_processing_id(batch_processing_id):
"""Get the list of colin_event_ids linked to the given batch_processing_id."""
colin_event_id_objs = db.session.query(ColinEventId). \
filter(ColinEventId.batch_processing_id == batch_processing_id).all()
id_list = []
for obj in colin_event_id_objs:
id_list.append(obj.colin_event_id)
return id_list
101 changes: 0 additions & 101 deletions legal-api/tests/unit/models/test_colin_event_id.py

This file was deleted.

0 comments on commit abad7a9

Please sign in to comment.