-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1974 add default storage used by all dsr policies by default (#2438)
Co-authored-by: Paul Sanders <pau@ethyca.com>
- Loading branch information
Showing
34 changed files
with
2,271 additions
and
220 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
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
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
55 changes: 55 additions & 0 deletions
55
src/fides/api/ctl/migrations/versions/5d62bab40b71_add_application_config_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,55 @@ | ||
"""add application config table | ||
Revision ID: 5d62bab40b71 | ||
Revises: 7fd4601ef88b | ||
Create Date: 2023-01-27 22:56:33.367379 | ||
""" | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "5d62bab40b71" | ||
down_revision = "7fd4601ef88b" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"applicationconfig", | ||
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( | ||
"api_set", | ||
sqlalchemy_utils.types.encrypted.encrypted_type.StringEncryptedType(), | ||
nullable=True, | ||
), | ||
sa.Column("single_row", sa.Boolean(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.CheckConstraint("single_row", name="single_row_check"), | ||
) | ||
op.create_index( | ||
op.f("ix_applicationconfig_id"), "applicationconfig", ["id"], unique=False | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f("ix_applicationconfig_id"), table_name="applicationconfig") | ||
op.drop_table("applicationconfig") | ||
# ### end Alembic commands ### |
65 changes: 65 additions & 0 deletions
65
...fides/api/ctl/migrations/versions/7fd4601ef88b_add_is_default_column_to_storage_config.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 @@ | ||
"""add is_default column to storage config | ||
Revision ID: 7fd4601ef88b | ||
Revises: d6c6c6555c86 | ||
Create Date: 2023-01-26 14:13:22.538719 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy import text | ||
from sqlalchemy.sql.elements import TextClause | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "7fd4601ef88b" | ||
down_revision = "392992c7733a" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# schema migration - add a nullable storageconfig.is_default field. We will shortly make it non-nullable | ||
op.add_column("storageconfig", sa.Column("is_default", sa.Boolean(), nullable=True)) | ||
op.create_index( | ||
op.f("ix_storageconfig_is_default"), | ||
"storageconfig", | ||
["is_default"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
"only_one_default_per_type", | ||
"storageconfig", | ||
["type", "is_default"], | ||
unique=True, | ||
postgresql_where=sa.text("is_default"), | ||
) | ||
|
||
# Data migration - automatically populate storageconfig.is_default column | ||
bind = op.get_bind() | ||
existing_storageconfigs: TextClause = bind.execute( | ||
text("SELECT id FROM storageconfig;") | ||
) | ||
for row in existing_storageconfigs: | ||
update_storage_config_query: TextClause = text( | ||
"UPDATE storageconfig SET is_default = false WHERE id= :storageconfig_id" | ||
) | ||
bind.execute(update_storage_config_query, {"storageconfig_id": row["id"]}) | ||
|
||
# now follow up to make it not nullable | ||
op.alter_column( | ||
"storageconfig", "is_default", existing_type=sa.Boolean(), nullable=False | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index( | ||
"only_one_default_per_type", | ||
table_name="storageconfig", | ||
postgresql_where=sa.text("is_default"), | ||
) | ||
op.drop_index(op.f("ix_storageconfig_is_default"), table_name="storageconfig") | ||
op.drop_column("storageconfig", "is_default") | ||
# ### end Alembic commands ### |
Oops, something went wrong.