forked from conda-incubator/conda-store
-
Notifications
You must be signed in to change notification settings - Fork 0
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 conda-incubator#491.
- Loading branch information
Nikita Karetnikov
committed
Oct 15, 2023
1 parent
64552a2
commit e96a709
Showing
7 changed files
with
553 additions
and
158 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...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,47 @@ | ||
"""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', 'role', 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.