pum 1.1.4__tar.gz → 1.1.6__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.4/pum.egg-info → pum-1.1.6}/PKG-INFO +1 -1
- {pum-1.1.4 → pum-1.1.6}/pum/hook.py +10 -6
- {pum-1.1.4 → pum-1.1.6}/pum/parameter.py +2 -0
- {pum-1.1.4 → pum-1.1.6}/pum/sql_content.py +17 -0
- {pum-1.1.4 → pum-1.1.6}/pum/upgrader.py +6 -25
- {pum-1.1.4 → pum-1.1.6/pum.egg-info}/PKG-INFO +1 -1
- {pum-1.1.4 → pum-1.1.6}/pum.egg-info/SOURCES.txt +0 -1
- {pum-1.1.4 → pum-1.1.6}/test/test_upgrader.py +1 -1
- pum-1.1.4/docs/roles.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/.ci/setup_db.sh +0 -0
- {pum-1.1.4 → pum-1.1.6}/.github/dependabot.yml +0 -0
- {pum-1.1.4 → pum-1.1.6}/.github/workflows/deploy-to-pypi.yml +0 -0
- {pum-1.1.4 → pum-1.1.6}/.github/workflows/docs.yml +0 -0
- {pum-1.1.4 → pum-1.1.6}/.github/workflows/tests.yml +0 -0
- {pum-1.1.4 → pum-1.1.6}/.github/workflows/wheel.yml +0 -0
- {pum-1.1.4 → pum-1.1.6}/.github/workflows/windows-tests.yml +0 -0
- {pum-1.1.4 → pum-1.1.6}/.gitignore +0 -0
- {pum-1.1.4 → pum-1.1.6}/.pre-commit-config.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/LICENSE +0 -0
- {pum-1.1.4 → pum-1.1.6}/README.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/changelog.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/dump_format.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/dumper.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/exceptions.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/hook_base.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/hook_handler.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/parameter_definition.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/parameter_type.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/permission.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/permission_type.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/pum_config.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/role.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/role_manager.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/schema_migrations.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/sql_content.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/api/upgrader.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/assets/images/favicon.ico +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/assets/images/pum-darkmode.png +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/assets/images/pum.png +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/baseline.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/check.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/dump.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/info.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/install.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/restore.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/role.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli/upgrade.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/cli.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/config_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/configuration.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/demo_data_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/dependency_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/hook_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/migration_hooks_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/parameter_definition_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/permission_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/pum_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/configuration/role_model.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/getting_started.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/hooks.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/index.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/docs/roles.md +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/mkdocs.yml +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/requirements.txt +0 -0
- {pum-1.1.4 → pum-1.1.6}/docs/update_cli_docs.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/__init__.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/changelog.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/checker.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/cli.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/conf/pum_config_example.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/config_model.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/dependency_handler.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/dumper.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/exceptions.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/info.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/pum_config.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/role_manager.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum/schema_migrations.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum.egg-info/dependency_links.txt +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum.egg-info/entry_points.txt +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum.egg-info/requires.txt +0 -0
- {pum-1.1.4 → pum-1.1.6}/pum.egg-info/top_level.txt +0 -0
- {pum-1.1.4 → pum-1.1.6}/pyproject.toml +0 -0
- {pum-1.1.4 → pum-1.1.6}/requirements/base.txt +0 -0
- {pum-1.1.4 → pum-1.1.6}/requirements/development.txt +0 -0
- {pum-1.1.4 → pum-1.1.6}/scripts/run_postgis.sh +0 -0
- {pum-1.1.4 → pum-1.1.6}/setup.cfg +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/__init__.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/complex_files_content/changelogs/1.2.3/complex_files_content.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/custom_directory/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/custom_directory/my_delta_directory/1.2.3/my_delta_directory.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/custom_migration_schema/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/custom_migration_schema/changelogs/1.2.3/custom_migration_schema.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/demo_data/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/demo_data/changelogs/1.2.3/single_changelog.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/demo_data/demo_data/demo_data.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/dependencies/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/dependencies/changelogs/1.2.3/pre_post_python_parameters.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/dependencies/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/dependencies/post/create_schema.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/dependencies/post/create_view.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/dependencies/pre/drop_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/invalid_changelog_commit/changelogs/1.2.3/invalid_changelog.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/invalid_changelog_search_path/changelogs/1.2.3/invalid_changelog.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/min_version/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/min_version/changelogs/1.2.3/roles.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/1.2.3/multiple_changelogs.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/1.3.0/add_created_by_column.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/2.0.0/create_second_table.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/2.0.0/create_third_table.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/parameters/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/parameters/changelogs/1.2.3/parameters.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python/changelogs/1.2.3/pre_post_python.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python/post/create_schema.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python/post/create_view.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python/pre/drop_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_local_import/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_local_import/changelogs/1.2.3/pre_post_python_local_import.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_local_import/post/create_schema.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_local_import/post/create_view.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_local_import/post/folder/my_module.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_local_import/pre/drop_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters/changelogs/1.2.3/pre_post_python_parameters.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters/post/create_schema.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters/post/create_view.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters/pre/drop_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters_broken/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters_broken/changelogs/1.2.3/pre_post_python_parameters_broken.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters_broken/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters_broken/post/create_schema.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters_broken/post/create_view.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_python_parameters_broken/pre/drop_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_code/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_code/changelogs/1.2.3/pre_post_sql_code.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_code/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_code/post/create_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_code/pre/drop_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_files/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_files/changelogs/1.2.3/pre_post_sql_files.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_files/changelogs/1.2.4/rename_created_date.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_files/post/create_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/pre_post_sql_files/pre/drop_view.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/roles/.pum.yaml +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/roles/changelogs/1.2.3/roles.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/data/single_changelog/changelogs/1.2.3/single_changelog.sql +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/test_changelog.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/test_checker.py.disabled +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/test_config.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/test_dumper.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/test_pum.sh +0 -0
- {pum-1.1.4 → pum-1.1.6}/test/test_roles.py +0 -0
- {pum-1.1.4 → pum-1.1.6}/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.6
|
|
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
|
|
@@ -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:
|
|
@@ -225,7 +229,7 @@ class HookHandler:
|
|
|
225
229
|
f"Unsupported file type for migration hook: {self.file.suffix}. Only .sql and .py files are supported."
|
|
226
230
|
)
|
|
227
231
|
elif self.code:
|
|
228
|
-
SqlContent(self.code).execute(connection, parameters=
|
|
232
|
+
SqlContent(self.code).execute(connection, parameters=parameters_literals, commit=False)
|
|
229
233
|
|
|
230
234
|
if commit:
|
|
231
235
|
connection.commit()
|
|
@@ -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:
|
|
@@ -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.6
|
|
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
|
|
@@ -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.4/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.4 → pum-1.1.6}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pum-1.1.4 → pum-1.1.6}/test/data/complex_files_content/changelogs/1.2.3/complex_files_content.sql
RENAMED
|
File without changes
|
|
File without changes
|
{pum-1.1.4 → pum-1.1.6}/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.4 → pum-1.1.6}/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.4 → pum-1.1.6}/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.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/1.2.3/multiple_changelogs.sql
RENAMED
|
File without changes
|
{pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/1.2.4/rename_created_date.sql
RENAMED
|
File without changes
|
{pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/1.3.0/add_created_by_column.sql
RENAMED
|
File without changes
|
{pum-1.1.4 → pum-1.1.6}/test/data/multiple_changelogs/changelogs/2.0.0/create_second_table.sql
RENAMED
|
File without changes
|
{pum-1.1.4 → pum-1.1.6}/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.4 → pum-1.1.6}/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.4 → pum-1.1.6}/test/data/pre_post_sql_files/changelogs/1.2.3/pre_post_sql_files.sql
RENAMED
|
File without changes
|
{pum-1.1.4 → pum-1.1.6}/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
|