-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track and report system changes (#3990)
- Loading branch information
Showing
11 changed files
with
393 additions
and
21 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
63 changes: 63 additions & 0 deletions
63
src/fides/api/alembic/migrations/versions/093bb28a8270_add_plus_system_history_table.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,63 @@ | ||
"""Add plus_system_history table | ||
Revision ID: 093bb28a8270 | ||
Revises: 3038667ba898 | ||
Create Date: 2023-08-18 23:48:22.934916 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "093bb28a8270" | ||
down_revision = "3038667ba898" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"plus_system_history", | ||
sa.Column("id", sa.String(length=255), nullable=False), | ||
sa.Column( | ||
"created_at", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=True, | ||
), | ||
sa.Column( | ||
"updated_at", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=True, | ||
), | ||
sa.Column("user_id", sa.String(), nullable=True), | ||
sa.Column("system_id", sa.String(), nullable=False), | ||
sa.Column("before", postgresql.JSONB(astext_type=sa.Text()), nullable=False), | ||
sa.Column("after", postgresql.JSONB(astext_type=sa.Text()), nullable=False), | ||
sa.ForeignKeyConstraint(["system_id"], ["ctl_systems.id"], ondelete="CASCADE"), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_index( | ||
op.f("ix_plus_system_history_id"), "plus_system_history", ["id"], unique=False | ||
) | ||
op.create_index( | ||
"idx_plus_system_history_created_at_system_id", | ||
"plus_system_history", | ||
["created_at", "system_id"], | ||
) | ||
op.add_column( | ||
"ctl_systems", | ||
sa.Column("user_id", sa.String, nullable=True), | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_column("ctl_systems", "user_id") | ||
op.drop_index( | ||
op.f("idx_plus_system_history_created_at_system_id"), | ||
table_name="plus_system_history", | ||
) | ||
op.drop_index(op.f("ix_plus_system_history_id"), table_name="plus_system_history") | ||
op.drop_table("plus_system_history") |
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
Oops, something went wrong.