pum 1.2.1__tar.gz → 1.2.3__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.2.1 → pum-1.2.3}/PKG-INFO +1 -1
- {pum-1.2.1 → pum-1.2.3}/pum/cli.py +21 -2
- {pum-1.2.1 → pum-1.2.3}/pum/config_model.py +1 -1
- {pum-1.2.1 → pum-1.2.3}/pum/pum_config.py +1 -1
- {pum-1.2.1 → pum-1.2.3}/pum/upgrader.py +7 -0
- {pum-1.2.1 → pum-1.2.3}/pum.egg-info/PKG-INFO +1 -1
- {pum-1.2.1 → pum-1.2.3}/LICENSE +0 -0
- {pum-1.2.1 → pum-1.2.3}/README.md +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/__init__.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/changelog.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/checker.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/dependency_handler.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/dumper.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/exceptions.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/hook.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/info.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/parameter.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/role_manager.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/schema_migrations.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum/sql_content.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum.egg-info/SOURCES.txt +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum.egg-info/dependency_links.txt +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum.egg-info/entry_points.txt +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum.egg-info/requires.txt +0 -0
- {pum-1.2.1 → pum-1.2.3}/pum.egg-info/top_level.txt +0 -0
- {pum-1.2.1 → pum-1.2.3}/pyproject.toml +0 -0
- {pum-1.2.1 → pum-1.2.3}/requirements/base.txt +0 -0
- {pum-1.2.1 → pum-1.2.3}/requirements/development.txt +0 -0
- {pum-1.2.1 → pum-1.2.3}/setup.cfg +0 -0
- {pum-1.2.1 → pum-1.2.3}/test/test_changelog.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/test/test_config.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/test/test_dumper.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/test/test_roles.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/test/test_schema_migrations.py +0 -0
- {pum-1.2.1 → pum-1.2.3}/test/test_upgrader.py +0 -0
{pum-1.2.1 → pum-1.2.3}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pum
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
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
|
|
@@ -279,6 +279,11 @@ def create_parser() -> argparse.ArgumentParser:
|
|
|
279
279
|
parser_baseline.add_argument(
|
|
280
280
|
"-b", "--baseline", help="Set baseline in the format x.x.x", required=True
|
|
281
281
|
)
|
|
282
|
+
parser_baseline.add_argument(
|
|
283
|
+
"--create-table",
|
|
284
|
+
help="Create the pum_migrations table if it does not exist",
|
|
285
|
+
action="store_true",
|
|
286
|
+
)
|
|
282
287
|
|
|
283
288
|
# Parser for the "upgrade" command
|
|
284
289
|
parser_upgrade = subparsers.add_parser("upgrade", help="upgrade db")
|
|
@@ -307,10 +312,13 @@ def cli() -> int: # noqa: PLR0912
|
|
|
307
312
|
parser.print_help()
|
|
308
313
|
parser.exit()
|
|
309
314
|
|
|
315
|
+
validate = args.command not in ("info", "baseline")
|
|
310
316
|
if args.config_file:
|
|
311
|
-
config = PumConfig.from_yaml(args.config_file, install_dependencies=True)
|
|
317
|
+
config = PumConfig.from_yaml(args.config_file, validate=validate, install_dependencies=True)
|
|
312
318
|
else:
|
|
313
|
-
config = PumConfig.from_yaml(
|
|
319
|
+
config = PumConfig.from_yaml(
|
|
320
|
+
Path(args.dir) / ".pum.yaml", validate=validate, install_dependencies=True
|
|
321
|
+
)
|
|
314
322
|
|
|
315
323
|
with psycopg.connect(f"service={args.pg_service}") as conn:
|
|
316
324
|
# Check if the connection is successful
|
|
@@ -391,6 +399,17 @@ def cli() -> int: # noqa: PLR0912
|
|
|
391
399
|
elif args.command == "restore":
|
|
392
400
|
pum.run_restore(args.pg_service, args.file, args.x, args.exclude_schema)
|
|
393
401
|
elif args.command == "baseline":
|
|
402
|
+
sm = SchemaMigrations(config=config)
|
|
403
|
+
if not sm.exists(connection=conn):
|
|
404
|
+
if args.create_table:
|
|
405
|
+
sm.create(connection=conn)
|
|
406
|
+
logger.info("Created pum_migrations table.")
|
|
407
|
+
else:
|
|
408
|
+
logger.error(
|
|
409
|
+
"pum_migrations table does not exist. Use --create-table to create it."
|
|
410
|
+
)
|
|
411
|
+
exit_code = 1
|
|
412
|
+
return exit_code
|
|
394
413
|
SchemaMigrations(config=config).set_baseline(connection=conn, version=args.baseline)
|
|
395
414
|
|
|
396
415
|
elif args.command == "upgrade":
|
|
@@ -72,7 +72,7 @@ class PumModel(PumCustomBaseModel):
|
|
|
72
72
|
PumModel holds some PUM specifics.
|
|
73
73
|
|
|
74
74
|
Attributes:
|
|
75
|
-
migration_table_schema: Name of schema for the migration table.
|
|
75
|
+
migration_table_schema: Name of schema for the migration table. The table will always be named `pum_migrations`.
|
|
76
76
|
minimum_version: Minimum required version of PUM.
|
|
77
77
|
"""
|
|
78
78
|
|
|
@@ -231,7 +231,7 @@ class PumConfig:
|
|
|
231
231
|
"""Return a RoleManager instance based on the roles defined in the configuration."""
|
|
232
232
|
if not self.config.roles:
|
|
233
233
|
logger.warning("No roles defined in the configuration. Returning an empty RoleManager.")
|
|
234
|
-
return RoleManager()
|
|
234
|
+
return RoleManager([])
|
|
235
235
|
return RoleManager([role.model_dump() for role in self.config.roles])
|
|
236
236
|
|
|
237
237
|
def pre_hook_handlers(self) -> list[HookHandler]:
|
|
@@ -133,6 +133,7 @@ class Upgrader:
|
|
|
133
133
|
name: str,
|
|
134
134
|
*,
|
|
135
135
|
parameters: dict | None = None,
|
|
136
|
+
grant: bool = True,
|
|
136
137
|
) -> None:
|
|
137
138
|
"""Install demo data for the module.
|
|
138
139
|
|
|
@@ -140,6 +141,7 @@ class Upgrader:
|
|
|
140
141
|
connection: The database connection to use.
|
|
141
142
|
name: The name of the demo data to install.
|
|
142
143
|
parameters: The parameters to pass to the demo data SQL.
|
|
144
|
+
grant: If True, grant permissions to the roles after installing the demo data. Default is True.
|
|
143
145
|
"""
|
|
144
146
|
if name not in self.config.demo_data():
|
|
145
147
|
raise PumException(f"Demo data '{name}' not found in the configuration.")
|
|
@@ -167,4 +169,9 @@ class Upgrader:
|
|
|
167
169
|
|
|
168
170
|
connection.commit()
|
|
169
171
|
|
|
172
|
+
if grant:
|
|
173
|
+
self.config.role_manager().grant_permissions(connection=connection, commit=False)
|
|
174
|
+
|
|
175
|
+
connection.commit()
|
|
176
|
+
|
|
170
177
|
logger.info("Demo data '%s' installed successfully.", name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pum
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
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
|
{pum-1.2.1 → pum-1.2.3}/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
|
|
File without changes
|