From ddbabcaca985e0722df5d549e3f9213250334e2a Mon Sep 17 00:00:00 2001 From: VivianDee <115420678+VivianDee@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:10:07 +0100 Subject: [PATCH] [fix]: Repayment schedule model --- app/models/loan_repayment_schedule.py | 4 +- ...4_migration_on_thu_apr_24_17_42_25_utc_.py | 6 --- ...2_migration_on_fri_apr_25_14_02_01_utc_.py | 41 +++++++++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 migrations/versions/2cf0c177ca02_migration_on_fri_apr_25_14_02_01_utc_.py diff --git a/app/models/loan_repayment_schedule.py b/app/models/loan_repayment_schedule.py index 2523964..aeb1923 100644 --- a/app/models/loan_repayment_schedule.py +++ b/app/models/loan_repayment_schedule.py @@ -19,9 +19,9 @@ class LoanRepaymentSchedule(db.Model): loan = relationship( "Loan", - primaryjoin="LoanCharge.loan_id == Loan.id", + primaryjoin="LoanRepaymentSchedule.loan_id == Loan.id", foreign_keys=[loan_id], - back_populates="loan_charges", + back_populates="loan_repayment_schedules", ) @classmethod diff --git a/migrations/versions/1b2339f43824_migration_on_thu_apr_24_17_42_25_utc_.py b/migrations/versions/1b2339f43824_migration_on_thu_apr_24_17_42_25_utc_.py index c72a985..c66d8a4 100644 --- a/migrations/versions/1b2339f43824_migration_on_thu_apr_24_17_42_25_utc_.py +++ b/migrations/versions/1b2339f43824_migration_on_thu_apr_24_17_42_25_utc_.py @@ -33,12 +33,6 @@ def upgrade(): existing_type=sa.NUMERIC(precision=10, scale=2), type_=sa.Float(), existing_nullable=True) - - with op.batch_alter_table('loans', schema=None) as batch_op: - batch_op.add_column(sa.Column('upfront_fee', sa.Float(), nullable=True)) - batch_op.add_column(sa.Column('repayment_amount', sa.Float(), nullable=True)) - batch_op.add_column(sa.Column('installment_amount', sa.Float(), nullable=True)) - # ### end Alembic commands ### diff --git a/migrations/versions/2cf0c177ca02_migration_on_fri_apr_25_14_02_01_utc_.py b/migrations/versions/2cf0c177ca02_migration_on_fri_apr_25_14_02_01_utc_.py new file mode 100644 index 0000000..6876ba6 --- /dev/null +++ b/migrations/versions/2cf0c177ca02_migration_on_fri_apr_25_14_02_01_utc_.py @@ -0,0 +1,41 @@ +"""Migration on Fri Apr 25 14:02:01 UTC 2025 + +Revision ID: 2cf0c177ca02 +Revises: 1b2339f43824 +Create Date: 2025-04-25 14:02:42.244146 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '2cf0c177ca02' +down_revision = '1b2339f43824' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('loan_repayment_schedules', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('loan_id', sa.Integer(), nullable=False), + sa.Column('installment_number', sa.Integer(), nullable=False), + sa.Column('due_date', sa.DateTime(), nullable=False), + sa.Column('principal_amount', sa.Float(), nullable=True), + sa.Column('interest_amount', sa.Float(), nullable=True), + sa.Column('total_installment', sa.Float(), nullable=True), + sa.Column('paid', sa.Boolean(), nullable=True), + sa.Column('paid_at', sa.DateTime(), nullable=True), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('loan_repayment_schedules') + # ### end Alembic commands ###