-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/districtr/districtr-v2 into…
… feat/chart-enhancements
- Loading branch information
Showing
20 changed files
with
498 additions
and
125 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
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
109 changes: 109 additions & 0 deletions
109
backend/app/alembic/versions/2494caf34886_soft_delete_districtrmap.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,109 @@ | ||
"""soft delete districtrmap | ||
Revision ID: 2494caf34886 | ||
Revises: f86991e63a62 | ||
Create Date: 2024-11-18 09:37:23.352006 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "2494caf34886" | ||
down_revision: Union[str, None] = "f86991e63a62" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column( | ||
"districtrmap", | ||
sa.Column("visible", sa.Boolean(), nullable=False, server_default="true"), | ||
) | ||
op.execute( | ||
sa.text( | ||
""" | ||
CREATE OR REPLACE FUNCTION create_districtr_map( | ||
map_name VARCHAR, | ||
gerrydb_table_name VARCHAR, | ||
num_districts INTEGER, | ||
tiles_s3_path VARCHAR, | ||
parent_layer_name VARCHAR, | ||
child_layer_name VARCHAR, | ||
visibility BOOLEAN DEFAULT TRUE | ||
) | ||
RETURNS UUID AS $$ | ||
DECLARE | ||
inserted_districtr_uuid UUID; | ||
BEGIN | ||
INSERT INTO districtrmap ( | ||
created_at, | ||
uuid, | ||
name, | ||
gerrydb_table_name, | ||
num_districts, | ||
tiles_s3_path, | ||
parent_layer, | ||
child_layer, | ||
visible | ||
) | ||
VALUES ( | ||
now(), | ||
gen_random_uuid(), | ||
map_name, | ||
gerrydb_table_name, | ||
num_districts, | ||
tiles_s3_path, | ||
parent_layer_name, | ||
child_layer_name, | ||
visibility | ||
) | ||
RETURNING uuid INTO inserted_districtr_uuid; | ||
RETURN inserted_districtr_uuid; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
""" | ||
) | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("districtrmap", "visible") | ||
op.execute( | ||
sa.text( | ||
""" | ||
CREATE OR REPLACE FUNCTION create_districtr_map( | ||
map_name VARCHAR, | ||
gerrydb_table_name VARCHAR, | ||
num_districts INTEGER, | ||
tiles_s3_path VARCHAR, | ||
parent_layer_name VARCHAR, | ||
child_layer_name VARCHAR | ||
) | ||
RETURNS UUID AS $$ | ||
DECLARE | ||
inserted_districtr_uuid UUID; | ||
BEGIN | ||
INSERT INTO districtrmap ( | ||
created_at, | ||
uuid, | ||
name, | ||
gerrydb_table_name, | ||
num_districts, | ||
tiles_s3_path, | ||
parent_layer, | ||
child_layer | ||
) | ||
VALUES (now(), gen_random_uuid(), $1, $2, $3, $4, $5, $6) | ||
RETURNING uuid INTO inserted_districtr_uuid; | ||
RETURN inserted_districtr_uuid; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
""" | ||
) | ||
) |
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.