-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
de62c4e
commit 3f5d5ae
Showing
8 changed files
with
407 additions
and
38 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
alembic/versions/20240821_7a2fcaac8b63_add_loan_identifier_column_to_playtime_tables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Add loan_identifier column to playtime tables. | ||
Revision ID: 7a2fcaac8b63 | ||
Revises: 7ba553f3f80d | ||
Create Date: 2024-08-21 23:23:48.085451+00:00 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.orm.session import Session | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7a2fcaac8b63" | ||
down_revision = "7ba553f3f80d" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
session = Session(bind=op.get_bind()) | ||
conn = session.connection() | ||
|
||
op.add_column( | ||
"playtime_entries", | ||
sa.Column("loan_identifier", sa.String(length=40), nullable=False, default=""), | ||
) | ||
|
||
op.add_column( | ||
"playtime_summaries", | ||
sa.Column("loan_identifier", sa.String(length=40), nullable=False, default=""), | ||
) | ||
|
||
op.drop_constraint("unique_playtime_summary", "playtime_summaries", type_="unique") | ||
|
||
op.create_unique_constraint( | ||
"unique_playtime_summary", | ||
"playtime_summaries", | ||
[ | ||
"timestamp", | ||
"identifier_str", | ||
"collection_name", | ||
"library_name", | ||
"loan_identifier", | ||
], | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("playtime_entries", "loan_identifier") | ||
|
||
op.drop_constraint("unique_playtime_summary", "playtime_summaries", type_="unique") | ||
|
||
op.drop_column("playtime_summaries", "loan_identifier") | ||
|
||
op.create_unique_constraint( | ||
"unique_playtime_summary", | ||
"playtime_summaries", | ||
["timestamp", "identifier_str", "collection_name", "library_name"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.