-
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.
fixing some issues with the testing set up along the way
- Loading branch information
1 parent
1a3d360
commit c4d4b31
Showing
5 changed files
with
124 additions
and
29 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
71 changes: 71 additions & 0 deletions
71
backend/app/alembic/versions/6f0559e497ba_assignments_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,71 @@ | ||
"""assignments table | ||
Revision ID: 6f0559e497ba | ||
Revises: 966d8d72887e | ||
Create Date: 2024-07-21 16:08:29.504177 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
from sqlmodel.sql import sqltypes | ||
import sqlalchemy as sa | ||
|
||
from app.models import UUIDType | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "6f0559e497ba" | ||
down_revision: Union[str, None] = "966d8d72887e" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"document", | ||
sa.Column( | ||
"created_at", | ||
sa.TIMESTAMP(timezone=True), | ||
server_default=sa.text("CURRENT_TIMESTAMP"), | ||
nullable=False, | ||
), | ||
sa.Column( | ||
"updated_at", | ||
sa.TIMESTAMP(timezone=True), | ||
server_default=sa.text("CURRENT_TIMESTAMP"), | ||
nullable=False, | ||
), | ||
sa.Column("document_id", UUIDType(), nullable=False), | ||
sa.PrimaryKeyConstraint("document_id"), | ||
sa.UniqueConstraint("document_id"), | ||
) | ||
op.create_table( | ||
"assignments", | ||
sa.Column("document_id", sa.UUID(), nullable=False), | ||
sa.Column("geo_id", sqltypes.AutoString(), nullable=False), | ||
sa.Column("zone", sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["document_id"], | ||
["document.document_id"], | ||
), | ||
sa.PrimaryKeyConstraint("document_id", "geo_id"), | ||
postgresql_partition_by="LIST (document_id)", | ||
) | ||
op.alter_column("gerrydbtable", "uuid", existing_type=sa.UUID(), nullable=False) | ||
op.drop_column("gerrydbtable", "id") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"gerrydbtable", | ||
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), | ||
) | ||
op.alter_column("gerrydbtable", "uuid", existing_type=sa.UUID(), nullable=True) | ||
op.drop_table("assignments") | ||
op.drop_table("document") | ||
# ### end Alembic commands ### |
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