-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/karl/feature/opt-out'
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
poprox-db/migrations/versions/2024_07_26_1352-98ff1c3ebe33_add_web_login_table.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,66 @@ | ||
"""add web_login table | ||
Revision ID: 98ff1c3ebe33 | ||
Revises: 211c6b3ac5de | ||
Create Date: 2024-07-26 13:52:10.169410 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "98ff1c3ebe33" | ||
down_revision: Union[str, None] = "211c6b3ac5de" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_table( | ||
"web_logins", | ||
sa.Column( | ||
"web_login_id", | ||
sa.UUID, | ||
primary_key=True, | ||
server_default=sa.text("gen_random_uuid()"), | ||
), | ||
sa.Column("account_id", sa.UUID, nullable=False), | ||
sa.Column("newsletter_id", sa.UUID, nullable=True), | ||
sa.Column("endpoint", sa.String, nullable=False), | ||
sa.Column("data", JSONB, nullable=False), # not raw_data -- only contains extra url parameters. | ||
sa.Column("created_at", sa.DateTime, nullable=False, server_default=sa.text("NOW()")), | ||
) | ||
|
||
op.create_foreign_key( | ||
"fk_web_logins_accounts_account_id", | ||
"web_logins", | ||
"accounts", | ||
["account_id"], | ||
["account_id"], | ||
) | ||
|
||
op.create_foreign_key( | ||
"fk_web_logins_newsletters_newsletter_id", | ||
"web_logins", | ||
"newsletters", | ||
["newsletter_id"], | ||
["newsletter_id"], | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_constraint( | ||
"fk_web_logins_accounts_account_id", | ||
"web_logins", | ||
type_="foreignkey", | ||
) | ||
op.drop_constraint( | ||
"fk_web_logins_newsletters_newsletter_id", | ||
"web_logins", | ||
type_="foreignkey", | ||
) | ||
|
||
op.drop_table("web_logins") |
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