Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA-450 prereq: add user assigned data_uses and system_id properties to StagedResource #5841

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions .fides/db_dataset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,10 @@ dataset:
data_categories: [system]
- name: user_assigned_data_categories
data_categories: [system]
- name: user_assigned_data_uses
data_categories: [system]
- name: user_assigned_system_id
data_categories: [system]
- name: data_uses
data_categories: [system]
- name: system_id
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Changes can also be flagged with a GitHub label for tracking purposes. The URL o
- Added UI for configuring website integrations and monitors [#5867](https://github.com/ethyca/fides/pull/5867)

### Changed
- Add properties for user assigned systems/data_uses on staged resources [5841](https://github.com/ethyca/fides/pull/5841) https://github.com/ethyca/fides/labels/db-migration
- Bumped supported Python versions to `3.10.16` and `3.9.21` [#5840](https://github.com/ethyca/fides/pull/5840)
- Update the privacy request detail page to a new layout and improved styling [#5824](https://github.com/ethyca/fides/pull/5824)
- Updated privacy request handling to still succeed if not all identities are provided [#5836](https://github.com/ethyca/fides/pull/5836)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""add user assigned data_uses and system_id columns to stagedresource

Revision ID: 7c3fbee90c78
Revises: 69ad6d844e21
Create Date: 2025-03-04 15:00:23.874270

"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "7c3fbee90c78"
down_revision = "69ad6d844e21"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"stagedresource",
sa.Column(
"user_assigned_system_id", sa.VARCHAR(), autoincrement=False, nullable=True
),
)
op.add_column(
"stagedresource",
sa.Column(
"user_assigned_data_uses",
postgresql.ARRAY(sa.VARCHAR()),
server_default=sa.text("'{}'::character varying[]"),
autoincrement=False,
nullable=False,
),
)
# ### end Alembic commands ###
op.create_index(
"ix_stagedresource_user_assigned_system_id",
"stagedresource",
["user_assigned_system_id"],
unique=False,
)


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("stagedresource", "user_assigned_data_uses")
op.drop_column("stagedresource", "user_assigned_system_id")
# ### end Alembic commands ###
op.drop_index(
"ix_stagedresource_user_assigned_system_id", table_name="stagedresource"
)
12 changes: 12 additions & 0 deletions src/fides/api/models/detection_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@ class StagedResource(Base):
server_default="{}",
default=dict,
)
user_assigned_data_uses = Column(
ARRAY(String),
nullable=False,
server_default="{}",
default=dict,
)
user_assigned_system_id = Column(
String,
ForeignKey(System.id_field_path),
nullable=True,
index=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want an index here? it could make sense, though not sure it's strictly necessary. i'm good keeping it, but if so, we need to make sure we actually create/remove the index in the migration upgrade/downgrade

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed the migration in a merge apparently; added here: b829ef4

)

# pointers to child and parent URNs
children = Column(
Expand Down