-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dataset destination management in fieldmapping service + mi…
…gration
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
.../geonature/migrations/versions/imports/a43842db7ac1_monitorings_adjust_gn_imports_bib_.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,65 @@ | ||
"""[monitorings] Adjust gn.imports bib_fields id_dataset and unique_id_dataset values | ||
Revision ID: a43842db7ac1 | ||
Revises: 2b0b3bd0248c | ||
Create Date: 2024-12-17 11:18:07.806852 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'a43842db7ac1' | ||
down_revision = '2b0b3bd0248c' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
def upgrade(): | ||
op.execute( | ||
""" | ||
UPDATE gn_imports.bib_fields | ||
SET display = TRUE, | ||
mandatory = TRUE, | ||
optional_conditions = '{"unique_dataset_id"}', | ||
type_field = 'dataset', | ||
type_field_params = '{"bind_value": "id_dataset"}' | ||
WHERE name_field = 'id_dataset' | ||
""" | ||
) | ||
op.execute( | ||
""" | ||
UPDATE gn_imports.bib_fields | ||
SET display = TRUE, | ||
mandatory = TRUE, | ||
optional_conditions = '{"id_dataset"}', | ||
type_field = 'dataset', | ||
type_field_params = '{"bind_value": "unique_dataset_id"}' | ||
WHERE name_field = 'unique_dataset_id' | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.execute( | ||
""" | ||
UPDATE gn_imports.bib_fields | ||
SET display = FALSE, | ||
mandatory = FALSE, | ||
optional_conditions = NULL, | ||
type_field = 'text', | ||
type_field_params = NULL | ||
WHERE name_field = 'id_dataset' | ||
""" | ||
) | ||
op.execute( | ||
""" | ||
UPDATE gn_imports.bib_fields | ||
SET display = FALSE, | ||
mandatory = FALSE, | ||
optional_conditions = NULL, | ||
type_field = 'text', | ||
type_field_params = NULL | ||
WHERE name_field = 'unique_dataset_id' | ||
""" | ||
) |
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