perfact-dbschematools 26.5.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.
Files changed (56) hide show
  1. perfact_dbschematools-26.5.0/.gitea/workflows/check.yml +60 -0
  2. perfact_dbschematools-26.5.0/.gitea/workflows/publish.yml +31 -0
  3. perfact_dbschematools-26.5.0/.gitignore +22 -0
  4. perfact_dbschematools-26.5.0/PKG-INFO +110 -0
  5. perfact_dbschematools-26.5.0/README.md +93 -0
  6. perfact_dbschematools-26.5.0/bandit.yaml +3 -0
  7. perfact_dbschematools-26.5.0/data/etc/perfact/dbschematools/config.yaml +2 -0
  8. perfact_dbschematools-26.5.0/data/etc/sudoers.d/perfact-dbschematools +1 -0
  9. perfact_dbschematools-26.5.0/data/usr/bin/perfact-dbschema-add +16 -0
  10. perfact_dbschematools-26.5.0/debian/changelog +152 -0
  11. perfact_dbschematools-26.5.0/debian/control +32 -0
  12. perfact_dbschematools-26.5.0/debian/copyright +13 -0
  13. perfact_dbschematools-26.5.0/debian/perfact-dbschematools.install +1 -0
  14. perfact_dbschematools-26.5.0/debian/perfact-dbschematools.postinst +19 -0
  15. perfact_dbschematools-26.5.0/debian/rules +11 -0
  16. perfact_dbschematools-26.5.0/debian/source/format +1 -0
  17. perfact_dbschematools-26.5.0/perfact/dbschematools/__init__.py +4 -0
  18. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/columns/chdefault.sql +2 -0
  19. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/columns/chtype.sql +2 -0
  20. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/columns/create.sql +3 -0
  21. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/columns/patch.sql +27 -0
  22. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/columns/patch_default.sql +20 -0
  23. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/columns/read.sql +21 -0
  24. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/tables/create.sql +10 -0
  25. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/tables/read.sql +7 -0
  26. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/testinit/db_username.sql +9 -0
  27. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/views/dependencies.sql +25 -0
  28. perfact_dbschematools-26.5.0/perfact/dbschematools/assets/views/read.sql +11 -0
  29. perfact_dbschematools-26.5.0/perfact/dbschematools/assets.py +6 -0
  30. perfact_dbschematools-26.5.0/perfact/dbschematools/commands/__init__.py +0 -0
  31. perfact_dbschematools-26.5.0/perfact/dbschematools/commands/add.py +33 -0
  32. perfact_dbschematools-26.5.0/perfact/dbschematools/commands/dump.py +18 -0
  33. perfact_dbschematools-26.5.0/perfact/dbschematools/commands/interface.py +26 -0
  34. perfact_dbschematools-26.5.0/perfact/dbschematools/commands/patch.py +47 -0
  35. perfact_dbschematools-26.5.0/perfact/dbschematools/main.py +59 -0
  36. perfact_dbschematools-26.5.0/perfact/dbschematools/plugins/__init__.py +7 -0
  37. perfact_dbschematools-26.5.0/perfact/dbschematools/plugins/columns.py +282 -0
  38. perfact_dbschematools-26.5.0/perfact/dbschematools/plugins/interface.py +51 -0
  39. perfact_dbschematools-26.5.0/perfact/dbschematools/plugins/tables.py +89 -0
  40. perfact_dbschematools-26.5.0/perfact/dbschematools/plugins/views.py +251 -0
  41. perfact_dbschematools-26.5.0/perfact/dbschematools/tests/__init__.py +0 -0
  42. perfact_dbschematools-26.5.0/perfact/dbschematools/tests/conftest.py +33 -0
  43. perfact_dbschematools-26.5.0/perfact/dbschematools/tests/test_columns.py +215 -0
  44. perfact_dbschematools-26.5.0/perfact/dbschematools/tests/test_tables.py +19 -0
  45. perfact_dbschematools-26.5.0/perfact/dbschematools/tests/test_views.py +178 -0
  46. perfact_dbschematools-26.5.0/perfact/dbschematools/tests/testenv.py +18 -0
  47. perfact_dbschematools-26.5.0/perfact/dbschematools/utils.py +64 -0
  48. perfact_dbschematools-26.5.0/perfact_dbschematools.egg-info/PKG-INFO +110 -0
  49. perfact_dbschematools-26.5.0/perfact_dbschematools.egg-info/SOURCES.txt +55 -0
  50. perfact_dbschematools-26.5.0/perfact_dbschematools.egg-info/dependency_links.txt +1 -0
  51. perfact_dbschematools-26.5.0/perfact_dbschematools.egg-info/entry_points.txt +2 -0
  52. perfact_dbschematools-26.5.0/perfact_dbschematools.egg-info/requires.txt +4 -0
  53. perfact_dbschematools-26.5.0/perfact_dbschematools.egg-info/top_level.txt +1 -0
  54. perfact_dbschematools-26.5.0/pyproject.toml +59 -0
  55. perfact_dbschematools-26.5.0/setup.cfg +44 -0
  56. perfact_dbschematools-26.5.0/tox.ini +31 -0
