From 3242a57586aaf280c47f4cc7b7fc08a30ece4807 Mon Sep 17 00:00:00 2001 From: VivianDee <115420678+VivianDee@users.noreply.github.com> Date: Wed, 4 Jun 2025 12:43:38 +0100 Subject: [PATCH] [update]: Loan and repayment table --- app/models/loan.py | 4 +++ app/models/repayment.py | 6 ++++ migrations/versions/45790fd659fb_.py | 54 ++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 migrations/versions/45790fd659fb_.py diff --git a/app/models/loan.py b/app/models/loan.py index 1c5d158..edf56f4 100644 --- a/app/models/loan.py +++ b/app/models/loan.py @@ -45,6 +45,10 @@ class Loan(db.Model): disburse_date = db.Column(db.DateTime, nullable=True) disburse_verify = db.Column(db.DateTime, nullable=True) reference = db.Column(db.String(50), nullable=True) + disburse_result = db.Column(db.String(10), nullable=True) + disburse_description = db.Column(db.String(100), nullable=True) + verify_result = db.Column(db.String(10), nullable=True) + verify_description = db.Column(db.String(100), nullable=True) customer = relationship( "Customer", diff --git a/app/models/repayment.py b/app/models/repayment.py index be77d2c..1116e0a 100644 --- a/app/models/repayment.py +++ b/app/models/repayment.py @@ -21,6 +21,12 @@ class Repayment(db.Model): created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) transaction_id = db.Column(db.String(50), nullable=True) + repay_date = db.Column(db.DateTime, default=datetime.now(timezone.utc)) + repay_result = db.Column(db.String(10), nullable=True) + repay_description = db.Column(db.String(100), nullable=True) + verify_date = db.Column(db.DateTime, default=datetime.now(timezone.utc)) + verify_result = db.Column(db.String(10), nullable=True) + verify_description = db.Column(db.String(100), nullable=True) @classmethod def create_repayment(cls, customer_id, loan, transaction_id): diff --git a/migrations/versions/45790fd659fb_.py b/migrations/versions/45790fd659fb_.py new file mode 100644 index 0000000..2895b4f --- /dev/null +++ b/migrations/versions/45790fd659fb_.py @@ -0,0 +1,54 @@ +"""empty message + +Revision ID: 45790fd659fb +Revises: b3a5e10bc77e +Create Date: 2025-06-04 12:37:48.180736 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '45790fd659fb' +down_revision = 'b3a5e10bc77e' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('loans', schema=None) as batch_op: + batch_op.add_column(sa.Column('disburse_result', sa.String(length=10), nullable=True)) + batch_op.add_column(sa.Column('disburse_description', sa.String(length=100), nullable=True)) + batch_op.add_column(sa.Column('verify_result', sa.String(length=10), nullable=True)) + batch_op.add_column(sa.Column('verify_description', sa.String(length=100), nullable=True)) + + with op.batch_alter_table('repayments', schema=None) as batch_op: + batch_op.add_column(sa.Column('repay_date', sa.DateTime(), nullable=True)) + batch_op.add_column(sa.Column('repay_result', sa.String(length=10), nullable=True)) + batch_op.add_column(sa.Column('repay_description', sa.String(length=100), nullable=True)) + batch_op.add_column(sa.Column('verify_date', sa.DateTime(), nullable=True)) + batch_op.add_column(sa.Column('verify_result', sa.String(length=10), nullable=True)) + batch_op.add_column(sa.Column('verify_description', sa.String(length=100), nullable=True)) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('repayments', schema=None) as batch_op: + batch_op.drop_column('verify_description') + batch_op.drop_column('verify_result') + batch_op.drop_column('verify_date') + batch_op.drop_column('repay_description') + batch_op.drop_column('repay_result') + batch_op.drop_column('repay_date') + + with op.batch_alter_table('loans', schema=None) as batch_op: + batch_op.drop_column('verify_description') + batch_op.drop_column('verify_result') + batch_op.drop_column('disburse_description') + batch_op.drop_column('disburse_result') + + # ### end Alembic commands ### -- 2.34.1