Skip to content

add Raredisease order type to database #4365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

diitaz93
Copy link
Contributor

@diitaz93 diitaz93 commented Apr 25, 2025

Description

Closes #4364

Added

  • Raredisease to the OrderType Strenum
  • Alembic migration to allow new ordertype in the order_type_application table

How to prepare for test

  • Ssh to relevant server (depending on type of change)
  • Use stage: us
  • Paxa the environment: paxa
  • Deploy on CGVS-stage
  • Install on stage (example for Hasta):
    bash /home/proj/production/servers/resources/hasta.scilifelab.se/update-tool-stage.sh -e S_cg -t cg -b add-raredisease-ordertype -a

How to test

  • Do alembic -c $ALEMBIC_CG_STAGE upgrade 039dbdf8af01
  • Add an entry containing RAREDISEASE to the order_type_application table
  • Do alembic -c $ALEMBIC_CG_STAGE downgrade -1 head

Expected test outcome

  • Check that the upgrade went without errors
jsdiazboada@juasebmbp cg % alembic -c $ALEMBIC_CG_STAGE upgrade 039dbdf8af01                   
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 6362cfd4c61f -> 039dbdf8af01, add Raredisease ordertype
(cg-py3.11) (base) jsdiazboada@juasebmbp cg % 
  • In admin view in statusdb the new entry appears
Screenshot 2025-04-25 at 15 48 07 Screenshot 2025-04-25 at 15 47 07 Screenshot 2025-04-25 at 16 00 48
  • Check that the downgrade went without errors and deletes the new entries
 jsdiazboada@juasebmbp cg % alembic -c $ALEMBIC_CG_STAGE downgrade -1
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade 039dbdf8af01 -> 6362cfd4c61f, add Raredisease ordertype
(cg-py3.11) (base) jsdiazboada@juasebmbp cg %

Review

  • Tests executed by SD
  • "Merge and deploy" approved by IO
    Thanks for filling in who performed the code review and the test!

This version is a

  • MINOR - when you add functionality in a backwards compatible manner

Implementation Plan

  • Deployed to stage:
  • Deployed to production:

@diitaz93 diitaz93 requested a review from a team as a code owner April 25, 2025 12:25
Copy link
Contributor

@islean islean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

"""Maps an order type to its allowed applications"""

__tablename__ = "order_type_application"
order_type = sa.Column(sa.types.Enum(*list(OrderType)), primary_key=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity - the primary key of the OrderTypeApplication table is a composite key over both order type and application. Should order_type be marked as primary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key is defined as primary in the definition of the store model, so I would say so:

class OrderTypeApplication(Base):
    """Maps an order type to its allowed applications"""

    __tablename__ = "order_type_application"

    order_type: Mapped[OrderType] = mapped_column(sqlalchemy.Enum(OrderType), primary_key=True)
    application_id: Mapped[int] = mapped_column(
        ForeignKey("application.id", ondelete="CASCADE"), primary_key=True
    )
    application: Mapped[Application] = orm.relationship(
        "Application", back_populates="order_type_applications"
    )

but not sure if I should include the application in the migration model. I assumed not as I don't need it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works it works! Just surprised me a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works!

@clingen-sthlm clingen-sthlm temporarily deployed to stage April 25, 2025 13:43 Inactive
@diitaz93 diitaz93 added the alembic migration Perform a change in database label Apr 25, 2025
@diitaz93 diitaz93 self-assigned this Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alembic migration Perform a change in database
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Raredisease as an order type
3 participants