Skip to content

Commit

Permalink
db downgrade does not work with data
Browse files Browse the repository at this point in the history
  • Loading branch information
joelclems committed Dec 8, 2023
1 parent 2ed9184 commit b08ab1d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,4 @@ def upgrade():


def downgrade():
op.execute(
"""
UPDATE gn_commons.t_modules AS tm SET type=NULL
FROM gn_monitoring.t_module_complements AS tmc
WHERE tm.id_module = tmc.id_module;
"""
)
pass
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ def downgrade():
op.drop_table("t_visit_complements", schema=monitorings_schema)

# Remove all GNM related objects

op.execute(
"""
DELETE FROM
gn_permissions.t_permissions p
USING gn_permissions.t_objects o
WHERE
p.id_object = o.id_object
AND o.code_object like 'GNM_%'
;
"""
)

op.execute(
"""
DELETE FROM
gn_permissions.t_permissions_available p
USING gn_permissions.t_objects o
WHERE
p.id_object = o.id_object
AND o.code_object like 'GNM_%'
;
"""
)

statement = sa.delete(TObjects).where(TObjects.code_object.like("GNM_%"))
op.execute(statement)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ def downgrade():
"""
)
op.execute(statement)

statement = sa.text(
f"""
DELETE FROM gn_monitoring.t_site_complements WHERE id_module IS NULL;
"""
)
op.execute(statement)

op.alter_column("t_site_complements", "id_module", nullable=False, schema=monitorings_schema)
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ def downgrade():
"""
)

op.execute(
"""
DELETE FROM
gn_permissions.t_permissions p
USING gn_permissions.t_objects o
WHERE
p.id_object = o.id_object
AND o.code_object = 'TYPES_SITES'
;
"""
)

op.execute(
"""
DELETE FROM
Expand Down

0 comments on commit b08ab1d

Please sign in to comment.