pum 1.1.17__py3-none-any.whl → 1.2.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.
- pum/config_model.py +13 -2
- pum/pum_config.py +5 -2
- pum/role_manager.py +11 -6
- pum/schema_migrations.py +2 -2
- pum/upgrader.py +8 -7
- {pum-1.1.17.dist-info → pum-1.2.0.dist-info}/METADATA +1 -1
- pum-1.2.0.dist-info/RECORD +22 -0
- pum-1.1.17.dist-info/RECORD +0 -22
- {pum-1.1.17.dist-info → pum-1.2.0.dist-info}/WHEEL +0 -0
- {pum-1.1.17.dist-info → pum-1.2.0.dist-info}/entry_points.txt +0 -0
- {pum-1.1.17.dist-info → pum-1.2.0.dist-info}/licenses/LICENSE +0 -0
- {pum-1.1.17.dist-info → pum-1.2.0.dist-info}/top_level.txt +0 -0
pum/config_model.py
CHANGED
|
@@ -132,11 +132,22 @@ class DemoDataModel(PumCustomBaseModel):
|
|
|
132
132
|
DemoDataModel represents a configuration for demo data.
|
|
133
133
|
|
|
134
134
|
Attributes:
|
|
135
|
-
|
|
135
|
+
name: Name of the demo data.
|
|
136
|
+
file: Optional path to a single demo data file.
|
|
137
|
+
files: Optional list of paths to multiple demo data files.
|
|
136
138
|
"""
|
|
137
139
|
|
|
138
140
|
name: str = Field(..., description="Name of the demo data.")
|
|
139
|
-
|
|
141
|
+
|
|
142
|
+
file: Optional[str] = None
|
|
143
|
+
files: Optional[List[str]] = None
|
|
144
|
+
|
|
145
|
+
@model_validator(mode="after")
|
|
146
|
+
def validate_args(self):
|
|
147
|
+
file, files = self.file, self.files
|
|
148
|
+
if (file and files) or (not file and not files):
|
|
149
|
+
raise PumConfigError("Exactly one of 'file' or 'files' must be set in a demo data set.")
|
|
150
|
+
return self
|
|
140
151
|
|
|
141
152
|
|
|
142
153
|
class DependencyModel(PumCustomBaseModel):
|
pum/pum_config.py
CHANGED
|
@@ -256,9 +256,12 @@ class PumConfig:
|
|
|
256
256
|
else []
|
|
257
257
|
)
|
|
258
258
|
|
|
259
|
-
def demo_data(self) -> dict[str, str]:
|
|
259
|
+
def demo_data(self) -> dict[str, list[str]]:
|
|
260
260
|
"""Return a dictionary of demo data files defined in the configuration."""
|
|
261
|
-
|
|
261
|
+
demo_data_files = {}
|
|
262
|
+
for dm in self.config.demo_data:
|
|
263
|
+
demo_data_files[dm.name] = dm.files or [dm.file]
|
|
264
|
+
return demo_data_files
|
|
262
265
|
|
|
263
266
|
def __del__(self):
|
|
264
267
|
# Cleanup temporary directories and sys.path modifications
|
pum/role_manager.py
CHANGED
|
@@ -125,7 +125,7 @@ class Role:
|
|
|
125
125
|
self.inherit = inherit
|
|
126
126
|
self.description = description
|
|
127
127
|
|
|
128
|
-
def permissions(self):
|
|
128
|
+
def permissions(self) -> list[Permission]:
|
|
129
129
|
"""
|
|
130
130
|
Returns the list of permissions associated with the role.
|
|
131
131
|
"""
|
|
@@ -138,11 +138,16 @@ class Role:
|
|
|
138
138
|
Returns:
|
|
139
139
|
bool: True if the role exists, False otherwise.
|
|
140
140
|
"""
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
return (
|
|
142
|
+
SqlContent("SELECT 1 FROM pg_roles WHERE rolname = {name}")
|
|
143
|
+
.execute(
|
|
144
|
+
connection=connection,
|
|
145
|
+
commit=False,
|
|
146
|
+
parameters={"name": psycopg.sql.Literal(self.name)},
|
|
147
|
+
)
|
|
148
|
+
.fetchone()
|
|
149
|
+
is not None
|
|
150
|
+
)
|
|
146
151
|
|
|
147
152
|
def create(
|
|
148
153
|
self, connection: psycopg.Connection, grant: bool = False, commit: bool = False
|
pum/schema_migrations.py
CHANGED
|
@@ -177,9 +177,9 @@ class SchemaMigrations:
|
|
|
177
177
|
"""
|
|
178
178
|
if isinstance(version, packaging.version.Version):
|
|
179
179
|
version = str(version)
|
|
180
|
-
pattern = re.compile(r"^\d+\.\d
|
|
180
|
+
pattern = re.compile(r"^\d+\.\d+(\.\d+)?$")
|
|
181
181
|
if not re.match(pattern, version):
|
|
182
|
-
raise ValueError(f"Wrong version format: {version}. Must be x.x.
|
|
182
|
+
raise ValueError(f"Wrong version format: {version}. Must be x.y or x.y.z")
|
|
183
183
|
|
|
184
184
|
current = self.baseline(connection=connection)
|
|
185
185
|
if current and current >= version:
|
pum/upgrader.py
CHANGED
|
@@ -144,8 +144,7 @@ class Upgrader:
|
|
|
144
144
|
if name not in self.config.demo_data():
|
|
145
145
|
raise PumException(f"Demo data '{name}' not found in the configuration.")
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
logger.info("Installing demo data from %s", demo_data_file)
|
|
147
|
+
logger.info(f"Installing demo data {name}")
|
|
149
148
|
|
|
150
149
|
for pre_hook in self.config.pre_hook_handlers():
|
|
151
150
|
pre_hook.execute(connection=connection, commit=False, parameters=parameters)
|
|
@@ -153,11 +152,13 @@ class Upgrader:
|
|
|
153
152
|
connection.commit()
|
|
154
153
|
|
|
155
154
|
parameters_literals = SqlContent.prepare_parameters(parameters)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
for demo_data_file in self.config.demo_data()[name]:
|
|
156
|
+
demo_data_file = self.config.base_path / demo_data_file
|
|
157
|
+
SqlContent(sql=demo_data_file).execute(
|
|
158
|
+
connection=connection,
|
|
159
|
+
commit=False,
|
|
160
|
+
parameters=parameters_literals,
|
|
161
|
+
)
|
|
161
162
|
|
|
162
163
|
connection.commit()
|
|
163
164
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pum
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Pum stands for "Postgres Upgrades Manager". It is a Database migration management tool very similar to flyway-db or Liquibase, based on metadata tables.
|
|
5
5
|
Author-email: Denis Rouzaud <denis@opengis.ch>
|
|
6
6
|
License-Expression: GPL-2.0-or-later
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
pum/__init__.py,sha256=P-NHd6_SYpk9aypefLI62QCZ3f5APOMCwSzrFFCKAew,759
|
|
2
|
+
pum/changelog.py,sha256=yDc5swmMd5gb2vCEAlenoq5gs-ZEGc4uXicBtiGxkOk,3692
|
|
3
|
+
pum/checker.py,sha256=GT2v7793HP1g94dv0mL6CHtQfblQwAyeFHEWCy44lkc,14379
|
|
4
|
+
pum/cli.py,sha256=p5dMF4PyaM9iKpjd5QQATJLEZRiwhGDjB0oFElibwjE,14275
|
|
5
|
+
pum/config_model.py,sha256=kwUkJ0lFdKyT3V0jJkRyWpI6JNHOqVTYfYKkm3B8v_Q,6884
|
|
6
|
+
pum/dependency_handler.py,sha256=AVeemsh6zUumRJKbRLRwP_FRC0x3K16TJiK2i9ogvn0,3861
|
|
7
|
+
pum/dumper.py,sha256=EJZ8T44JM0GKgdqw1ENOfhZ-RI89OQ4DNdoTZKtLdEw,3404
|
|
8
|
+
pum/exceptions.py,sha256=xyzzY4ht1nKfrVt59Giulflpmu83nJhxoTygrqiqPlw,1137
|
|
9
|
+
pum/hook.py,sha256=5MrVa6Xr0o28RfsXylGDatlM_vOKfKtGJmhYx8crC94,9541
|
|
10
|
+
pum/info.py,sha256=CGj-Lt4Y2l2ymAl3OFqCWfJD5xZF4aaUSztAiSKwgE4,1395
|
|
11
|
+
pum/parameter.py,sha256=qdbWk3WZc419AW-qwGMxlgc-7GEhdwIoPBnDk6UsVZU,2485
|
|
12
|
+
pum/pum_config.py,sha256=mmoTmdb1s8X5xrUUEQ2xqdDZpyESZKOGj3Y8Mja7w3o,11347
|
|
13
|
+
pum/role_manager.py,sha256=sV-pbjczxCTRWPVszrks7V5MIqFSbZtmbPreE7gx13k,10236
|
|
14
|
+
pum/schema_migrations.py,sha256=rUn14aNkt8nw-69cCgklbtveanq6CrNdKKrc458cGIc,10491
|
|
15
|
+
pum/sql_content.py,sha256=-0h3caJlvkyEjZwjPVrKh5ZYaDctC-5lklBvZ-zgRzA,10620
|
|
16
|
+
pum/upgrader.py,sha256=6hqOHwXAyw9H-ksQvQZJDLDD0Gk6QxVsiOtY9bPSY7Y,6387
|
|
17
|
+
pum-1.2.0.dist-info/licenses/LICENSE,sha256=2ylvL381vKOhdO-w6zkrOxe9lLNBhRQpo9_0EbHC_HM,18046
|
|
18
|
+
pum-1.2.0.dist-info/METADATA,sha256=40kf_2wb9YRjFCzXxD6-uv6nZcZece0_6HubqiLDs5k,3138
|
|
19
|
+
pum-1.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
20
|
+
pum-1.2.0.dist-info/entry_points.txt,sha256=U6dmxSpKs1Pe9vWiR29VPhJMDjrmZeJCSxvfLGR8BD4,36
|
|
21
|
+
pum-1.2.0.dist-info/top_level.txt,sha256=ddiI4HLBhY6ql-NNm0Ez0JhoOHdWDIzrHeCdHmmagcc,4
|
|
22
|
+
pum-1.2.0.dist-info/RECORD,,
|
pum-1.1.17.dist-info/RECORD
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
pum/__init__.py,sha256=P-NHd6_SYpk9aypefLI62QCZ3f5APOMCwSzrFFCKAew,759
|
|
2
|
-
pum/changelog.py,sha256=yDc5swmMd5gb2vCEAlenoq5gs-ZEGc4uXicBtiGxkOk,3692
|
|
3
|
-
pum/checker.py,sha256=GT2v7793HP1g94dv0mL6CHtQfblQwAyeFHEWCy44lkc,14379
|
|
4
|
-
pum/cli.py,sha256=p5dMF4PyaM9iKpjd5QQATJLEZRiwhGDjB0oFElibwjE,14275
|
|
5
|
-
pum/config_model.py,sha256=l8PmaP_UJ5gbZH-p8EcE8W4J1wMhS0wPPr01a8wKlsA,6492
|
|
6
|
-
pum/dependency_handler.py,sha256=AVeemsh6zUumRJKbRLRwP_FRC0x3K16TJiK2i9ogvn0,3861
|
|
7
|
-
pum/dumper.py,sha256=EJZ8T44JM0GKgdqw1ENOfhZ-RI89OQ4DNdoTZKtLdEw,3404
|
|
8
|
-
pum/exceptions.py,sha256=xyzzY4ht1nKfrVt59Giulflpmu83nJhxoTygrqiqPlw,1137
|
|
9
|
-
pum/hook.py,sha256=5MrVa6Xr0o28RfsXylGDatlM_vOKfKtGJmhYx8crC94,9541
|
|
10
|
-
pum/info.py,sha256=CGj-Lt4Y2l2ymAl3OFqCWfJD5xZF4aaUSztAiSKwgE4,1395
|
|
11
|
-
pum/parameter.py,sha256=qdbWk3WZc419AW-qwGMxlgc-7GEhdwIoPBnDk6UsVZU,2485
|
|
12
|
-
pum/pum_config.py,sha256=bnL3rxgd7YNLD9u8Yyl7lNPxt7YtRXC0cpDP-l1Rw9w,11245
|
|
13
|
-
pum/role_manager.py,sha256=yr-fmytflGqANY3IZIpgJBoMOK98ynTWfemIBhAy79A,10131
|
|
14
|
-
pum/schema_migrations.py,sha256=MCA40pCptwWeoZQuZb3zyvbLDU7I1YdRbr1Hgpe9hYg,10481
|
|
15
|
-
pum/sql_content.py,sha256=-0h3caJlvkyEjZwjPVrKh5ZYaDctC-5lklBvZ-zgRzA,10620
|
|
16
|
-
pum/upgrader.py,sha256=5o3d-RoZoUifw4POHRe2map2ik1FFe8SagGSa1reQUg,6333
|
|
17
|
-
pum-1.1.17.dist-info/licenses/LICENSE,sha256=2ylvL381vKOhdO-w6zkrOxe9lLNBhRQpo9_0EbHC_HM,18046
|
|
18
|
-
pum-1.1.17.dist-info/METADATA,sha256=X8budn6t9STUdtHwdbqxDMiwIehSmBM4dx5dCIqbMcU,3139
|
|
19
|
-
pum-1.1.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
20
|
-
pum-1.1.17.dist-info/entry_points.txt,sha256=U6dmxSpKs1Pe9vWiR29VPhJMDjrmZeJCSxvfLGR8BD4,36
|
|
21
|
-
pum-1.1.17.dist-info/top_level.txt,sha256=ddiI4HLBhY6ql-NNm0Ez0JhoOHdWDIzrHeCdHmmagcc,4
|
|
22
|
-
pum-1.1.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|