-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add access control over metrics (#584)
* Add the new field "is_restricted" to SqlMetric and DruidMetric * Add the access control on metrics * Add the more descriptions on is_restricted * Update docs/security.rst * Update docs/security.rst
- Loading branch information
1 parent
55baab4
commit 4c6026f
Showing
5 changed files
with
155 additions
and
12 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
caravel/migrations/versions/d8bc074f7aad_add_new_field_is_restricted_to_.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 @@ | ||
"""Add new field 'is_restricted' to SqlMetric and DruidMetric | ||
Revision ID: d8bc074f7aad | ||
Revises: 1226819ee0e3 | ||
Create Date: 2016-06-07 12:33:25.756640 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'd8bc074f7aad' | ||
down_revision = '1226819ee0e3' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from caravel import db | ||
from caravel import models | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table('metrics', schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column('is_restricted', sa.Boolean(), nullable=True)) | ||
|
||
with op.batch_alter_table('sql_metrics', schema=None) as batch_op: | ||
batch_op.add_column( | ||
sa.Column('is_restricted', sa.Boolean(), nullable=True)) | ||
|
||
bind = op.get_bind() | ||
session = db.Session(bind=bind) | ||
|
||
session.query(models.DruidMetric).update({ | ||
'is_restricted': False | ||
}) | ||
session.query(models.SqlMetric).update({ | ||
'is_restricted': False | ||
}) | ||
|
||
session.commit() | ||
session.close() | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table('sql_metrics', schema=None) as batch_op: | ||
batch_op.drop_column('is_restricted') | ||
|
||
with op.batch_alter_table('metrics', schema=None) as batch_op: | ||
batch_op.drop_column('is_restricted') |
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