Skip to content

Commit

Permalink
Merge pull request #745 from scidsg/re-add-index-to-user-model
Browse files Browse the repository at this point in the history
re-add stripe_customer_id index to User model
  • Loading branch information
brassy-endomorph authored Nov 12, 2024
2 parents 91752af + 5635a0e commit 7574998
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hushline/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class User(Model):
tier_id: Mapped[int | None] = mapped_column(db.ForeignKey("tiers.id"), nullable=True)
tier: Mapped["Tier"] = relationship(backref=db.backref("tiers", lazy=True))

stripe_customer_id = mapped_column(db.String(255))
stripe_customer_id = mapped_column(db.String(255), index=True)
stripe_subscription_id = mapped_column(db.String(255), nullable=True)
stripe_subscription_cancel_at_period_end = mapped_column(db.Boolean, default=False)
stripe_subscription_status: Mapped[Optional[StripeSubscriptionStatusEnum]] = mapped_column(
Expand Down
29 changes: 29 additions & 0 deletions migrations/versions/06b343c38386_rename_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""rename index
Revision ID: 06b343c38386
Revises: 0b1321c8de13
Create Date: 2024-11-09 10:32:09.966628
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "06b343c38386"
down_revision = "0b1321c8de13"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.execute(
sa.text("ALTER INDEX idx_users_stripe_customer_id RENAME TO ix_users_stripe_customer_id")
)


def downgrade() -> None:
op.execute(
sa.text("ALTER INDEX ix_users_stripe_customer_id RENAME TO idx_users_stripe_customer_id")
)
1 change: 1 addition & 0 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
FIRST_TESTABLE_REVISION = "46aedec8fd9b"
SKIPPABLE_REVISIONS = [
"5ffe5a5c8e9a", # only renames indices and tables, no data changed
"06b343c38386", # only renames indices and tables, no data changed
]


Expand Down

0 comments on commit 7574998

Please sign in to comment.