uboa 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uboa/__init__.py +0 -0
- uboa/common/__init__.py +1 -0
- uboa/common/commands.py +19 -0
- uboa/config/engine.json +7 -0
- uboa/config/uboa_datamodel.json +12 -0
- uboa/config/users.json +57 -0
- uboa/datamodel/__init__.py +0 -0
- uboa/datamodel/base.py +28 -0
- uboa/datamodel/errors.py +20 -0
- uboa/datamodel/functions.py +41 -0
- uboa/datamodel/uboa_data_model.dbm +277 -0
- uboa/datamodel/uboa_data_model.sql +185 -0
- uboa/datamodel/users.py +175 -0
- uboa/debugging.py +62 -0
- uboa/engine/__init__.py +0 -0
- uboa/engine/engine.py +637 -0
- uboa/engine/errors.py +98 -0
- uboa/engine/functions.py +97 -0
- uboa/engine/operators.py +36 -0
- uboa/engine/parsing.py +159 -0
- uboa/engine/printing.py +45 -0
- uboa/engine/query.py +457 -0
- uboa/logging.py +118 -0
- uboa/scripts/__init__.py +0 -0
- uboa/scripts/initialize_uboa_ddbb.sh +4 -0
- uboa/scripts/start_uboa.sh +3 -0
- uboa/scripts/uboa_init.py +110 -0
- uboa/scripts/uboa_init_ddbb.sh +79 -0
- uboa-0.1.0.data/scripts/initialize_uboa_ddbb.sh +4 -0
- uboa-0.1.0.data/scripts/start_uboa.sh +3 -0
- uboa-0.1.0.data/scripts/uboa_init.py +110 -0
- uboa-0.1.0.data/scripts/uboa_init_ddbb.sh +79 -0
- uboa-0.1.0.dist-info/METADATA +208 -0
- uboa-0.1.0.dist-info/RECORD +38 -0
- uboa-0.1.0.dist-info/WHEEL +5 -0
- uboa-0.1.0.dist-info/licenses/AUTHORS +6 -0
- uboa-0.1.0.dist-info/licenses/LICENSE +21 -0
- uboa-0.1.0.dist-info/top_level.txt +1 -0
uboa/__init__.py
ADDED
|
File without changes
|
uboa/common/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""UBOA command helpers."""
|
uboa/common/commands.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Runtime helpers for UBOA, part of the BOA suite.
|
|
2
|
+
|
|
3
|
+
Written by Daniel Brosnan Blázquez.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import shlex
|
|
7
|
+
from subprocess import Popen, PIPE
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def execute_command(command, success_message, check_error = True):
|
|
11
|
+
command_split = shlex.split(command)
|
|
12
|
+
program = Popen(command_split, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
|
13
|
+
output, error = program.communicate()
|
|
14
|
+
return_code = program.returncode
|
|
15
|
+
if check_error and return_code != 0:
|
|
16
|
+
print("The execution of the command {} has ended unexpectedly with the following output: {} but the following error: {}".format(command, str(output.decode()), str(error.decode())))
|
|
17
|
+
exit(-1)
|
|
18
|
+
else:
|
|
19
|
+
print(success_message)
|
uboa/config/engine.json
ADDED
uboa/config/users.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{"operations": [{
|
|
2
|
+
"mode": "insert",
|
|
3
|
+
"users": [
|
|
4
|
+
{
|
|
5
|
+
"email": "administrator@test.com",
|
|
6
|
+
"username": "administrator",
|
|
7
|
+
"password": "$2b$12$U9sVkIyZuER4eG0Kzfr2cOzHK7mNox5Qc8AtUrb6I4gHuIYiU4n56",
|
|
8
|
+
"roles": ["administrator"]
|
|
9
|
+
},{
|
|
10
|
+
"email": "service_administrator@test.com",
|
|
11
|
+
"username": "service_administrator",
|
|
12
|
+
"password": "$2b$12$U9sVkIyZuER4eG0Kzfr2cOzHK7mNox5Qc8AtUrb6I4gHuIYiU4n56",
|
|
13
|
+
"roles": ["service_administrator"]
|
|
14
|
+
},{
|
|
15
|
+
"email": "operator@test.com",
|
|
16
|
+
"username": "operator",
|
|
17
|
+
"password": "$2b$12$U9sVkIyZuER4eG0Kzfr2cOzHK7mNox5Qc8AtUrb6I4gHuIYiU4n56",
|
|
18
|
+
"roles": ["operator"]
|
|
19
|
+
},{
|
|
20
|
+
"email": "analyst@test.com",
|
|
21
|
+
"username": "analyst",
|
|
22
|
+
"password": "$2b$12$U9sVkIyZuER4eG0Kzfr2cOzHK7mNox5Qc8AtUrb6I4gHuIYiU4n56",
|
|
23
|
+
"roles": ["analyst"]
|
|
24
|
+
},{
|
|
25
|
+
"email": "operator_observer@test.com",
|
|
26
|
+
"username": "operator_observer",
|
|
27
|
+
"password": "$2b$12$U9sVkIyZuER4eG0Kzfr2cOzHK7mNox5Qc8AtUrb6I4gHuIYiU4n56",
|
|
28
|
+
"roles": ["operator_observer"]
|
|
29
|
+
},{
|
|
30
|
+
"email": "observer@test.com",
|
|
31
|
+
"username": "observer",
|
|
32
|
+
"password": "$2b$12$U9sVkIyZuER4eG0Kzfr2cOzHK7mNox5Qc8AtUrb6I4gHuIYiU4n56",
|
|
33
|
+
"roles": ["observer"]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"roles": [
|
|
37
|
+
{
|
|
38
|
+
"name": "administrator",
|
|
39
|
+
"description": "Administrator of the system. All operations allowed."
|
|
40
|
+
},{
|
|
41
|
+
"name": "service_administrator",
|
|
42
|
+
"description": "Administrator of the service. All operations allowed, except management of users."
|
|
43
|
+
},{
|
|
44
|
+
"name": "operator",
|
|
45
|
+
"description": "Operator of the service. All operations allowed, except management of users and management of services."
|
|
46
|
+
},{
|
|
47
|
+
"name": "analyst",
|
|
48
|
+
"description": "Analyst of the service. Read access to data (including EBOA navigation) and write access to include justifications."
|
|
49
|
+
},{
|
|
50
|
+
"name": "operator_observer",
|
|
51
|
+
"description": "Operator of the service. Read access to data (including EBOA navigation)."
|
|
52
|
+
},{
|
|
53
|
+
"name": "observer",
|
|
54
|
+
"description": "Read access to specfic views."
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}]}
|
|
File without changes
|
uboa/datamodel/base.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Connection configuration for the uboa component
|
|
3
|
+
|
|
4
|
+
Written by Daniel Brosnan Blázquez
|
|
5
|
+
|
|
6
|
+
module uboa
|
|
7
|
+
"""
|
|
8
|
+
# Import SQLalchemy entities
|
|
9
|
+
import os
|
|
10
|
+
from sqlalchemy import create_engine
|
|
11
|
+
from sqlalchemy.ext.declarative import declarative_base
|
|
12
|
+
from sqlalchemy.orm import sessionmaker, scoped_session
|
|
13
|
+
|
|
14
|
+
# Import auxiliary functions
|
|
15
|
+
from uboa.datamodel.functions import read_configuration
|
|
16
|
+
|
|
17
|
+
config = read_configuration()
|
|
18
|
+
|
|
19
|
+
db_configuration = config["DDBB_CONFIGURATION"]
|
|
20
|
+
|
|
21
|
+
db_uri = "{db_api}://{user}@{host}:{port}/{database}".format(**db_configuration)
|
|
22
|
+
|
|
23
|
+
engine = create_engine(db_uri, pool_size=db_configuration["pool_size"], max_overflow=db_configuration["max_overflow"])
|
|
24
|
+
Session = sessionmaker(bind=engine)
|
|
25
|
+
|
|
26
|
+
db_session = scoped_session(Session)
|
|
27
|
+
Base = declarative_base()
|
|
28
|
+
Base.query = db_session.query_property()
|
uboa/datamodel/errors.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Errors definition for the datamodel module
|
|
3
|
+
|
|
4
|
+
Written by Daniel Brosnan Blázquez
|
|
5
|
+
|
|
6
|
+
module uboa
|
|
7
|
+
"""
|
|
8
|
+
class Error(Exception):
|
|
9
|
+
"""Base class for exceptions in this module."""
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
class WrongParameter(Error):
|
|
13
|
+
"""Exception raised when the received parameter is not correct
|
|
14
|
+
|
|
15
|
+
Attributes:
|
|
16
|
+
message -- explanation of the error
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, message):
|
|
20
|
+
self.message = message
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Functions definition for the datamodel component
|
|
3
|
+
|
|
4
|
+
Written by Daniel Brosnan Blázquez
|
|
5
|
+
|
|
6
|
+
module uboa
|
|
7
|
+
"""
|
|
8
|
+
# Import python utilities
|
|
9
|
+
from importlib.resources import files
|
|
10
|
+
import os
|
|
11
|
+
import json
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class UboaResourcesPathNotAvailable(FileNotFoundError):
|
|
16
|
+
"""The configured UBOA resource directory is unavailable."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_resources_path():
|
|
20
|
+
"""Return UBOA_RESOURCES_PATH, defaulting to the bundled config directory."""
|
|
21
|
+
directory = os.environ.get("UBOA_RESOURCES_PATH", str(files("uboa").joinpath("config")))
|
|
22
|
+
if not os.path.isdir(directory):
|
|
23
|
+
raise UboaResourcesPathNotAvailable("The UBOA resources path {} is not available".format(directory))
|
|
24
|
+
return directory
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def config_path(filename):
|
|
28
|
+
return str(Path(get_resources_path()) / filename)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def read_configuration():
|
|
32
|
+
# Get configuration
|
|
33
|
+
with open(config_path("uboa_datamodel.json")) as json_data_file:
|
|
34
|
+
config = json.load(json_data_file)
|
|
35
|
+
# end with
|
|
36
|
+
|
|
37
|
+
if "UBOA_DDBB_HOST" in os.environ:
|
|
38
|
+
config["DDBB_CONFIGURATION"]["host"] = os.environ["UBOA_DDBB_HOST"]
|
|
39
|
+
# end if
|
|
40
|
+
|
|
41
|
+
return config
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
CAUTION: Do not modify this file unless you know what you are doing.
|
|
4
|
+
Unexpected results may occur if the code is changed deliberately.
|
|
5
|
+
-->
|
|
6
|
+
<dbmodel pgmodeler-ver="1.2.3" use-changelog="false" max-obj-count="8"
|
|
7
|
+
gen-disabled-objs-code="false" show-sys-schemas-rects="true"
|
|
8
|
+
last-position="0,0" last-zoom="1"
|
|
9
|
+
default-owner="postgres"
|
|
10
|
+
layers="Default,"
|
|
11
|
+
active-layers=""
|
|
12
|
+
layer-name-colors="#000000"
|
|
13
|
+
layer-rect-colors="#b4b4b4"
|
|
14
|
+
show-layer-names="false" show-layer-rects="false">
|
|
15
|
+
<role name="uboa"
|
|
16
|
+
inherit="true"
|
|
17
|
+
login="true">
|
|
18
|
+
</role>
|
|
19
|
+
|
|
20
|
+
<database name="uboadb" is-template="false" allow-conns="true">
|
|
21
|
+
</database>
|
|
22
|
+
|
|
23
|
+
<schema name="public" layers="0" fill-color="#e1e1e1" name-color="#000000" sql-disabled="true">
|
|
24
|
+
</schema>
|
|
25
|
+
|
|
26
|
+
<schema name="uboa" layers="0" fill-color="#e1e1e1" name-color="#000000">
|
|
27
|
+
<role name="uboa"/>
|
|
28
|
+
</schema>
|
|
29
|
+
|
|
30
|
+
<table name="users" layers="0" collapse-mode="2" max-obj-count="15" z-value="0">
|
|
31
|
+
<schema name="uboa"/>
|
|
32
|
+
<role name="uboa"/>
|
|
33
|
+
<position x="520" y="100"/>
|
|
34
|
+
<column name="user_uuid" not-null="true">
|
|
35
|
+
<type name="uuid" length="0"/>
|
|
36
|
+
</column>
|
|
37
|
+
<column name="email" not-null="true">
|
|
38
|
+
<type name="text" length="0"/>
|
|
39
|
+
</column>
|
|
40
|
+
<column name="username" not-null="true">
|
|
41
|
+
<type name="text" length="0"/>
|
|
42
|
+
</column>
|
|
43
|
+
<column name="group" not-null="true">
|
|
44
|
+
<type name="text" length="0"/>
|
|
45
|
+
</column>
|
|
46
|
+
<column name="password" not-null="true">
|
|
47
|
+
<type name="text" length="0"/>
|
|
48
|
+
</column>
|
|
49
|
+
<column name="last_login_at">
|
|
50
|
+
<type name="timestamp" length="0"/>
|
|
51
|
+
</column>
|
|
52
|
+
<column name="current_login_at">
|
|
53
|
+
<type name="timestamp" length="0"/>
|
|
54
|
+
</column>
|
|
55
|
+
<column name="last_login_ip">
|
|
56
|
+
<type name="text" length="0"/>
|
|
57
|
+
</column>
|
|
58
|
+
<column name="current_login_ip">
|
|
59
|
+
<type name="text" length="0"/>
|
|
60
|
+
</column>
|
|
61
|
+
<column name="login_count">
|
|
62
|
+
<type name="integer" length="0"/>
|
|
63
|
+
</column>
|
|
64
|
+
<column name="active" not-null="true">
|
|
65
|
+
<type name="bool" length="0"/>
|
|
66
|
+
</column>
|
|
67
|
+
<column name="fs_uniquifier" not-null="true">
|
|
68
|
+
<type name="text" length="0"/>
|
|
69
|
+
</column>
|
|
70
|
+
<column name="confirmed_at">
|
|
71
|
+
<type name="timestamp" length="0"/>
|
|
72
|
+
</column>
|
|
73
|
+
<constraint name="users_pk" type="pk-constr" table="uboa.users">
|
|
74
|
+
<columns names="user_uuid" ref-type="src-columns"/>
|
|
75
|
+
</constraint>
|
|
76
|
+
<constraint name="unique_fs_uniquifier" type="uq-constr" table="uboa.users">
|
|
77
|
+
<columns names="fs_uniquifier" ref-type="src-columns"/>
|
|
78
|
+
</constraint>
|
|
79
|
+
<constraint name="unique_username" type="uq-constr" table="uboa.users">
|
|
80
|
+
<columns names="username" ref-type="src-columns"/>
|
|
81
|
+
</constraint>
|
|
82
|
+
<constraint name="unique_email" type="uq-constr" table="uboa.users">
|
|
83
|
+
<columns names="email" ref-type="src-columns"/>
|
|
84
|
+
</constraint>
|
|
85
|
+
</table>
|
|
86
|
+
|
|
87
|
+
<table name="roles" layers="0" collapse-mode="2" max-obj-count="3" z-value="0">
|
|
88
|
+
<schema name="uboa"/>
|
|
89
|
+
<role name="uboa"/>
|
|
90
|
+
<position x="900" y="240"/>
|
|
91
|
+
<column name="role_uuid" not-null="true">
|
|
92
|
+
<type name="uuid" length="0"/>
|
|
93
|
+
</column>
|
|
94
|
+
<column name="name" not-null="true">
|
|
95
|
+
<type name="text" length="0"/>
|
|
96
|
+
</column>
|
|
97
|
+
<column name="description">
|
|
98
|
+
<type name="text" length="0"/>
|
|
99
|
+
</column>
|
|
100
|
+
<constraint name="unique_role" type="uq-constr" table="uboa.roles">
|
|
101
|
+
<columns names="name" ref-type="src-columns"/>
|
|
102
|
+
</constraint>
|
|
103
|
+
<constraint name="roles_pk" type="pk-constr" table="uboa.roles">
|
|
104
|
+
<columns names="role_uuid" ref-type="src-columns"/>
|
|
105
|
+
</constraint>
|
|
106
|
+
</table>
|
|
107
|
+
|
|
108
|
+
<table name="roles_users" layers="0" collapse-mode="2" max-obj-count="3" z-value="0">
|
|
109
|
+
<schema name="uboa"/>
|
|
110
|
+
<role name="uboa"/>
|
|
111
|
+
<position x="880" y="100"/>
|
|
112
|
+
<column name="role_user_uuid" not-null="true">
|
|
113
|
+
<type name="uuid" length="0"/>
|
|
114
|
+
</column>
|
|
115
|
+
<constraint name="roles_users_pk" type="pk-constr" table="uboa.roles_users">
|
|
116
|
+
<columns names="role_user_uuid" ref-type="src-columns"/>
|
|
117
|
+
</constraint>
|
|
118
|
+
</table>
|
|
119
|
+
|
|
120
|
+
<table name="configurations" layers="0" collapse-mode="2" max-obj-count="8" z-value="0">
|
|
121
|
+
<schema name="uboa"/>
|
|
122
|
+
<role name="uboa"/>
|
|
123
|
+
<position x="920" y="540"/>
|
|
124
|
+
<column name="configuration_uuid" not-null="true">
|
|
125
|
+
<type name="uuid" length="0"/>
|
|
126
|
+
</column>
|
|
127
|
+
<column name="name" not-null="true">
|
|
128
|
+
<type name="text" length="0"/>
|
|
129
|
+
</column>
|
|
130
|
+
<column name="configuration" not-null="true">
|
|
131
|
+
<type name="json" length="0"/>
|
|
132
|
+
</column>
|
|
133
|
+
<column name="permission" not-null="true">
|
|
134
|
+
<type name="integer" length="0"/>
|
|
135
|
+
</column>
|
|
136
|
+
<column name="diff_previous_version">
|
|
137
|
+
<type name="text" length="0"/>
|
|
138
|
+
</column>
|
|
139
|
+
<column name="active" not-null="true">
|
|
140
|
+
<type name="boolean" length="0"/>
|
|
141
|
+
</column>
|
|
142
|
+
<constraint name="configurations_pk" type="pk-constr" table="uboa.configurations">
|
|
143
|
+
<columns names="configuration_uuid" ref-type="src-columns"/>
|
|
144
|
+
</constraint>
|
|
145
|
+
|
|
146
|
+
<customidxs object-type="column">
|
|
147
|
+
<object name="user_uuid" index="6"/>
|
|
148
|
+
</customidxs>
|
|
149
|
+
<customidxs object-type="constraint">
|
|
150
|
+
<object name="users_fk" index="2"/>
|
|
151
|
+
</customidxs></table>
|
|
152
|
+
|
|
153
|
+
<relationship name="roles_has_many_roles_users" type="rel1n" layers="0"
|
|
154
|
+
src-col-pattern="{sc}"
|
|
155
|
+
pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
|
|
156
|
+
src-fk-pattern="{st}_fk"
|
|
157
|
+
fk-idx-pattern="{st}_idx"
|
|
158
|
+
custom-color="#4830d1"
|
|
159
|
+
src-table="uboa.roles"
|
|
160
|
+
dst-table="uboa.roles_users"
|
|
161
|
+
src-required="true" dst-required="false"
|
|
162
|
+
del-action="CASCADE"/>
|
|
163
|
+
|
|
164
|
+
<relationship name="users_has_many_roles_users" type="rel1n" layers="0"
|
|
165
|
+
src-col-pattern="{sc}"
|
|
166
|
+
pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
|
|
167
|
+
src-fk-pattern="{st}_fk"
|
|
168
|
+
fk-idx-pattern="{st}_idx"
|
|
169
|
+
custom-color="#684e2f"
|
|
170
|
+
src-table="uboa.users"
|
|
171
|
+
dst-table="uboa.roles_users"
|
|
172
|
+
src-required="true" dst-required="false"
|
|
173
|
+
del-action="CASCADE"/>
|
|
174
|
+
|
|
175
|
+
<table name="configurations_users" layers="0" collapse-mode="2" max-obj-count="3" z-value="0">
|
|
176
|
+
<schema name="uboa"/>
|
|
177
|
+
<role name="uboa"/>
|
|
178
|
+
<position x="840" y="400"/>
|
|
179
|
+
<column name="configuration_user_uuid" not-null="true">
|
|
180
|
+
<type name="uuid" length="0"/>
|
|
181
|
+
</column>
|
|
182
|
+
<constraint name="configurations_users_pk" type="pk-constr" table="uboa.configurations_users">
|
|
183
|
+
<columns names="configuration_user_uuid" ref-type="src-columns"/>
|
|
184
|
+
</constraint>
|
|
185
|
+
|
|
186
|
+
<customidxs object-type="column">
|
|
187
|
+
<object name="configuration_uuid" index="2"/>
|
|
188
|
+
<object name="user_uuid" index="1"/>
|
|
189
|
+
</customidxs>
|
|
190
|
+
<customidxs object-type="constraint">
|
|
191
|
+
<object name="configurations_fk" index="1"/>
|
|
192
|
+
<object name="users_fk" index="0"/>
|
|
193
|
+
</customidxs></table>
|
|
194
|
+
|
|
195
|
+
<relationship name="users_has_many_configurations_users" type="rel1n" layers="0"
|
|
196
|
+
src-col-pattern="{sc}"
|
|
197
|
+
pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
|
|
198
|
+
src-fk-pattern="{st}_fk"
|
|
199
|
+
fk-idx-pattern="{st}_idx"
|
|
200
|
+
custom-color="#88ed48"
|
|
201
|
+
src-table="uboa.users"
|
|
202
|
+
dst-table="uboa.configurations_users"
|
|
203
|
+
src-required="true" dst-required="false"
|
|
204
|
+
del-action="CASCADE"/>
|
|
205
|
+
|
|
206
|
+
<relationship name="configurations_has_many_configurations_users" type="rel1n" layers="0"
|
|
207
|
+
src-col-pattern="{sc}"
|
|
208
|
+
pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
|
|
209
|
+
src-fk-pattern="{st}_fk"
|
|
210
|
+
fk-idx-pattern="{st}_idx"
|
|
211
|
+
custom-color="#1f978a"
|
|
212
|
+
src-table="uboa.configurations"
|
|
213
|
+
dst-table="uboa.configurations_users"
|
|
214
|
+
src-required="true" dst-required="false"
|
|
215
|
+
del-action="CASCADE"/>
|
|
216
|
+
|
|
217
|
+
<table name="configuration_changes" layers="0" collapse-mode="2" max-obj-count="6" z-value="0">
|
|
218
|
+
<schema name="uboa"/>
|
|
219
|
+
<role name="uboa"/>
|
|
220
|
+
<position x="500" y="540"/>
|
|
221
|
+
<column name="configuration_change_uuid" not-null="true">
|
|
222
|
+
<type name="uuid" length="0"/>
|
|
223
|
+
</column>
|
|
224
|
+
<column name="timestamp" not-null="true">
|
|
225
|
+
<type name="timestamp" length="0"/>
|
|
226
|
+
</column>
|
|
227
|
+
<column name="type" not-null="true">
|
|
228
|
+
<type name="integer" length="0"/>
|
|
229
|
+
</column>
|
|
230
|
+
<constraint name="configuration_changes_pk" type="pk-constr" table="uboa.configuration_changes">
|
|
231
|
+
<columns names="configuration_change_uuid" ref-type="src-columns"/>
|
|
232
|
+
</constraint>
|
|
233
|
+
|
|
234
|
+
<customidxs object-type="column">
|
|
235
|
+
<object name="configuration_uuid" index="3"/>
|
|
236
|
+
</customidxs>
|
|
237
|
+
<customidxs object-type="constraint">
|
|
238
|
+
<object name="configurations_fk" index="0"/>
|
|
239
|
+
</customidxs></table>
|
|
240
|
+
|
|
241
|
+
<relationship name="configurations_has_many_configuration_changes" type="rel1n" layers="0"
|
|
242
|
+
src-col-pattern="{sc}"
|
|
243
|
+
pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
|
|
244
|
+
src-fk-pattern="{st}_fk"
|
|
245
|
+
fk-idx-pattern="{st}_idx"
|
|
246
|
+
custom-color="#125bfa"
|
|
247
|
+
src-table="uboa.configurations"
|
|
248
|
+
dst-table="uboa.configuration_changes"
|
|
249
|
+
src-required="true" dst-required="false"
|
|
250
|
+
del-action="CASCADE"/>
|
|
251
|
+
|
|
252
|
+
<relationship name="users_has_many_configuration_changes" type="rel1n" layers="0"
|
|
253
|
+
src-col-pattern="{sc}"
|
|
254
|
+
pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
|
|
255
|
+
src-fk-pattern="{st}_fk"
|
|
256
|
+
fk-idx-pattern="{st}_idx"
|
|
257
|
+
custom-color="#f98553"
|
|
258
|
+
src-table="uboa.users"
|
|
259
|
+
dst-table="uboa.configuration_changes"
|
|
260
|
+
src-required="true" dst-required="false"
|
|
261
|
+
del-action="CASCADE"/>
|
|
262
|
+
|
|
263
|
+
<relationship name="users_creates_many_configurations" type="rel1n" layers="0"
|
|
264
|
+
src-col-pattern="{sc}"
|
|
265
|
+
pk-pattern="{dt}_pk" uq-pattern="{dt}_uq"
|
|
266
|
+
src-fk-pattern="{st}_fk"
|
|
267
|
+
fk-idx-pattern="{st}_idx"
|
|
268
|
+
custom-color="#7ce9c2"
|
|
269
|
+
src-table="uboa.users"
|
|
270
|
+
dst-table="uboa.configurations"
|
|
271
|
+
src-required="true" dst-required="false"/>
|
|
272
|
+
|
|
273
|
+
<constraint name="unique_configuration" type="uq-constr" table="uboa.configurations">
|
|
274
|
+
<columns names="name,user_uuid" ref-type="src-columns"/>
|
|
275
|
+
</constraint>
|
|
276
|
+
|
|
277
|
+
</dbmodel>
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
-- Database generated with pgModeler (PostgreSQL Database Modeler).
|
|
2
|
+
-- pgModeler version: 0.9.3
|
|
3
|
+
-- PostgreSQL version: 11.0
|
|
4
|
+
-- Project Site: pgmodeler.io
|
|
5
|
+
-- Model Author: John Bradley Valdenebro
|
|
6
|
+
-- object: uboa | type: ROLE --
|
|
7
|
+
-- DROP ROLE IF EXISTS uboa;
|
|
8
|
+
CREATE ROLE uboa WITH
|
|
9
|
+
INHERIT
|
|
10
|
+
LOGIN;
|
|
11
|
+
-- ddl-end --
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
-- Database creation must be performed outside a multi lined SQL file.
|
|
15
|
+
-- These commands were put in this file only as a convenience.
|
|
16
|
+
--
|
|
17
|
+
-- object: uboadb | type: DATABASE --
|
|
18
|
+
-- DROP DATABASE IF EXISTS uboadb;
|
|
19
|
+
CREATE DATABASE uboadb;
|
|
20
|
+
-- ddl-end --
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
-- object: uboa | type: SCHEMA --
|
|
24
|
+
-- DROP SCHEMA IF EXISTS uboa CASCADE;
|
|
25
|
+
CREATE SCHEMA uboa;
|
|
26
|
+
-- ddl-end --
|
|
27
|
+
ALTER SCHEMA uboa OWNER TO uboa;
|
|
28
|
+
-- ddl-end --
|
|
29
|
+
|
|
30
|
+
SET search_path TO pg_catalog,public,uboa;
|
|
31
|
+
-- ddl-end --
|
|
32
|
+
|
|
33
|
+
-- object: uboa.users | type: TABLE --
|
|
34
|
+
-- DROP TABLE IF EXISTS uboa.users CASCADE;
|
|
35
|
+
CREATE TABLE uboa.users (
|
|
36
|
+
user_uuid uuid NOT NULL,
|
|
37
|
+
email text NOT NULL,
|
|
38
|
+
username text NOT NULL,
|
|
39
|
+
"group" text NOT NULL,
|
|
40
|
+
password text NOT NULL,
|
|
41
|
+
last_login_at timestamp,
|
|
42
|
+
current_login_at timestamp,
|
|
43
|
+
last_login_ip text,
|
|
44
|
+
current_login_ip text,
|
|
45
|
+
login_count integer,
|
|
46
|
+
active bool NOT NULL,
|
|
47
|
+
fs_uniquifier text NOT NULL,
|
|
48
|
+
confirmed_at timestamp,
|
|
49
|
+
CONSTRAINT users_pk PRIMARY KEY (user_uuid),
|
|
50
|
+
CONSTRAINT unique_fs_uniquifier UNIQUE (fs_uniquifier),
|
|
51
|
+
CONSTRAINT unique_username UNIQUE (username),
|
|
52
|
+
CONSTRAINT unique_email UNIQUE (email)
|
|
53
|
+
|
|
54
|
+
);
|
|
55
|
+
-- ddl-end --
|
|
56
|
+
ALTER TABLE uboa.users OWNER TO uboa;
|
|
57
|
+
-- ddl-end --
|
|
58
|
+
|
|
59
|
+
-- object: uboa.roles | type: TABLE --
|
|
60
|
+
-- DROP TABLE IF EXISTS uboa.roles CASCADE;
|
|
61
|
+
CREATE TABLE uboa.roles (
|
|
62
|
+
role_uuid uuid NOT NULL,
|
|
63
|
+
name text NOT NULL,
|
|
64
|
+
description text,
|
|
65
|
+
CONSTRAINT unique_role UNIQUE (name),
|
|
66
|
+
CONSTRAINT roles_pk PRIMARY KEY (role_uuid)
|
|
67
|
+
|
|
68
|
+
);
|
|
69
|
+
-- ddl-end --
|
|
70
|
+
ALTER TABLE uboa.roles OWNER TO uboa;
|
|
71
|
+
-- ddl-end --
|
|
72
|
+
|
|
73
|
+
-- object: uboa.roles_users | type: TABLE --
|
|
74
|
+
-- DROP TABLE IF EXISTS uboa.roles_users CASCADE;
|
|
75
|
+
CREATE TABLE uboa.roles_users (
|
|
76
|
+
role_user_uuid uuid NOT NULL,
|
|
77
|
+
role_uuid uuid NOT NULL,
|
|
78
|
+
user_uuid uuid NOT NULL,
|
|
79
|
+
CONSTRAINT roles_users_pk PRIMARY KEY (role_user_uuid)
|
|
80
|
+
|
|
81
|
+
);
|
|
82
|
+
-- ddl-end --
|
|
83
|
+
ALTER TABLE uboa.roles_users OWNER TO uboa;
|
|
84
|
+
-- ddl-end --
|
|
85
|
+
|
|
86
|
+
-- object: uboa.configurations | type: TABLE --
|
|
87
|
+
-- DROP TABLE IF EXISTS uboa.configurations CASCADE;
|
|
88
|
+
CREATE TABLE uboa.configurations (
|
|
89
|
+
configuration_uuid uuid NOT NULL,
|
|
90
|
+
name text NOT NULL,
|
|
91
|
+
configuration json NOT NULL,
|
|
92
|
+
permission integer NOT NULL,
|
|
93
|
+
diff_previous_version text,
|
|
94
|
+
active boolean NOT NULL,
|
|
95
|
+
user_uuid uuid NOT NULL,
|
|
96
|
+
CONSTRAINT configurations_pk PRIMARY KEY (configuration_uuid)
|
|
97
|
+
|
|
98
|
+
);
|
|
99
|
+
-- ddl-end --
|
|
100
|
+
ALTER TABLE uboa.configurations OWNER TO uboa;
|
|
101
|
+
-- ddl-end --
|
|
102
|
+
|
|
103
|
+
-- object: roles_fk | type: CONSTRAINT --
|
|
104
|
+
-- ALTER TABLE uboa.roles_users DROP CONSTRAINT IF EXISTS roles_fk CASCADE;
|
|
105
|
+
ALTER TABLE uboa.roles_users ADD CONSTRAINT roles_fk FOREIGN KEY (role_uuid)
|
|
106
|
+
REFERENCES uboa.roles (role_uuid) MATCH FULL
|
|
107
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
108
|
+
-- ddl-end --
|
|
109
|
+
|
|
110
|
+
-- object: users_fk | type: CONSTRAINT --
|
|
111
|
+
-- ALTER TABLE uboa.roles_users DROP CONSTRAINT IF EXISTS users_fk CASCADE;
|
|
112
|
+
ALTER TABLE uboa.roles_users ADD CONSTRAINT users_fk FOREIGN KEY (user_uuid)
|
|
113
|
+
REFERENCES uboa.users (user_uuid) MATCH FULL
|
|
114
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
115
|
+
-- ddl-end --
|
|
116
|
+
|
|
117
|
+
-- object: uboa.configurations_users | type: TABLE --
|
|
118
|
+
-- DROP TABLE IF EXISTS uboa.configurations_users CASCADE;
|
|
119
|
+
CREATE TABLE uboa.configurations_users (
|
|
120
|
+
configuration_user_uuid uuid NOT NULL,
|
|
121
|
+
user_uuid uuid NOT NULL,
|
|
122
|
+
configuration_uuid uuid NOT NULL,
|
|
123
|
+
CONSTRAINT configurations_users_pk PRIMARY KEY (configuration_user_uuid)
|
|
124
|
+
|
|
125
|
+
);
|
|
126
|
+
-- ddl-end --
|
|
127
|
+
ALTER TABLE uboa.configurations_users OWNER TO uboa;
|
|
128
|
+
-- ddl-end --
|
|
129
|
+
|
|
130
|
+
-- object: users_fk | type: CONSTRAINT --
|
|
131
|
+
-- ALTER TABLE uboa.configurations_users DROP CONSTRAINT IF EXISTS users_fk CASCADE;
|
|
132
|
+
ALTER TABLE uboa.configurations_users ADD CONSTRAINT users_fk FOREIGN KEY (user_uuid)
|
|
133
|
+
REFERENCES uboa.users (user_uuid) MATCH FULL
|
|
134
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
135
|
+
-- ddl-end --
|
|
136
|
+
|
|
137
|
+
-- object: configurations_fk | type: CONSTRAINT --
|
|
138
|
+
-- ALTER TABLE uboa.configurations_users DROP CONSTRAINT IF EXISTS configurations_fk CASCADE;
|
|
139
|
+
ALTER TABLE uboa.configurations_users ADD CONSTRAINT configurations_fk FOREIGN KEY (configuration_uuid)
|
|
140
|
+
REFERENCES uboa.configurations (configuration_uuid) MATCH FULL
|
|
141
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
142
|
+
-- ddl-end --
|
|
143
|
+
|
|
144
|
+
-- object: uboa.configuration_changes | type: TABLE --
|
|
145
|
+
-- DROP TABLE IF EXISTS uboa.configuration_changes CASCADE;
|
|
146
|
+
CREATE TABLE uboa.configuration_changes (
|
|
147
|
+
configuration_change_uuid uuid NOT NULL,
|
|
148
|
+
"timestamp" timestamp NOT NULL,
|
|
149
|
+
type integer NOT NULL,
|
|
150
|
+
configuration_uuid uuid NOT NULL,
|
|
151
|
+
user_uuid uuid NOT NULL,
|
|
152
|
+
CONSTRAINT configuration_changes_pk PRIMARY KEY (configuration_change_uuid)
|
|
153
|
+
|
|
154
|
+
);
|
|
155
|
+
-- ddl-end --
|
|
156
|
+
ALTER TABLE uboa.configuration_changes OWNER TO uboa;
|
|
157
|
+
-- ddl-end --
|
|
158
|
+
|
|
159
|
+
-- object: configurations_fk | type: CONSTRAINT --
|
|
160
|
+
-- ALTER TABLE uboa.configuration_changes DROP CONSTRAINT IF EXISTS configurations_fk CASCADE;
|
|
161
|
+
ALTER TABLE uboa.configuration_changes ADD CONSTRAINT configurations_fk FOREIGN KEY (configuration_uuid)
|
|
162
|
+
REFERENCES uboa.configurations (configuration_uuid) MATCH FULL
|
|
163
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
164
|
+
-- ddl-end --
|
|
165
|
+
|
|
166
|
+
-- object: users_fk | type: CONSTRAINT --
|
|
167
|
+
-- ALTER TABLE uboa.configuration_changes DROP CONSTRAINT IF EXISTS users_fk CASCADE;
|
|
168
|
+
ALTER TABLE uboa.configuration_changes ADD CONSTRAINT users_fk FOREIGN KEY (user_uuid)
|
|
169
|
+
REFERENCES uboa.users (user_uuid) MATCH FULL
|
|
170
|
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
|
171
|
+
-- ddl-end --
|
|
172
|
+
|
|
173
|
+
-- object: users_fk | type: CONSTRAINT --
|
|
174
|
+
-- ALTER TABLE uboa.configurations DROP CONSTRAINT IF EXISTS users_fk CASCADE;
|
|
175
|
+
ALTER TABLE uboa.configurations ADD CONSTRAINT users_fk FOREIGN KEY (user_uuid)
|
|
176
|
+
REFERENCES uboa.users (user_uuid) MATCH FULL
|
|
177
|
+
ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
178
|
+
-- ddl-end --
|
|
179
|
+
|
|
180
|
+
-- object: unique_configuration | type: CONSTRAINT --
|
|
181
|
+
-- ALTER TABLE uboa.configurations DROP CONSTRAINT IF EXISTS unique_configuration CASCADE;
|
|
182
|
+
ALTER TABLE uboa.configurations ADD CONSTRAINT unique_configuration UNIQUE (name,user_uuid);
|
|
183
|
+
-- ddl-end --
|
|
184
|
+
|
|
185
|
+
|