-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change API to be able to assign roles to namespaces
Fixes #491.
- Loading branch information
Nikita Karetnikov
committed
Oct 19, 2023
1 parent
91d2cb4
commit 9ac936b
Showing
8 changed files
with
648 additions
and
180 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...rver/conda_store_server/alembic/versions/46bdf428642d_change_namespacerolemapping_and_.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,56 @@ | ||
"""Change NamespaceRoleMapping and Namespace | ||
Revision ID: 46bdf428642d | ||
Revises: b387747ca9b7 | ||
Create Date: 2023-10-08 10:40:06.227854 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "46bdf428642d" | ||
down_revision = "b387747ca9b7" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"namespace_role_mapping_new", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("namespace_id", sa.Integer(), nullable=False), | ||
sa.Column("other_namespace_id", sa.Integer(), nullable=False), | ||
sa.Column("role", sa.Unicode(length=255), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["namespace_id"], | ||
["namespace.id"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["other_namespace_id"], | ||
["namespace.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("namespace_id", "other_namespace_id", name="_uc"), | ||
) | ||
# Note: data is NOT copied before dropping the old table | ||
op.drop_table("namespace_role_mapping") | ||
op.rename_table("namespace_role_mapping_new", "namespace_role_mapping") | ||
|
||
|
||
def downgrade(): | ||
op.create_table( | ||
"namespace_role_mapping_new", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("namespace_id", sa.Integer(), nullable=False), | ||
sa.Column("entity", sa.Unicode(length=255), nullable=False), | ||
sa.Column("role", sa.Unicode(length=255), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["namespace_id"], | ||
["namespace.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
# Note: data is NOT copied before dropping the old table | ||
op.drop_table("namespace_role_mapping") | ||
op.rename_table("namespace_role_mapping_new", "namespace_role_mapping") |
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.