@@ -0,0 +1,60 @@
1
+ name: Build Package
2
+ on:
3
+ push:
4
+ branches:
5
+ - 'main'
6
+ pull_request: {}
7
+
8
+ jobs:
9
+ build:
10
+ strategy:
11
+ matrix:
12
+ target: ['jammy', 'bookworm', 'trixie']
13
+ runs-on: perfact-build-${{ matrix.target }}
14
+ steps:
15
+ - name: Install SSH key
16
+ run: |
17
+ mkdir -p /home/build/.ssh
18
+ printf '%s' '${{ secrets.SSH_DEPLOYMENT_KEY }}' > /home/build/.ssh/id_rsa
19
+ printf '%s' '${{ secrets.KNOWN_HOSTS }}' > /home/build/.ssh/known_hosts
20
+ chmod 600 /home/build/.ssh/id_rsa
21
+
22
+ - name: Checkout Repository
23
+ uses: actions/checkout@v3
24
+ - name: Change owner of build output Folder
25
+ run: sudo chown build:build /workspace/DebianPackages/ && echo OK!
26
+
27
+ - name: Update NMU changelog
28
+ run: |
29
+ echo Setting environment Variables
30
+ export DEBFULLNAME=${{ github.actor }}
31
+ echo Debian Fullname: $DEBFULLNAME
32
+ export DEBEMAIL=${{ github.actor }}@perfact.de
33
+ echo Debian Email: $DEBEMAIL
34
+ debchange --nmu Automated build on commit: ${{ gitea.sha }}
35
+
36
+ - name: Update package sources
37
+ run: sudo apt update || true
38
+
39
+ - name: Install build dependencies
40
+ run: sudo apt build-dep -y .
41
+
42
+ - name: Build
43
+ run: dpkg-buildpackage
44
+
45
+ - name: Collect result files
46
+ run: |
47
+ rm -rf /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}/
48
+ mkdir -p /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}
49
+ cp /workspace/DebianPackages/*.buildinfo /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}/
50
+ cp /workspace/DebianPackages/*.changes /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}/
51
+ cp /workspace/DebianPackages/*.deb /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}/
52
+ cp /workspace/DebianPackages/*.dsc /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}/
53
+ cp /workspace/DebianPackages/*.tar.xz /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}/
54
+
55
+ - name: Output the result as artifact
56
+ uses: actions/upload-artifact@v3
57
+ with:
58
+ name: ${{ matrix.target }}
59
+ path: /workspace/outputs/${{ gitea.repository }}/${{ gitea.ref_name }}/${{ matrix.target }}/
60
+ overwrite: true
@@ -0,0 +1,31 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "[0-9]*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ with:
14
+ fetch-depth: 0
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.x"
20
+
21
+ - name: Install build dependencies
22
+ run: python -m pip install --upgrade build twine
23
+
24
+ - name: Build package
25
+ run: python -m build
26
+
27
+ - name: Publish to PyPI
28
+ env:
29
+ TWINE_USERNAME: __token__
30
+ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
31
+ run: twine upload dist/*
@@ -0,0 +1,22 @@
1
+ *.pyc
2
+ *.swp
3
+ perfact_dbschematools.egg-info
4
+ venv*
5
+ .tox
6
+ .coverage
7
+ __pycache__
8
+ build
9
+ dist
10
+ .temp-venv
11
+ .wheels
12
+ debian/perfact-dbschematools
13
+ debian/.debhelper
14
+ debian/perfact-dbschematools.substvars
15
+ debian/debhelper-build-stamp
16
+ debian/files
17
+ tags
18
+ tags.lock
19
+ tags.temp
20
+ *.orig
21
+ .pybuild
22
+ *.debhelper
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: perfact-dbschematools
3
+ Version: 26.5.0
4
+ Summary: Tools for deploying necessary schema changes for a perfactema database
5
+ Author: Viktor Dick
6
+ Author-email: Viktor Dick <viktor.dick@perfact.de>
7
+ License: GPL-2.0-or-later
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: POSIX :: Linux
10
+ Classifier: Topic :: Database
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: oyaml
14
+ Requires-Dist: pglast
15
+ Requires-Dist: psycopg2
16
+ Requires-Dist: perfact-dbutils
17
+
18
+ # PerFact DBSchemaTools
19
+
20
+ Tools for deploying necessary schema changes for a perfactema database.
21
+
22
+ It aims to gradually replace DatabaseModifications by a schema definition
23
+ delivered in the form of yaml files in a file system structure, so we don't
24
+ define the steps to perform to arrive at some required schema, but the target
25
+ schema itself. It also allows introspecting the current database and checking
26
+ which (additive) change are to be performed to arrive at the correct schema.
27
+
28
+ The maintainers of this project are:
29
+
30
+ - Alexander Rolfes <alexander.rolfes@perfact.de>
31
+ - Ján Jockusch <jan.jockusch@perfact.de>
32
+ - Viktor Dick <viktor.dick@perfact.de>
33
+
34
+ ## Technical details
35
+
36
+ The DBSchemaTools come bundled with an executable `perfact-dbschema` which is
37
+ available in `/usr/bin`. This allows several actions to be performed (check out
38
+ `--help`):
39
+ - `patch`: Compare the current DB against the definitions provided in the
40
+ schema definition paths and extend the current DB as required.
41
+ - `add`: Adds an entity to a schema definition path
42
+ - `dump`: Dumps the full database into a schema definition path. Currently only
43
+ for debugging.
44
+
45
+ Additionally, a wrapper `perfact-dbschema-add` is provided with a `sudoers`
46
+ file that allows the user `zope` to execute it as user `perfact` on a typical
47
+ PerFact system. This is intended to be used by the table manager while we
48
+ transition more and more functionality over.
49
+
50
+ On a PerFact template system, the package `perfact-dbutils-zope4` additionally
51
+ provides a wrapper `perfact-dbschema-patch`. This is also used by the
52
+ `zodbsync` configuration to make sure that any code deployment runs through the
53
+ three steps:
54
+ 1. Check the schema definitions as recognized by perfact-dbschematools and
55
+ execute them, before changing anything inside Zope.
56
+ 2. Play back `DatabaseModifications` and related paths, and trigger their
57
+ application.
58
+ 3. Play back any remaining code changes, i.e. the code that depends on the new
59
+ schema.
60
+
61
+ A **schema definition path** is usually something like
62
+ `/opt/perfact/dbutils-zoperepo/__schema__` or a similar path somewhere in
63
+ `/var/lib/perfact/zodbsync/layers` for an activated layer package. It contains
64
+ a folder structure mostly oriented along tables, containing YAML files (and in
65
+ the future probably also other file formats, when we include function
66
+ definitions) that describe the entities that we require to be present in the
67
+ database.
68
+
69
+ In preparation for a future situation where we can develop for multiple layers
70
+ on the same system, the main executable `perfact-dbschema` requires the path to
71
+ be explicitly named, making its arguments somewhat clumsy at times. Usually,
72
+ you should not have to interact with it directly, relying on the table manager
73
+ and on the wrapper `perfact-dbschema-patch` instead.
74
+
75
+ ## Usage from other packages
76
+
77
+ As of version 26.2.0, `perfact-dbschematools` no longer uses a virtual
78
+ environment and can therefore be imported in other Python packages. A package
79
+ that deploys some schema definitions that it requires to be executed to run can
80
+ therefore do something like this at startup:
81
+ ```
82
+ from perfact.dbschematools import patch
83
+ patch('/path/to/my/schema/definition', my_connection_string)
84
+ ```
85
+
86
+ ## Configuration
87
+
88
+ The default configuration file `/etc/pefact/dbschematools/config.yml` currently
89
+ only describes the database connection string.
90
+
91
+ ## FAQs
92
+
93
+ **I tried deploying a code state that uses schema definitions and it failed**
94
+
95
+ - Is `perfact-dbutils-zope4` up to date? If you deployed using the layer
96
+ package `perfact-zope-layers-complete`, the dependency should be set
97
+ correctly so the necessary versions are installed, but if you only deployed
98
+ using a `git` checkout, you will need to update the packages accordingly.
99
+ - Does the configuration of `perfact-dbschematools` contain the correct
100
+ connection string?
101
+ - If you skipped the failures and continued the deployment, but fixed the
102
+ cause, you can execute `perfact-dbschema-patch` to retry.
103
+ - Afterwards, you want to retry applying the `DatabaseModifications`.
104
+
105
+ **During development, a column I created should have a different type after all**
106
+
107
+ - Edit the file in `__schema__/tables/<table>/columns/<column>.yml`
108
+ - Execute `perfact-dbschema-patch`.
109
+ - If the column can not be converted automatically due to completely different
110
+ types, you will need to first delete the column manually.
@@ -0,0 +1,93 @@
1
+ # PerFact DBSchemaTools
2
+
3
+ Tools for deploying necessary schema changes for a perfactema database.
4
+
5
+ It aims to gradually replace DatabaseModifications by a schema definition
6
+ delivered in the form of yaml files in a file system structure, so we don't
7
+ define the steps to perform to arrive at some required schema, but the target
8
+ schema itself. It also allows introspecting the current database and checking
9
+ which (additive) change are to be performed to arrive at the correct schema.
10
+
11
+ The maintainers of this project are:
12
+
13
+ - Alexander Rolfes <alexander.rolfes@perfact.de>
14
+ - Ján Jockusch <jan.jockusch@perfact.de>
15
+ - Viktor Dick <viktor.dick@perfact.de>
16
+
17
+ ## Technical details
18
+
19
+ The DBSchemaTools come bundled with an executable `perfact-dbschema` which is
20
+ available in `/usr/bin`. This allows several actions to be performed (check out
21
+ `--help`):
22
+ - `patch`: Compare the current DB against the definitions provided in the
23
+ schema definition paths and extend the current DB as required.
24
+ - `add`: Adds an entity to a schema definition path
25
+ - `dump`: Dumps the full database into a schema definition path. Currently only
26
+ for debugging.
27
+
28
+ Additionally, a wrapper `perfact-dbschema-add` is provided with a `sudoers`
29
+ file that allows the user `zope` to execute it as user `perfact` on a typical
30
+ PerFact system. This is intended to be used by the table manager while we
31
+ transition more and more functionality over.
32
+
33
+ On a PerFact template system, the package `perfact-dbutils-zope4` additionally
34
+ provides a wrapper `perfact-dbschema-patch`. This is also used by the
35
+ `zodbsync` configuration to make sure that any code deployment runs through the
36
+ three steps:
37
+ 1. Check the schema definitions as recognized by perfact-dbschematools and
38
+ execute them, before changing anything inside Zope.
39
+ 2. Play back `DatabaseModifications` and related paths, and trigger their
40
+ application.
41
+ 3. Play back any remaining code changes, i.e. the code that depends on the new
42
+ schema.
43
+
44
+ A **schema definition path** is usually something like
45
+ `/opt/perfact/dbutils-zoperepo/__schema__` or a similar path somewhere in
46
+ `/var/lib/perfact/zodbsync/layers` for an activated layer package. It contains
47
+ a folder structure mostly oriented along tables, containing YAML files (and in
48
+ the future probably also other file formats, when we include function
49
+ definitions) that describe the entities that we require to be present in the
50
+ database.
51
+
52
+ In preparation for a future situation where we can develop for multiple layers
53
+ on the same system, the main executable `perfact-dbschema` requires the path to
54
+ be explicitly named, making its arguments somewhat clumsy at times. Usually,
55
+ you should not have to interact with it directly, relying on the table manager
56
+ and on the wrapper `perfact-dbschema-patch` instead.
57
+
58
+ ## Usage from other packages
59
+
60
+ As of version 26.2.0, `perfact-dbschematools` no longer uses a virtual
61
+ environment and can therefore be imported in other Python packages. A package
62
+ that deploys some schema definitions that it requires to be executed to run can
63
+ therefore do something like this at startup:
64
+ ```
65
+ from perfact.dbschematools import patch
66
+ patch('/path/to/my/schema/definition', my_connection_string)
67
+ ```
68
+
69
+ ## Configuration
70
+
71
+ The default configuration file `/etc/pefact/dbschematools/config.yml` currently
72
+ only describes the database connection string.
73
+
74
+ ## FAQs
75
+
76
+ **I tried deploying a code state that uses schema definitions and it failed**
77
+
78
+ - Is `perfact-dbutils-zope4` up to date? If you deployed using the layer
79
+ package `perfact-zope-layers-complete`, the dependency should be set
80
+ correctly so the necessary versions are installed, but if you only deployed
81
+ using a `git` checkout, you will need to update the packages accordingly.
82
+ - Does the configuration of `perfact-dbschematools` contain the correct
83
+ connection string?
84
+ - If you skipped the failures and continued the deployment, but fixed the
85
+ cause, you can execute `perfact-dbschema-patch` to retry.
86
+ - Afterwards, you want to retry applying the `DatabaseModifications`.
87
+
88
+ **During development, a column I created should have a different type after all**
89
+
90
+ - Edit the file in `__schema__/tables/<table>/columns/<column>.yml`
91
+ - Execute `perfact-dbschema-patch`.
92
+ - If the column can not be converted automatically due to completely different
93
+ types, you will need to first delete the column manually.
@@ -0,0 +1,3 @@
1
+ # FILE: bandit.yaml
2
+ assert_used:
3
+ skips: ['*_test.py', '*test_*.py']
@@ -0,0 +1,2 @@
1
+ # Connection string for connecting to the local database
2
+ connstr: dbname=perfactema user=zope application_name=dbschematools
@@ -0,0 +1 @@
1
+ zope ALL=(perfact) NOPASSWD:/usr/bin/perfact-dbschema-add
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/python3
2
+
3
+ # Wrapper for "perfact-dbschema add" that checks for an allowed path - because
4
+ # this is allowed to be called via sudo, we do not allow just any path to be
5
+ # passed.
6
+
7
+ import sys
8
+ import subprocess as sp
9
+
10
+ if __name__ == '__main__':
11
+ # For now, only the default path is allowed. We might want to read layer
12
+ # definitions once we allow creating code for different layers
13
+ if sys.argv[1] != '/opt/perfact/dbutils-zoperepo/__schema__':
14
+ raise ValueError("Path not allowed")
15
+ sp.run(['/usr/bin/perfact-dbschema', 'add']
16
+ + sys.argv[1:], check=True)
@@ -0,0 +1,152 @@
1
+ perfact-dbschematools (26.5.0) unstable; urgency=medium
2
+
3
+ [ Viktor Dick ]
4
+ * Add workflow to publish to pypi
5
+ * Switch to using ruff
6
+
7
+ -- Viktor Dick <viktor.dick@perfact.de> Tue, 12 May 2026 08:54:47 +0200
8
+
9
+ perfact-dbschematools (26.4.0) unstable; urgency=medium
10
+
11
+ [ Viktor Dick ]
12
+ * Add support for view definitions
13
+
14
+ [ Dionyssios Stamatis ]
15
+ * Normalize definitions of column defaults
16
+
17
+ -- Viktor Dick <viktor.dick@perfact.de> Fri, 17 Apr 2026 12:37:22 +0200
18
+
19
+ perfact-dbschematools (26.3.0) unstable; urgency=medium
20
+
21
+ [ Viktor Dick ]
22
+ * Keep defaults if the schema def of a column does not say anything about it
23
+
24
+ -- Viktor Dick <viktor.dick@perfact.de> Thu, 26 Feb 2026 14:07:44 +0100
25
+
26
+ perfact-dbschematools (26.2.1) unstable; urgency=medium
27
+
28
+ [ Viktor Dick ]
29
+ * Fix setup.cfg, which is read by jammy, to p.e. include the script
30
+
31
+ -- Viktor Dick <viktor.dick@perfact.de> Wed, 18 Feb 2026 07:05:44 +0100
32
+
33
+ perfact-dbschematools (26.2.0) unstable; urgency=medium
34
+
35
+ [ Viktor Dick ]
36
+ * Update documentation
37
+
38
+ [ Alexander Rolfes ]
39
+ * Correctly determine package version on build
40
+
41
+ -- Viktor Dick <viktor.dick@perfact.de> Wed, 11 Feb 2026 15:37:13 +0100
42
+
43
+ perfact-dbschematools (26.1.0) unstable; urgency=medium
44
+
45
+ [ Viktor Dick ]
46
+ * Add tox workflow
47
+ * Convert to system-wide dist-package
48
+
49
+ -- Viktor Dick <viktor.dick@perfact.de> Sat, 07 Feb 2026 13:06:27 +0100
50
+
51
+ perfact-dbschematools (26.0.2) unstable; urgency=medium
52
+
53
+ [ Dionyssios Stamatis ]
54
+ * Remove deprecated parameter from argparse
55
+
56
+ -- Viktor Dick <viktor.dick@perfact.de> Mon, 05 Jan 2026 12:39:35 +0100
57
+
58
+ perfact-dbschematools (26.0.1) unstable; urgency=medium
59
+
60
+ [ Viktor Dick ]
61
+ * Revert switch from virtualenv to real package - dependencies can not be
62
+ satisfied
63
+
64
+ -- Viktor Dick <viktor.dick@perfact.de> Mon, 05 Jan 2026 10:26:52 +0100
65
+
66
+ perfact-dbschematools (26.0.0) unstable; urgency=medium
67
+
68
+ [ Viktor Dick ]
69
+ * Avoid using virtualenv
70
+ * Always execute when calling patch, deprecating the --execute flag
71
+
72
+ -- Viktor Dick <viktor.dick@perfact.de> Mon, 05 Jan 2026 09:55:34 +0100
73
+
74
+ perfact-dbschematools (25.3.0) unstable; urgency=medium
75
+
76
+ [ Viktor Dick ]
77
+ * Fix applying patch where column default is to be removed
78
+
79
+ -- Viktor Dick <viktor.dick@perfact.de> Wed, 17 Dec 2025 08:29:50 +0100
80
+
81
+ perfact-dbschematools (25.2.0) unstable; urgency=medium
82
+
83
+ [ Viktor Dick ]
84
+ * Avoid unnecessary type changes for equivalent types
85
+
86
+ -- Viktor Dick <viktor.dick@perfact.de> Tue, 16 Dec 2025 15:44:51 +0100
87
+
88
+ perfact-dbschematools (25.1.0) unstable; urgency=medium
89
+
90
+ [ Viktor Dick ]
91
+ * Add tests
92
+ * Omit "null" as default for columns
93
+
94
+ -- Viktor Dick <viktor.dick@perfact.de> Sat, 13 Dec 2025 11:09:33 +0100
95
+
96
+ perfact-dbschematools (25.0.0) unstable; urgency=medium
97
+
98
+ [ Viktor Dick ]
99
+ * Improve API for columns:
100
+ - Default columns are implicitly assumed
101
+ - Column definitions are expected to be in {table}/columns/{column}.yml
102
+ instead of {table}/columns/{column}/def.yml
103
+ * Fix usage of logger outputs, avoiding deprecation warnings
104
+ * Fix dependency on psycopg, making this work for trixie
105
+ * Purge virtualenv before recreating it in postinst
106
+ * Return best-guess queries from "add" to apply the changes directly
107
+ * Add subcommand "dump" to store current schema
108
+
109
+ -- Viktor Dick <viktor.dick@perfact.de> Fri, 31 Oct 2025 13:26:37 +0100
110
+
111
+ perfact-dbschematools (23.0.3+nmu1) UNRELEASED; urgency=medium
112
+
113
+ [ Alexander Rolfes ]
114
+ * Add dependency on python3-yaml
115
+
116
+ -- Alexander Rolfes <alexander.rolfes@perfact.de> Tue, 09 Sep 2025 08:22:34 +0200
117
+
118
+ perfact-dbschematools (23.0.3) unstable; urgency=medium
119
+
120
+ [ Alexander Rolfes ]
121
+ * Include psycopg3 inside of the virtual env instead of relying on
122
+ a system package
123
+
124
+ -- Alexander Rolfes <alexander.rolfes@perfact.de> Mon, 11 Aug 2025 16:51:29 +0200
125
+
126
+ perfact-dbschematools (23.0.2) unstable; urgency=medium
127
+
128
+ [ Viktor Dick ]
129
+ * Actually check that layer config files are files before trying to open
130
+ them.
131
+
132
+ -- Viktor Dick <viktor.dick@perfact.de> Fri, 25 Jul 2025 08:26:03 +0200
133
+
134
+ perfact-dbschematools (23.0.1) unstable; urgency=medium
135
+
136
+ [ Viktor Dick ]
137
+ * Only check regular files for layer configs
138
+
139
+ -- Viktor Dick <viktor.dick@perfact.de> Tue, 22 Jul 2025 09:40:05 +0200
140
+
141
+ perfact-dbschematools (23.0.0) unstable; urgency=medium
142
+
143
+ [ Viktor Dick ]
144
+ * Use deprecated version spec in pyproject.toml for backwards compatibility
145
+
146
+ -- Viktor Dick <viktor.dick@perfact.de> Fri, 11 Jul 2025 14:11:38 +0200
147
+
148
+ perfact-dbschematools (0.1) UNRELEASED; urgency=medium
149
+
150
+ * Initial release.
151
+
152
+ -- Viktor Dick <viktor.dick@perfact.de> Fri, 30 May 2025 12:56:18 +0200
@@ -0,0 +1,32 @@
1
+ Source: perfact-dbschematools
2
+ Section: unknown
3
+ Priority: optional
4
+ Maintainer: Viktor Dick <viktor.dick@perfact.de>
5
+ Rules-Requires-Root: no
6
+ Build-Depends:
7
+ debhelper-compat (= 13),
8
+ dh-python,
9
+ python3,
10
+ python3-venv,
11
+ pybuild-plugin-pyproject,
12
+ python3-setuptools-scm,
13
+ Standards-Version: 4.6.2
14
+
15
+ Package: perfact-dbschematools
16
+ Architecture: all
17
+ Depends:
18
+ ${misc:Depends},
19
+ ${python3:Depends},
20
+ python3,
21
+ python3-venv,
22
+ python3-yaml,
23
+ python3-pglast,
24
+ perfact-pyoyaml,
25
+ python3-perfact,
26
+ python3-perfact-dbutils,
27
+ python3-psycopg2,
28
+ Conflicts:
29
+ perfact-dbutils-zope4 (<=26.0.0),
30
+ Description: Tools for deploying database schema changes.
31
+ It aims to gradually replace DatabaseModifications by a schema definition
32
+ delivered in the form of yaml files in a file system structure.
@@ -0,0 +1,13 @@
1
+ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2
+
3
+ Files: *
4
+ Copyright: 2002-2025, PerFact Innovation GmbH & Co. KG <info@perfact.de>
5
+ License: GPL-2+
6
+
7
+ License: GPL-2+
8
+ This program is free software; you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation; version 2 dated June, 1991, or (at
11
+ your option) any later version.
12
+ On Debian systems, the complete text of version 2 of the GNU General
13
+ Public License can be found in '/usr/share/common-licenses/GPL-2'.
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+ #
3
+ # Post-installation procedure.
4
+
5
+ set -e
6
+
7
+ case "$1" in
8
+ configure)
9
+ # Remove virtualenv from older version, not needed anymore
10
+ rm -rf /var/lib/perfact/dbschematools
11
+ ;;
12
+ abort-upgrade|abort-remove|abort-deconfigure)
13
+ ;;
14
+
15
+ *)
16
+ echo "postinst called with unknown argument '$1'" >&2
17
+ exit 1
18
+ ;;
19
+ esac
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/make -f
2
+
3
+ # See debhelper(7) (uncomment to enable).
4
+ # Output every command that modifies files on the build system.
5
+ #export DH_VERBOSE = 1
6
+
7
+ override_dh_auto_test:
8
+ tox
9
+
10
+ %:
11
+ dh $@ --with python3 --buildsystem=pybuild
@@ -0,0 +1 @@
1
+ 3.0 (native)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/python3
2
+ from .main import patch
3
+
4
+ __all__ = ["patch"]
@@ -0,0 +1,2 @@
1
+ alter table {tablename}
2
+ alter column {colname} set default {coldefault};
@@ -0,0 +1,2 @@
1
+ alter table {tablename}
2
+ alter column {colname} type {coltype};
@@ -0,0 +1,3 @@
1
+ alter table {tablename} add column if not exists
2
+ {colname} {coltype}
3
+ ;
@@ -0,0 +1,27 @@
1
+ do $$
2
+ declare
3
+ cur_type text;
4
+ begin
5
+ select
6
+ udt_name || coalesce('(' || character_maximum_length || ')', '')
7
+ into
8
+ cur_type
9
+ from information_schema.columns
10
+ where table_schema not in ('pg_catalog', 'information_schema', 'hist')
11
+ and table_name = '{tablename}'
12
+ and column_name = '{colname}'
13
+ ;
14
+
15
+ if cur_type is null then
16
+ -- Column does not exist yet
17
+ alter table {tablename} add column if not exists
18
+ {colname} {coltype}
19
+ ;
20
+ end if;
21
+
22
+ if cur_type::regtype != '{coltype}'::regtype then
23
+ alter table {tablename}
24
+ alter column {colname} type {coltype};
25
+ end if;
26
+ end
27
+ $$;
@@ -0,0 +1,20 @@
1
+ do $$
2
+ declare
3
+ cur_default text;
4
+ begin
5
+ select
6
+ column_default
7
+ into
8
+ cur_default
9
+ from information_schema.columns
10
+ where table_schema not in ('pg_catalog', 'information_schema', 'hist')
11
+ and table_name = '{tablename}'
12
+ and column_name = '{colname}'
13
+ ;
14
+
15
+ if cur_default is distinct from {coldefault_esc} then
16
+ alter table {tablename}
17
+ alter column {colname} set default {coldefault};
18
+ end if;
19
+ end
20
+ $$;
@@ -0,0 +1,21 @@
1
+ select
2
+ table_name collate "POSIX" as tablename,
3
+ column_name collate "POSIX" as name,
4
+ udt_name || coalesce('(' || character_maximum_length || ')', '') as type,
5
+ column_default as default
6
+
7
+ from information_schema.columns
8
+
9
+ where table_schema not in ('pg_catalog', 'information_schema', 'hist')
10
+ -- only valid table names
11
+ and table_name ~ '^[a-z0-9]+$'
12
+ -- no hist tables
13
+ and table_name !~ 'hist$'
14
+ -- only columns from base tables, not views
15
+ and table_name in (
16
+ select table_name
17
+ from information_schema.tables
18
+ where table_type = 'BASE TABLE'
19
+ and table_schema not in ('pg_catalog', 'information_schema', 'hist')
20
+ )
21
+ order by tablename, ordinal_position