Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
d2141506
Commit
d2141506
authored
Oct 09, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DB] Alembic: add support for schemas and policies
parent
079257f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
8 deletions
+41
-8
alembic.py
gargantext/util/alembic.py
+41
-8
No files found.
gargantext/util/alembic.py
View file @
d2141506
...
...
@@ -84,8 +84,10 @@ class ReversibleOp(MigrateOperation):
CreateViewOp
,
DropViewOp
=
ReversibleOp
.
define
(
'view'
)
CreateRoleOp
,
DropRoleOp
=
ReversibleOp
.
define
(
'role'
)
CreateSchemaOp
,
DropSchemaOp
=
ReversibleOp
.
define
(
'schema'
)
CreateSPOp
,
DropSPOp
=
ReversibleOp
.
define
(
'sp'
,
'SP'
)
CreateTriggerOp
,
DropTriggerOp
=
ReversibleOp
.
define
(
'trigger'
)
CreatePolicyOp
,
DropPolicyOp
=
ReversibleOp
.
define
(
'policy'
)
@
Operations
.
implementation_for
(
CreateViewOp
)
...
...
@@ -101,6 +103,32 @@ def drop_view(operations, operation):
operations
.
execute
(
"DROP VIEW
%
s"
%
operation
.
target
.
name
)
@
Operations
.
implementation_for
(
CreateRoleOp
)
def
create_role
(
operations
,
operation
):
args
=
operation
.
target
.
args
operations
.
execute
(
"CREATE ROLE
%
s WITH
%
s"
%
(
operation
.
target
.
name
,
args
[
0
]
if
len
(
args
)
else
'NOLOGIN'
)
)
@
Operations
.
implementation_for
(
DropRoleOp
)
def
drop_role
(
operations
,
operation
):
operations
.
execute
(
"DROP ROLE
%
s"
%
operation
.
target
.
name
)
@
Operations
.
implementation_for
(
CreateSchemaOp
)
def
create_schema
(
operations
,
operation
):
operations
.
execute
(
"CREATE SCHEMA
%
s"
%
operation
.
target
.
name
)
@
Operations
.
implementation_for
(
DropSchemaOp
)
def
drop_schema
(
operations
,
operation
):
operations
.
execute
(
"DROP SCHEMA
%
s"
%
operation
.
target
.
name
)
@
Operations
.
implementation_for
(
CreateSPOp
)
def
create_sp
(
operations
,
operation
):
operations
.
execute
(
...
...
@@ -135,17 +163,22 @@ def drop_trigger(operations, operation):
)
@
Operations
.
implementation_for
(
CreateRoleOp
)
def
create_role
(
operations
,
operation
):
args
=
operation
.
target
.
args
@
Operations
.
implementation_for
(
CreatePolicyOp
)
def
create_policy
(
operations
,
operation
):
operations
.
execute
(
"CREATE
ROLE
%
s WITH
%
s"
%
(
"CREATE
POLICY
%
s ON
%
s
%
s"
%
(
operation
.
target
.
name
,
args
[
0
]
if
len
(
args
)
else
'NOLOGIN'
operation
.
target
.
args
[
0
],
operation
.
target
.
args
[
1
],
)
)
@
Operations
.
implementation_for
(
DropRoleOp
)
def
drop_role
(
operations
,
operation
):
operations
.
execute
(
"DROP ROLE
%
s"
%
operation
.
target
.
name
)
@
Operations
.
implementation_for
(
DropPolicyOp
)
def
drop_policy
(
operations
,
operation
):
operations
.
execute
(
"DROP POLICY
%
s ON
%
s"
%
(
operation
.
target
.
name
,
operation
.
target
.
args
[
0
],
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment