-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[raw data resource locks] update lock_ttl to lock_ttl_seconds (Recidi…
…viz/recidiviz-data#29452) ## Description of the change i apparently didn't look that hard and the pg `Interval` type is indeed [not supported](https://cloud.google.com/bigquery/docs/reference/standard-sql/federated_query_functions#postgresql_mapping) by federated bq queries to pg. this pr updates the `lock_ttl` column of type `Interval` to instead be `lock_ttl_seconds` of type `Integer` and updates the associated manager and tests to reflect this change. i havent written a ton of alembic migrations but took my best swing at removing and adding the associated `CheckConstraint`; would love some feedback if that looks right! ## Type of change > All pull requests must have at least one of the following labels applied (otherwise the PR will fail): | Label | Description | |----------------------------- |----------------------------------------------------------------------------------------------------------- | | Type: Bug | non-breaking change that fixes an issue | | Type: Feature | non-breaking change that adds functionality | | Type: Breaking Change | fix or feature that would cause existing functionality to not work as expected | | Type: Non-breaking refactor | change addresses some tech debt item or prepares for a later change, but does not change functionality | | Type: Configuration Change | adjusts configuration to achieve some end related to functionality, development, performance, or security | | Type: Dependency Upgrade | upgrades a project dependency - these changes are not included in release notes | ## Related issues Closes Recidiviz/recidiviz-data#29451 ## Checklists ### Development **This box MUST be checked by the submitter prior to merging**: - [x] **Double- and triple-checked that there is no Personally Identifiable Information (PII) being mistakenly added in this pull request** These boxes should be checked by the submitter prior to merging: - [x] Tests have been written to cover the code changed/added as part of this pull request ### Code review These boxes should be checked by reviewers prior to merging: - [ ] This pull request has a descriptive title and information useful to a reviewer - [ ] Potential security implications or infrastructural changes have been considered, if relevant GitOrigin-RevId: 86ea4499f7711babb75348d18ce3b5fc94c5e7ad
- Loading branch information
Showing
7 changed files
with
87 additions
and
26 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
59 changes: 59 additions & 0 deletions
59
...ations/operations/versions/2024_04_29_1942_2a6d882eaf1c_update_lock_ttl_to_use_seconds.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 @@ | ||
# pylint: skip-file | ||
"""update_lock_ttl_to_use_seconds | ||
Revision ID: 2a6d882eaf1c | ||
Revises: a92c4af755cc | ||
Create Date: 2024-04-29 19:42:55.756028 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "2a6d882eaf1c" | ||
down_revision = "a92c4af755cc" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint( | ||
"all_process_actors_must_specify_ttl", | ||
"direct_ingest_raw_data_resource_lock", | ||
type_="check", | ||
) | ||
op.drop_column("direct_ingest_raw_data_resource_lock", "lock_ttl") | ||
op.add_column( | ||
"direct_ingest_raw_data_resource_lock", | ||
sa.Column("lock_ttl_seconds", sa.Integer(), nullable=True), | ||
) | ||
op.create_check_constraint( | ||
"all_process_actors_must_specify_ttl_seconds", | ||
"direct_ingest_raw_data_resource_lock", | ||
"lock_actor = 'ADHOC' OR (lock_actor = 'PROCESS' and lock_ttl_seconds IS NOT NULL)", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint( | ||
"all_process_actors_must_specify_ttl_seconds", | ||
"direct_ingest_raw_data_resource_lock", | ||
type_="check", | ||
) | ||
op.add_column( | ||
"direct_ingest_raw_data_resource_lock", | ||
sa.Column( | ||
"lock_ttl", postgresql.INTERVAL(), autoincrement=False, nullable=True | ||
), | ||
) | ||
op.drop_column("direct_ingest_raw_data_resource_lock", "lock_ttl_seconds") | ||
op.create_check_constraint( | ||
"all_process_actors_must_specify_ttl", | ||
"direct_ingest_raw_data_resource_lock", | ||
"lock_actor = 'ADHOC' OR (lock_actor = 'PROCESS' and lock_ttl IS NOT NULL)", | ||
) | ||
# ### 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
2 changes: 1 addition & 1 deletion
2
recidiviz/tools/admin_panel/fixtures/operations_db/direct_ingest_raw_data_resource_lock.csv
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
lock_id,lock_actor,lock_resource,region_code,raw_data_source_instance,released,lock_acquisition_time,lock_ttl,lock_description | ||
lock_id,lock_actor,lock_resource,region_code,raw_data_source_instance,released,lock_acquisition_time,lock_ttl_seconds,lock_description | ||
1,ADHOC,BUCKET,US_CA,PRIMARY,true,2024-02-09T19:06:00.000000+00,,we held this lock just bc we could | ||
2,ADHOC,BUCKET,US_CA,PRIMARY,false,2024-02-10T19:06:00.000000+00,,we holding this lock just bc we can |