pum 1.1.3__tar.gz → 1.1.5__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.3/pum.egg-info → pum-1.1.5}/PKG-INFO +1 -1
- {pum-1.1.3 → pum-1.1.5}/docs/docs/index.md +1 -1
- {pum-1.1.3 → pum-1.1.5}/pum/config_model.py +6 -0
- {pum-1.1.3 → pum-1.1.5}/pum/hook.py +9 -5
- {pum-1.1.3 → pum-1.1.5}/pum/parameter.py +2 -0
- {pum-1.1.3 → pum-1.1.5}/pum/pum_config.py +16 -5
- {pum-1.1.3 → pum-1.1.5}/pum/sql_content.py +17 -0
- {pum-1.1.3 → pum-1.1.5}/pum/upgrader.py +6 -25
- {pum-1.1.3 → pum-1.1.5/pum.egg-info}/PKG-INFO +1 -1
- {pum-1.1.3 → pum-1.1.5}/pum.egg-info/SOURCES.txt +0 -2
- {pum-1.1.3 → pum-1.1.5}/test/test_upgrader.py +1 -1
- pum-1.1.3/docs/docs/api/api.md +0 -11
- pum-1.1.3/docs/roles.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/.ci/setup_db.sh +0 -0
- {pum-1.1.3 → pum-1.1.5}/.github/dependabot.yml +0 -0
- {pum-1.1.3 → pum-1.1.5}/.github/workflows/deploy-to-pypi.yml +0 -0
- {pum-1.1.3 → pum-1.1.5}/.github/workflows/docs.yml +0 -0
- {pum-1.1.3 → pum-1.1.5}/.github/workflows/tests.yml +0 -0
- {pum-1.1.3 → pum-1.1.5}/.github/workflows/wheel.yml +0 -0
- {pum-1.1.3 → pum-1.1.5}/.github/workflows/windows-tests.yml +0 -0
- {pum-1.1.3 → pum-1.1.5}/.gitignore +0 -0
- {pum-1.1.3 → pum-1.1.5}/.pre-commit-config.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/LICENSE +0 -0
- {pum-1.1.3 → pum-1.1.5}/README.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/changelog.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/dump_format.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/dumper.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/exceptions.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/hook_base.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/hook_handler.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/parameter_definition.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/parameter_type.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/permission.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/permission_type.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/pum_config.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/role.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/role_manager.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/schema_migrations.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/sql_content.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/api/upgrader.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/assets/images/favicon.ico +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/assets/images/pum-darkmode.png +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/assets/images/pum.png +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/baseline.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/check.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/dump.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/info.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/install.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/restore.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/role.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli/upgrade.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/cli.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/config_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/configuration.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/demo_data_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/dependency_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/hook_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/migration_hooks_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/parameter_definition_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/permission_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/pum_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/configuration/role_model.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/getting_started.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/hooks.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/docs/roles.md +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/mkdocs.yml +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/requirements.txt +0 -0
- {pum-1.1.3 → pum-1.1.5}/docs/update_cli_docs.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/__init__.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/changelog.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/checker.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/cli.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/conf/pum_config_example.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/dependency_handler.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/dumper.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/exceptions.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/info.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/role_manager.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum/schema_migrations.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum.egg-info/dependency_links.txt +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum.egg-info/entry_points.txt +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum.egg-info/requires.txt +0 -0
- {pum-1.1.3 → pum-1.1.5}/pum.egg-info/top_level.txt +0 -0
- {pum-1.1.3 → pum-1.1.5}/pyproject.toml +0 -0
- {pum-1.1.3 → pum-1.1.5}/requirements/base.txt +0 -0
- {pum-1.1.3 → pum-1.1.5}/requirements/development.txt +0 -0
- {pum-1.1.3 → pum-1.1.5}/scripts/run_postgis.sh +0 -0
- {pum-1.1.3 → pum-1.1.5}/setup.cfg +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/__init__.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/complex_files_content/changelogs/1.2.3/complex_files_content.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/custom_directory/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/custom_directory/my_delta_directory/1.2.3/my_delta_directory.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/custom_migration_schema/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/custom_migration_schema/changelogs/1.2.3/custom_migration_schema.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/demo_data/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/demo_data/changelogs/1.2.3/single_changelog.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/demo_data/demo_data/demo_data.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/dependencies/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/dependencies/changelogs/1.2.3/pre_post_python_parameters.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/dependencies/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/dependencies/post/create_schema.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/dependencies/post/create_view.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/dependencies/pre/drop_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/invalid_changelog_commit/changelogs/1.2.3/invalid_changelog.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/invalid_changelog_search_path/changelogs/1.2.3/invalid_changelog.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/min_version/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/min_version/changelogs/1.2.3/roles.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/1.2.3/multiple_changelogs.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/1.3.0/add_created_by_column.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/2.0.0/create_second_table.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/2.0.0/create_third_table.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/parameters/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/parameters/changelogs/1.2.3/parameters.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python/changelogs/1.2.3/pre_post_python.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python/post/create_schema.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python/post/create_view.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python/pre/drop_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_local_import/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_local_import/changelogs/1.2.3/pre_post_python_local_import.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_local_import/post/create_schema.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_local_import/post/create_view.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_local_import/post/folder/my_module.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_local_import/pre/drop_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters/changelogs/1.2.3/pre_post_python_parameters.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters/post/create_schema.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters/post/create_view.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters/pre/drop_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters_broken/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters_broken/changelogs/1.2.3/pre_post_python_parameters_broken.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters_broken/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters_broken/post/create_schema.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters_broken/post/create_view.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_python_parameters_broken/pre/drop_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_code/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_code/changelogs/1.2.3/pre_post_sql_code.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_code/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_code/post/create_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_code/pre/drop_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_files/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_files/changelogs/1.2.3/pre_post_sql_files.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_files/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_files/post/create_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_files/pre/drop_view.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/roles/.pum.yaml +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/roles/changelogs/1.2.3/roles.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/data/single_changelog/changelogs/1.2.3/single_changelog.sql +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/test_changelog.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/test_checker.py.disabled +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/test_config.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/test_dumper.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/test_pum.sh +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/test_roles.py +0 -0
- {pum-1.1.3 → pum-1.1.5}/test/test_schema_migrations.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pum
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.5
|
|
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
|
|
@@ -8,7 +8,7 @@ PUM (PostgreSQL Upgrades Manager) is a robust database migration management tool
|
|
|
8
8
|
|
|
9
9
|
# Key Features
|
|
10
10
|
|
|
11
|
-
- **Command-line and Python Integration**: Use PUM as a standalone [CLI tool](cli.md) or integrate it into your Python project using the [API](api/
|
|
11
|
+
- **Command-line and Python Integration**: Use PUM as a standalone [CLI tool](cli.md) or integrate it into your Python project using the [API](api/pum_config.md).
|
|
12
12
|
- **Database Versioning**: Automatically manage database versioning with a metadata table.
|
|
13
13
|
- **Changelog Management**: Apply and track SQL delta files for database upgrades.
|
|
14
14
|
- **Migration Hooks**: Define custom hooks to execute additional SQL or Python code before or after migrations. This feature allows you to isolate data (table) code from application code (such as views and triggers), ensuring a clear separation of concerns and more maintainable database structures.
|
|
@@ -26,6 +26,12 @@ class ParameterDefinitionModel(PumCustomBaseModel):
|
|
|
26
26
|
default: Optional[Any] = None
|
|
27
27
|
description: Optional[str] = None
|
|
28
28
|
|
|
29
|
+
@model_validator(mode="before")
|
|
30
|
+
def validate_default(cls, values):
|
|
31
|
+
if values.get("type") == ParameterType.BOOLEAN:
|
|
32
|
+
values["default"] = values.get("default", False) in (1, "1", "true", "TRUE", True)
|
|
33
|
+
return values
|
|
34
|
+
|
|
29
35
|
|
|
30
36
|
class HookModel(PumCustomBaseModel):
|
|
31
37
|
"""
|
|
@@ -59,8 +59,9 @@ class HookBase(abc.ABC):
|
|
|
59
59
|
connection: The database connection.
|
|
60
60
|
sql: The SQL statement to execute or a path to a SQL file..
|
|
61
61
|
"""
|
|
62
|
+
parameters_literals = SqlContent.prepare_parameters(self._parameters)
|
|
62
63
|
SqlContent(sql).execute(
|
|
63
|
-
connection=self._connection, parameters=
|
|
64
|
+
connection=self._connection, parameters=parameters_literals, commit=False
|
|
64
65
|
)
|
|
65
66
|
|
|
66
67
|
execute.__isfinal__ = True
|
|
@@ -191,13 +192,15 @@ class HookHandler:
|
|
|
191
192
|
f"Executing hook from file: {self.file} or SQL code with parameters: {parameters}",
|
|
192
193
|
)
|
|
193
194
|
|
|
195
|
+
parameters_literals = SqlContent.prepare_parameters(parameters)
|
|
196
|
+
|
|
194
197
|
if self.file is None and self.code is None:
|
|
195
198
|
raise ValueError("No file or SQL code specified for the migration hook.")
|
|
196
199
|
|
|
197
200
|
if self.file:
|
|
198
201
|
if self.file.suffix == ".sql":
|
|
199
202
|
SqlContent(self.file).execute(
|
|
200
|
-
connection=connection, commit=False, parameters=
|
|
203
|
+
connection=connection, commit=False, parameters=parameters_literals
|
|
201
204
|
)
|
|
202
205
|
elif self.file.suffix == ".py":
|
|
203
206
|
for parameter_arg in self.parameter_args:
|
|
@@ -208,9 +211,10 @@ class HookHandler:
|
|
|
208
211
|
)
|
|
209
212
|
|
|
210
213
|
_hook_parameters = {}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
if parameters:
|
|
215
|
+
for key, value in parameters.items():
|
|
216
|
+
if key in self.parameter_args:
|
|
217
|
+
_hook_parameters[key] = value
|
|
214
218
|
self.hook_instance._prepare(connection=connection, parameters=parameters)
|
|
215
219
|
try:
|
|
216
220
|
if _hook_parameters:
|
|
@@ -11,6 +11,7 @@ class ParameterType(Enum):
|
|
|
11
11
|
INTEGER (str): Represents an integer parameter type.
|
|
12
12
|
TEXT (str): Represents a text parameter type.
|
|
13
13
|
DECIMAL (str): Represents a decimal parameter type.
|
|
14
|
+
PATH (str): Represents a path parameter type.
|
|
14
15
|
|
|
15
16
|
"""
|
|
16
17
|
|
|
@@ -18,6 +19,7 @@ class ParameterType(Enum):
|
|
|
18
19
|
INTEGER = "integer"
|
|
19
20
|
TEXT = "text"
|
|
20
21
|
DECIMAL = "decimal"
|
|
22
|
+
PATH = "path"
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
class ParameterDefinition:
|
|
@@ -25,7 +25,7 @@ try:
|
|
|
25
25
|
except importlib.metadata.PackageNotFoundError:
|
|
26
26
|
# Fallback: try to read from pum-*.dist-info/METADATA
|
|
27
27
|
dist_info_dirs = glob.glob(os.path.join(os.path.dirname(__file__), "..", "pum-*.dist-info"))
|
|
28
|
-
|
|
28
|
+
versions = []
|
|
29
29
|
for dist_info in dist_info_dirs:
|
|
30
30
|
metadata_path = os.path.join(dist_info, "METADATA")
|
|
31
31
|
if os.path.isfile(metadata_path):
|
|
@@ -33,11 +33,11 @@ except importlib.metadata.PackageNotFoundError:
|
|
|
33
33
|
for line in f:
|
|
34
34
|
if line.startswith("Version:"):
|
|
35
35
|
version = line.split(":", 1)[1].strip()
|
|
36
|
+
versions.append(version)
|
|
36
37
|
break
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
PUM_VERSION = packaging.version.Version(version)
|
|
38
|
+
if versions:
|
|
39
|
+
# Pick the highest version
|
|
40
|
+
PUM_VERSION = max((packaging.version.Version(v) for v in versions))
|
|
41
41
|
else:
|
|
42
42
|
PUM_VERSION = packaging.version.Version("0.0.0")
|
|
43
43
|
|
|
@@ -137,6 +137,17 @@ class PumConfig:
|
|
|
137
137
|
"""Return the base path used for configuration and changelogs."""
|
|
138
138
|
return self._base_path
|
|
139
139
|
|
|
140
|
+
def parameters(self) -> list[ParameterDefinition]:
|
|
141
|
+
"""Return a list of migration parameters.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
list[ParameterDefinition]: A list of migration parameter definitions.
|
|
145
|
+
|
|
146
|
+
"""
|
|
147
|
+
return [
|
|
148
|
+
ParameterDefinition(**parameter.model_dump()) for parameter in self.config.parameters
|
|
149
|
+
]
|
|
150
|
+
|
|
140
151
|
def parameter(self, name: str) -> ParameterDefinition:
|
|
141
152
|
"""Get a specific migration parameter by name.
|
|
142
153
|
|
|
@@ -263,3 +263,20 @@ class SqlContent:
|
|
|
263
263
|
) from e
|
|
264
264
|
|
|
265
265
|
return [format_sql(statement, parameters) for statement in sql_code]
|
|
266
|
+
|
|
267
|
+
@staticmethod
|
|
268
|
+
def prepare_parameters(parameters: dict | None):
|
|
269
|
+
"""
|
|
270
|
+
Prepares a dictionary of parameters for use in SQL queries by converting each value to a psycopg.sql.Literal.
|
|
271
|
+
|
|
272
|
+
Args:
|
|
273
|
+
parameters: A dictionary of parameters to be converted, or None.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
dict: A new dictionary with the same keys as `parameters`, where each value is wrapped in psycopg.sql.Literal.
|
|
277
|
+
"""
|
|
278
|
+
parameters_literals = {}
|
|
279
|
+
if parameters:
|
|
280
|
+
for key, value in parameters.items():
|
|
281
|
+
parameters_literals[key] = psycopg.sql.Literal(value)
|
|
282
|
+
return parameters_literals
|
|
@@ -4,7 +4,6 @@ import logging
|
|
|
4
4
|
import packaging
|
|
5
5
|
import packaging.version
|
|
6
6
|
import psycopg
|
|
7
|
-
import copy
|
|
8
7
|
|
|
9
8
|
from .pum_config import PumConfig
|
|
10
9
|
from .exceptions import PumException
|
|
@@ -76,8 +75,6 @@ class Upgrader:
|
|
|
76
75
|
commit:
|
|
77
76
|
If True, the changes will be committed to the database.
|
|
78
77
|
"""
|
|
79
|
-
parameters_literals = self._prepare_parameters(parameters)
|
|
80
|
-
|
|
81
78
|
if demo_data and demo_data not in self.config.demo_data():
|
|
82
79
|
raise PumException(
|
|
83
80
|
f"Demo data '{demo_data}' not found in the configuration. Available demo data: {self.config.demo_data()}"
|
|
@@ -98,8 +95,9 @@ class Upgrader:
|
|
|
98
95
|
)
|
|
99
96
|
|
|
100
97
|
for pre_hook in self.config.pre_hook_handlers():
|
|
101
|
-
pre_hook.execute(connection=connection, commit=False, parameters=
|
|
98
|
+
pre_hook.execute(connection=connection, commit=False, parameters=parameters)
|
|
102
99
|
|
|
100
|
+
parameters_literals = SqlContent.prepare_parameters(parameters)
|
|
103
101
|
last_changelog = None
|
|
104
102
|
for changelog in self.config.changelogs(max_version=max_version):
|
|
105
103
|
last_changelog = changelog
|
|
@@ -117,7 +115,7 @@ class Upgrader:
|
|
|
117
115
|
)
|
|
118
116
|
|
|
119
117
|
for post_hook in self.config.post_hook_handlers():
|
|
120
|
-
post_hook.execute(connection=connection, commit=False, parameters=
|
|
118
|
+
post_hook.execute(connection=connection, commit=False, parameters=parameters)
|
|
121
119
|
|
|
122
120
|
logger.info(
|
|
123
121
|
"Installed %s.pum_migrations table and applied changelogs up to version %s",
|
|
@@ -148,16 +146,15 @@ class Upgrader:
|
|
|
148
146
|
if name not in self.config.demo_data():
|
|
149
147
|
raise PumException(f"Demo data '{name}' not found in the configuration.")
|
|
150
148
|
|
|
151
|
-
parameters_literals = self._prepare_parameters(parameters)
|
|
152
|
-
|
|
153
149
|
demo_data_file = self.config.base_path / self.config.demo_data()[name]
|
|
154
150
|
logger.info("Installing demo data from %s", demo_data_file)
|
|
155
151
|
|
|
156
152
|
for pre_hook in self.config.pre_hook_handlers():
|
|
157
|
-
pre_hook.execute(connection=connection, commit=False, parameters=
|
|
153
|
+
pre_hook.execute(connection=connection, commit=False, parameters=parameters)
|
|
158
154
|
|
|
159
155
|
connection.commit()
|
|
160
156
|
|
|
157
|
+
parameters_literals = SqlContent.prepare_parameters(parameters)
|
|
161
158
|
SqlContent(sql=demo_data_file).execute(
|
|
162
159
|
connection=connection,
|
|
163
160
|
commit=False,
|
|
@@ -167,22 +164,6 @@ class Upgrader:
|
|
|
167
164
|
connection.commit()
|
|
168
165
|
|
|
169
166
|
for post_hook in self.config.post_hook_handlers():
|
|
170
|
-
post_hook.execute(connection=connection, commit=False, parameters=
|
|
167
|
+
post_hook.execute(connection=connection, commit=False, parameters=parameters)
|
|
171
168
|
|
|
172
169
|
logger.info("Demo data '%s' installed successfully.", name)
|
|
173
|
-
|
|
174
|
-
@staticmethod
|
|
175
|
-
def _prepare_parameters(parameters: dict | None):
|
|
176
|
-
"""
|
|
177
|
-
Prepares a dictionary of parameters for use in SQL queries by converting each value to a psycopg.sql.Literal.
|
|
178
|
-
|
|
179
|
-
Args:
|
|
180
|
-
parameters: A dictionary of parameters to be converted, or None.
|
|
181
|
-
|
|
182
|
-
Returns:
|
|
183
|
-
dict: A new dictionary with the same keys as `parameters`, where each value is wrapped in psycopg.sql.Literal.
|
|
184
|
-
"""
|
|
185
|
-
parameters_literals = copy.deepcopy(parameters) if parameters else {}
|
|
186
|
-
for key, value in parameters_literals.items():
|
|
187
|
-
parameters_literals[key] = psycopg.sql.Literal(value)
|
|
188
|
-
return parameters_literals
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pum
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.5
|
|
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
|
|
@@ -12,14 +12,12 @@ pyproject.toml
|
|
|
12
12
|
.github/workflows/windows-tests.yml
|
|
13
13
|
docs/mkdocs.yml
|
|
14
14
|
docs/requirements.txt
|
|
15
|
-
docs/roles.md
|
|
16
15
|
docs/update_cli_docs.py
|
|
17
16
|
docs/docs/cli.md
|
|
18
17
|
docs/docs/getting_started.md
|
|
19
18
|
docs/docs/hooks.md
|
|
20
19
|
docs/docs/index.md
|
|
21
20
|
docs/docs/roles.md
|
|
22
|
-
docs/docs/api/api.md
|
|
23
21
|
docs/docs/api/changelog.md
|
|
24
22
|
docs/docs/api/dump_format.md
|
|
25
23
|
docs/docs/api/dumper.md
|
|
@@ -77,7 +77,7 @@ class TestUpgrader(unittest.TestCase):
|
|
|
77
77
|
test_dir = Path("test") / "data" / "parameters"
|
|
78
78
|
config_path = test_dir / ".pum.yaml"
|
|
79
79
|
cfg = PumConfig.from_yaml(config_path)
|
|
80
|
-
self.assertEqual(len(cfg.
|
|
80
|
+
self.assertEqual(len(cfg.parameters()), 3)
|
|
81
81
|
self.assertEqual(
|
|
82
82
|
cfg.parameter("SRID"),
|
|
83
83
|
ParameterDefinition(
|
pum-1.1.3/docs/docs/api/api.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# PUM API
|
|
2
|
-
|
|
3
|
-
- [Changelog](api/changelog.md)
|
|
4
|
-
- [Hook](api/hook.md)
|
|
5
|
-
- [Hook](api/hook_handler.md)
|
|
6
|
-
- [ParameterDefinition](api/parameter_definition.md)
|
|
7
|
-
- [ParameterType](api/parameter_type.md)
|
|
8
|
-
- [PumConfig](api/pum_config.md)
|
|
9
|
-
- [SchemaMigrations](api/schema_migrations.md)
|
|
10
|
-
- [Upgrader](api/upgrader.md)
|
|
11
|
-
- [Exceptions](api/exceptions.md)
|
pum-1.1.3/docs/roles.md
DELETED
|
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
|
{pum-1.1.3 → pum-1.1.5}/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
|
|
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
|
|
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
|
{pum-1.1.3 → pum-1.1.5}/test/data/complex_files_content/changelogs/1.2.3/complex_files_content.sql
RENAMED
|
File without changes
|
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/custom_directory/my_delta_directory/1.2.3/my_delta_directory.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/dependencies/changelogs/1.2.3/pre_post_python_parameters.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/invalid_changelog_commit/changelogs/1.2.3/invalid_changelog.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/1.2.3/multiple_changelogs.sql
RENAMED
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/1.2.4/rename_created_date.sql
RENAMED
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/1.3.0/add_created_by_column.sql
RENAMED
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/2.0.0/create_second_table.sql
RENAMED
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/multiple_changelogs/changelogs/2.0.0/create_third_table.sql
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
|
{pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_code/changelogs/1.2.4/rename_created_date.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_files/changelogs/1.2.3/pre_post_sql_files.sql
RENAMED
|
File without changes
|
{pum-1.1.3 → pum-1.1.5}/test/data/pre_post_sql_files/changelogs/1.2.4/rename_created_date.sql
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
|