pum 1.1.18__tar.gz → 1.2.0__tar.gz
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-1.1.18 → pum-1.2.0}/PKG-INFO +1 -1
- {pum-1.1.18 → pum-1.2.0}/pum/config_model.py +13 -2
- {pum-1.1.18 → pum-1.2.0}/pum/pum_config.py +5 -2
- {pum-1.1.18 → pum-1.2.0}/pum/schema_migrations.py +2 -2
- {pum-1.1.18 → pum-1.2.0}/pum/upgrader.py +8 -7
- {pum-1.1.18 → pum-1.2.0}/pum.egg-info/PKG-INFO +1 -1
- {pum-1.1.18 → pum-1.2.0}/test/test_upgrader.py +18 -0
- {pum-1.1.18 → pum-1.2.0}/LICENSE +0 -0
- {pum-1.1.18 → pum-1.2.0}/README.md +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/__init__.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/changelog.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/checker.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/cli.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/dependency_handler.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/dumper.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/exceptions.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/hook.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/info.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/parameter.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/role_manager.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum/sql_content.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum.egg-info/SOURCES.txt +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum.egg-info/dependency_links.txt +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum.egg-info/entry_points.txt +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum.egg-info/requires.txt +0 -0
- {pum-1.1.18 → pum-1.2.0}/pum.egg-info/top_level.txt +0 -0
- {pum-1.1.18 → pum-1.2.0}/pyproject.toml +0 -0
- {pum-1.1.18 → pum-1.2.0}/requirements/base.txt +0 -0
- {pum-1.1.18 → pum-1.2.0}/requirements/development.txt +0 -0
- {pum-1.1.18 → pum-1.2.0}/setup.cfg +0 -0
- {pum-1.1.18 → pum-1.2.0}/test/test_changelog.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/test/test_config.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/test/test_dumper.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/test/test_roles.py +0 -0
- {pum-1.1.18 → pum-1.2.0}/test/test_schema_migrations.py +0 -0
|
@@ -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
|
|
@@ -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):
|
|
@@ -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
|
|
@@ -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:
|
|
@@ -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
|
|
@@ -407,6 +407,24 @@ class TestUpgrader(unittest.TestCase):
|
|
|
407
407
|
count = cursor.fetchone()[0]
|
|
408
408
|
self.assertEqual(count, 4)
|
|
409
409
|
|
|
410
|
+
def test_demo_data_multi(self) -> None:
|
|
411
|
+
"""Test the installation of demo data."""
|
|
412
|
+
test_dir = Path("test") / "data" / "demo_data_multi"
|
|
413
|
+
cfg = PumConfig.from_yaml(test_dir / ".pum.yaml")
|
|
414
|
+
sm = SchemaMigrations(cfg)
|
|
415
|
+
with psycopg.connect(f"service={self.pg_service}") as conn:
|
|
416
|
+
self.assertFalse(sm.exists(conn))
|
|
417
|
+
upgrader = Upgrader(config=cfg)
|
|
418
|
+
upgrader.install(connection=conn)
|
|
419
|
+
with self.assertRaises(PumException):
|
|
420
|
+
upgrader.install_demo_data(connection=conn, name="nope, nothing here fella")
|
|
421
|
+
upgrader.install_demo_data(connection=conn, name="some cool demo dataset")
|
|
422
|
+
self.assertTrue(sm.exists(conn))
|
|
423
|
+
cursor = conn.cursor()
|
|
424
|
+
cursor.execute("SELECT COUNT(*) FROM pum_test_data.some_table;")
|
|
425
|
+
count = cursor.fetchone()[0]
|
|
426
|
+
self.assertEqual(count, 4)
|
|
427
|
+
|
|
410
428
|
def test_dependencies(self) -> None:
|
|
411
429
|
"""Test the installation of dependencies."""
|
|
412
430
|
test_dir = Path("test") / "data" / "dependencies"
|
{pum-1.1.18 → pum-1.2.0}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|