asqueel-migration 0.1.2__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 (84) hide show
  1. asqueel_migration-0.1.2/.gitignore +150 -0
  2. asqueel_migration-0.1.2/CHANGELOG.md +31 -0
  3. asqueel_migration-0.1.2/LICENSE +201 -0
  4. asqueel_migration-0.1.2/NOTICE +11 -0
  5. asqueel_migration-0.1.2/PKG-INFO +274 -0
  6. asqueel_migration-0.1.2/README.md +207 -0
  7. asqueel_migration-0.1.2/assets/branding/asqueel-migration-inverse.svg +7 -0
  8. asqueel_migration-0.1.2/assets/branding/asqueel-migration-primary.svg +7 -0
  9. asqueel_migration-0.1.2/assets/branding/asqueel-monogram.svg +7 -0
  10. asqueel_migration-0.1.2/docs/_static/brand.css +31 -0
  11. asqueel_migration-0.1.2/docs/conf.py +57 -0
  12. asqueel_migration-0.1.2/docs/index.rst +19 -0
  13. asqueel_migration-0.1.2/docs/legacy_test_alignment.md +43 -0
  14. asqueel_migration-0.1.2/docs/producer_guide.md +414 -0
  15. asqueel_migration-0.1.2/pyproject.toml +163 -0
  16. asqueel_migration-0.1.2/scripts/check_distribution.py +25 -0
  17. asqueel_migration-0.1.2/src/asqueel_migration/__init__.py +81 -0
  18. asqueel_migration-0.1.2/src/asqueel_migration/adapters/__init__.py +26 -0
  19. asqueel_migration-0.1.2/src/asqueel_migration/adapters/mssql_adapter.py +277 -0
  20. asqueel_migration-0.1.2/src/asqueel_migration/adapters/mysql_adapter.py +283 -0
  21. asqueel_migration-0.1.2/src/asqueel_migration/adapters/pg_adapter.py +244 -0
  22. asqueel_migration-0.1.2/src/asqueel_migration/adapters/sqlite_adapter.py +333 -0
  23. asqueel_migration-0.1.2/src/asqueel_migration/app.py +229 -0
  24. asqueel_migration-0.1.2/src/asqueel_migration/cli.py +136 -0
  25. asqueel_migration-0.1.2/src/asqueel_migration/command_builder.py +1018 -0
  26. asqueel_migration-0.1.2/src/asqueel_migration/database.py +196 -0
  27. asqueel_migration-0.1.2/src/asqueel_migration/diff_engine.py +220 -0
  28. asqueel_migration-0.1.2/src/asqueel_migration/editor_service.py +65 -0
  29. asqueel_migration-0.1.2/src/asqueel_migration/exceptions.py +63 -0
  30. asqueel_migration-0.1.2/src/asqueel_migration/executor.py +364 -0
  31. asqueel_migration-0.1.2/src/asqueel_migration/json_producer.py +177 -0
  32. asqueel_migration-0.1.2/src/asqueel_migration/migrator.py +321 -0
  33. asqueel_migration-0.1.2/src/asqueel_migration/py.typed +0 -0
  34. asqueel_migration-0.1.2/src/asqueel_migration/readers/__init__.py +34 -0
  35. asqueel_migration-0.1.2/src/asqueel_migration/readers/base_reader.py +299 -0
  36. asqueel_migration-0.1.2/src/asqueel_migration/readers/mssql_reader.py +457 -0
  37. asqueel_migration-0.1.2/src/asqueel_migration/readers/mysql_reader.py +372 -0
  38. asqueel_migration-0.1.2/src/asqueel_migration/readers/pg_reader.py +442 -0
  39. asqueel_migration-0.1.2/src/asqueel_migration/readers/sqlite_reader.py +319 -0
  40. asqueel_migration-0.1.2/src/asqueel_migration/schemas/sql_model-1.0.xsd +210 -0
  41. asqueel_migration-0.1.2/src/asqueel_migration/schemas/structure-1.0.json +239 -0
  42. asqueel_migration-0.1.2/src/asqueel_migration/structures.py +459 -0
  43. asqueel_migration-0.1.2/src/asqueel_migration/validation.py +275 -0
  44. asqueel_migration-0.1.2/src/asqueel_migration/writers/__init__.py +32 -0
  45. asqueel_migration-0.1.2/src/asqueel_migration/writers/base_writer.py +353 -0
  46. asqueel_migration-0.1.2/src/asqueel_migration/writers/mssql_writer.py +323 -0
  47. asqueel_migration-0.1.2/src/asqueel_migration/writers/mysql_writer.py +411 -0
  48. asqueel_migration-0.1.2/src/asqueel_migration/writers/pg_writer.py +525 -0
  49. asqueel_migration-0.1.2/src/asqueel_migration/writers/sqlite_writer.py +234 -0
  50. asqueel_migration-0.1.2/src/asqueel_migration/xml_producer.py +356 -0
  51. asqueel_migration-0.1.2/tests/__init__.py +0 -0
  52. asqueel_migration-0.1.2/tests/conftest.py +63 -0
  53. asqueel_migration-0.1.2/tests/support/__init__.py +0 -0
  54. asqueel_migration-0.1.2/tests/support/migration_base.py +96 -0
  55. asqueel_migration-0.1.2/tests/support/mssql_database.py +130 -0
  56. asqueel_migration-0.1.2/tests/support/mysql_database.py +133 -0
  57. asqueel_migration-0.1.2/tests/support/orm_producer.py +466 -0
  58. asqueel_migration-0.1.2/tests/support/pg_database.py +42 -0
  59. asqueel_migration-0.1.2/tests/support/sqlite_database.py +33 -0
  60. asqueel_migration-0.1.2/tests/support/sqltools.py +21 -0
  61. asqueel_migration-0.1.2/tests/test_capabilities.py +173 -0
  62. asqueel_migration-0.1.2/tests/test_cli.py +96 -0
  63. asqueel_migration-0.1.2/tests/test_connection_error.py +117 -0
  64. asqueel_migration-0.1.2/tests/test_editor_app.py +192 -0
  65. asqueel_migration-0.1.2/tests/test_editor_service.py +59 -0
  66. asqueel_migration-0.1.2/tests/test_execution_atomicity.py +155 -0
  67. asqueel_migration-0.1.2/tests/test_executor_column_order.py +105 -0
  68. asqueel_migration-0.1.2/tests/test_index_roundtrip.py +126 -0
  69. asqueel_migration-0.1.2/tests/test_json_producer.py +326 -0
  70. asqueel_migration-0.1.2/tests/test_migration_modes_pg.py +323 -0
  71. asqueel_migration-0.1.2/tests/test_migration_mssql.py +262 -0
  72. asqueel_migration-0.1.2/tests/test_migration_mysql.py +234 -0
  73. asqueel_migration-0.1.2/tests/test_migration_pg.py +586 -0
  74. asqueel_migration-0.1.2/tests/test_migration_sqlite.py +189 -0
  75. asqueel_migration-0.1.2/tests/test_mssql_writer.py +199 -0
  76. asqueel_migration-0.1.2/tests/test_mysql_writer.py +156 -0
  77. asqueel_migration-0.1.2/tests/test_pg_adapter.py +40 -0
  78. asqueel_migration-0.1.2/tests/test_regressions.py +253 -0
  79. asqueel_migration-0.1.2/tests/test_size_normalization.py +91 -0
  80. asqueel_migration-0.1.2/tests/test_sqlite_writer.py +137 -0
  81. asqueel_migration-0.1.2/tests/test_todo_features.py +69 -0
  82. asqueel_migration-0.1.2/tests/test_validation.py +154 -0
  83. asqueel_migration-0.1.2/tests/test_wave0_pg.py +164 -0
  84. asqueel_migration-0.1.2/tests/test_xml_producer.py +213 -0
@@ -0,0 +1,150 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Unit test / coverage reports
34
+ htmlcov/
35
+ .tox/
36
+ .nox/
37
+ .coverage
38
+ .coverage.*
39
+ .cache
40
+ nosetests.xml
41
+ coverage.xml
42
+ *.cover
43
+ *.py,cover
44
+ .hypothesis/
45
+ .pytest_cache/
46
+ cover/
47
+
48
+ # Translations
49
+ *.mo
50
+ *.pot
51
+
52
+ # Django stuff:
53
+ *.log
54
+ local_settings.py
55
+ db.sqlite3
56
+ db.sqlite3-journal
57
+
58
+ # Flask stuff:
59
+ instance/
60
+ .webassets-cache
61
+
62
+ # Scrapy stuff:
63
+ .scrapy
64
+
65
+ # Sphinx documentation
66
+ docs/_build/
67
+
68
+ # PyBuilder
69
+ .pybuilder/
70
+ target/
71
+
72
+ # Jupyter Notebook
73
+ .ipynb_checkpoints
74
+
75
+ # IPython
76
+ profile_default/
77
+ ipython_config.py
78
+
79
+ # pyenv
80
+ .python-version
81
+
82
+ # pipenv
83
+ Pipfile.lock
84
+
85
+ # poetry
86
+ poetry.lock
87
+
88
+ # pdm
89
+ .pdm.toml
90
+
91
+ # PEP 582
92
+ __pypackages__/
93
+
94
+ # Celery stuff
95
+ celerybeat-schedule
96
+ celerybeat.pid
97
+
98
+ # SageMath parsed files
99
+ *.sage.py
100
+
101
+ # Environments
102
+ .env
103
+ .venv
104
+ env/
105
+ venv/
106
+ ENV/
107
+ env.bak/
108
+ venv.bak/
109
+
110
+ # Spyder project settings
111
+ .spyderproject
112
+ .spyproject
113
+
114
+ # Rope project settings
115
+ .ropeproject
116
+
117
+ # mkdocs documentation
118
+ /site
119
+
120
+ # mypy
121
+ .mypy_cache/
122
+ .dmypy.json
123
+ dmypy.json
124
+
125
+ # ruff
126
+ .ruff_cache/
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # pytype static type analyzer
132
+ .pytype/
133
+
134
+ # Cython debug symbols
135
+ cython_debug/
136
+
137
+ # IDEs
138
+ .vscode/
139
+ .idea/
140
+ *.swp
141
+ *.swo
142
+ *~
143
+
144
+ # OS
145
+ .DS_Store
146
+ Thumbs.db
147
+
148
+ # Temporary files
149
+ temp/*
150
+ !temp/.gitignore
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ ## 0.1.2 (unreleased)
4
+
5
+ - Rename the distribution, Python package and CLI to Asqueel Migration.
6
+ - Retain all fixes from 0.1.1; prepare GitHub Trusted Publishing for the new name.
7
+
8
+ ## 0.1.1 — 2026-09-29
9
+
10
+ - Preserve added and changed columns before primary-key rebuilds, retaining
11
+ dialect-specific SQL assembly (#10, #12; legacy genropy/genropy#1194).
12
+ - Normalize legacy varchar min:max sizes in JSON and XML producers so
13
+ repeated schema comparisons converge after migration (#11, #13).
14
+ - Align regression coverage with legacy develop, including varchar widening
15
+ on primary-key columns, and document intentional test exclusions.
16
+
17
+ ## 0.1.0 — 2026-09-29
18
+
19
+ First public Alpha release.
20
+
21
+ - Compare normalized database schemas and generate additive migrations for
22
+ PostgreSQL, SQLite, MySQL and SQL Server, with JSON and XML producers.
23
+ - Apply DDL atomically where supported; MySQL reports best-effort execution.
24
+ - Preserve authored index names and PostgreSQL descending column order.
25
+ Quote and escape index identifiers and handle schema-aware index rebuilds
26
+ and dialect-specific renames (issues #8 and #9).
27
+ - Offer an optional localhost-only HTTP/MCP editor built on Kajenn 0.1.
28
+ Applying migrations remains REST-only.
29
+
30
+ The API is still evolving. Renames are not inferred and database-only objects
31
+ are retained by default. See the producer guide for dialect limitations.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Softwell S.r.l.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,11 @@
1
+ asqueel-migration
2
+ Copyright 2025 Softwell S.r.l.
3
+
4
+ This product includes software developed at
5
+ Softwell S.r.l. (https://www.softwell.it/).
6
+
7
+ This project was originally developed as part of the Genropy framework
8
+ and has been extracted and relicensed to Apache License, Version 2.0
9
+ as part of the Genro Modules ecosystem.
10
+
11
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.5
2
+ Name: asqueel-migration
3
+ Version: 0.1.2
4
+ Summary: Database schema migration engine - compares desired structure with actual database and generates SQL commands
5
+ Project-URL: Homepage, https://github.com/asqueel-org/asqueel-migration
6
+ Project-URL: Documentation, https://github.com/asqueel-org/asqueel-migration/tree/main/docs
7
+ Project-URL: Repository, https://github.com/asqueel-org/asqueel-migration
8
+ Project-URL: Issues, https://github.com/asqueel-org/asqueel-migration/issues
9
+ Author: Genropy Team
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: database,ddl,diff,genro,genropy,migration,postgresql,schema,sql,sqlite
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.10
26
+ Requires-Dist: dictdiffer>=0.9.0
27
+ Provides-Extra: all
28
+ Requires-Dist: jsonschema>=4.18; extra == 'all'
29
+ Requires-Dist: mypy>=1.0; extra == 'all'
30
+ Requires-Dist: myst-parser>=4.0.0; extra == 'all'
31
+ Requires-Dist: psycopg[binary]>=3.1.0; extra == 'all'
32
+ Requires-Dist: pytest-cov>=4.0; extra == 'all'
33
+ Requires-Dist: pytest-sugar>=1.0; extra == 'all'
34
+ Requires-Dist: pytest>=7.0; extra == 'all'
35
+ Requires-Dist: ruff>=0.1.0; extra == 'all'
36
+ Requires-Dist: sphinx-autodoc-typehints>=3.0.0; extra == 'all'
37
+ Requires-Dist: sphinx-rtd-theme>=3.0.0; extra == 'all'
38
+ Requires-Dist: sphinx>=8.0.0; extra == 'all'
39
+ Requires-Dist: sphinxcontrib-mermaid>=1.0.0; extra == 'all'
40
+ Requires-Dist: testing-postgresql>=1.3; extra == 'all'
41
+ Provides-Extra: app
42
+ Requires-Dist: genro-routes>=0.30.0; extra == 'app'
43
+ Requires-Dist: kajenn<0.2.0,>=0.1.0; extra == 'app'
44
+ Provides-Extra: dev
45
+ Requires-Dist: jsonschema>=4.18; extra == 'dev'
46
+ Requires-Dist: mypy>=1.0; extra == 'dev'
47
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
48
+ Requires-Dist: pytest-sugar>=1.0; extra == 'dev'
49
+ Requires-Dist: pytest>=7.0; extra == 'dev'
50
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
51
+ Requires-Dist: testing-postgresql>=1.3; extra == 'dev'
52
+ Provides-Extra: docs
53
+ Requires-Dist: myst-parser>=4.0.0; extra == 'docs'
54
+ Requires-Dist: sphinx-autodoc-typehints>=3.0.0; extra == 'docs'
55
+ Requires-Dist: sphinx-rtd-theme>=3.0.0; extra == 'docs'
56
+ Requires-Dist: sphinx>=8.0.0; extra == 'docs'
57
+ Requires-Dist: sphinxcontrib-mermaid>=1.0.0; extra == 'docs'
58
+ Provides-Extra: mssql
59
+ Requires-Dist: pymssql; extra == 'mssql'
60
+ Provides-Extra: mysql
61
+ Requires-Dist: pymysql; extra == 'mysql'
62
+ Provides-Extra: postgresql
63
+ Requires-Dist: psycopg[binary]>=3.1.0; extra == 'postgresql'
64
+ Provides-Extra: validation
65
+ Requires-Dist: jsonschema>=4.18; extra == 'validation'
66
+ Description-Content-Type: text/markdown
67
+
68
+ # Asqueel Migration
69
+
70
+ ![Asqueel Migration](https://raw.githubusercontent.com/asqueel-org/asqueel-migration/main/assets/branding/asqueel-migration-primary.svg)
71
+
72
+ **Database schema migration engine** — compare a desired database
73
+ structure against a live database and generate (or apply) the SQL
74
+ commands that align them.
75
+
76
+ ORM-agnostic by design: the library never reads your model. You
77
+ describe the database in a normalized JSON contract — directly, or
78
+ through the friendlier **human JSON** / **XML** external formats — and
79
+ the engine does the rest: introspection, diff, DDL generation,
80
+ execution.
81
+
82
+ > Status: **Alpha** — API may change.
83
+
84
+ ## Features
85
+
86
+ - **Four dialects**: PostgreSQL (primary), SQLite, MySQL, MSSQL — one
87
+ reader/writer/adapter trio per dialect, capability-gated.
88
+ - **Two equivalent external formats**: human JSON and XSD-validated
89
+ XML; the same model in either compiles to the identical internal
90
+ structure.
91
+ - **Deterministic entity matching**: FK/UNIQUE/index names are
92
+ structural hashes computed from schema + table + columns, so
93
+ renaming never causes spurious diffs.
94
+ - **Additive compatibility check**: success means the database can host the
95
+ application without further additive changes, not that both structures are
96
+ identical. Extra database objects are preserved; renames are never inferred.
97
+ - **Safe by default**: destructive commands (DROP) are disabled unless
98
+ explicitly enabled; type conversions can be forced and backed up.
99
+ - **Minimal runtime dependencies**: `dictdiffer`, plus the DB driver
100
+ of your dialect as an optional extra.
101
+
102
+ ## Install
103
+
104
+ Install from PyPI:
105
+
106
+ ```bash
107
+ pip install "asqueel-migration[postgresql]"
108
+ ```
109
+
110
+ Extras: `postgresql` (psycopg 3), `mysql` (PyMySQL), `mssql`
111
+ (pymssql), `validation` (jsonschema), `docs`, `dev`, `all`.
112
+ SQLite needs no extra (stdlib driver).
113
+
114
+ ## Quickstart
115
+
116
+ ```python
117
+ from asqueel_migration import (
118
+ JsonStructureProducer, PgDatabase, SqlMigrator, StructureValidator,
119
+ )
120
+
121
+ model = {
122
+ "db": "mydb",
123
+ "schemas": [
124
+ {"name": "public", "tables": [
125
+ {"name": "author", "pkey": "id", "columns": [
126
+ {"name": "id", "dtype": "serial"},
127
+ {"name": "name", "dtype": "A", "size": "0:120",
128
+ "notnull": True},
129
+ ]},
130
+ ]},
131
+ ],
132
+ }
133
+
134
+ structure = JsonStructureProducer(model).get_json_struct()
135
+
136
+ db = PgDatabase({"dbname": "mydb", "host": "localhost"},
137
+ application_schemas=["public"])
138
+ migrator = SqlMigrator(db)
139
+ migrator.ormStructure = StructureValidator().validate(structure)
140
+ migrator.prepareMigrationCommands()
141
+ print(migrator.getChanges()) # review the SQL...
142
+ # migrator.applyChanges() # ...or apply it
143
+ ```
144
+
145
+ Swap `PgDatabase` for `SqliteDatabase`, `MysqlDatabase` or
146
+ `MssqlDatabase` for the other dialects.
147
+
148
+ ## Describing the database
149
+
150
+ Three input formats, from the friendliest to the most technical:
151
+
152
+ 1. **Human JSON** — readable JSON with names and lists, compiled by
153
+ `JsonStructureProducer` (above).
154
+ 2. **XML** — the same information validated by the packaged XSD
155
+ (`sql_model-1.0.xsd`), ideal for editors and GUIs; compiled by
156
+ `XmlStructureProducer`. The inverse `struct_to_xml()` turns an
157
+ introspected database back into editable XML.
158
+ 3. **Normalized JSON** — the internal contract, built directly with
159
+ the `new_*_item` factories (the route an ORM extractor takes).
160
+
161
+ The complete format reference — columns, dtypes, foreign keys
162
+ (including multi-column), constraints, indexes with per-column sort
163
+ order and WITH options, extensions, event triggers — is in the
164
+ [Producer Guide](https://asqueel-migration.readthedocs.io), also
165
+ available as [docs/producer_guide.md](docs/producer_guide.md).
166
+
167
+ ## How it works
168
+
169
+ ```text
170
+ your model ──(producer)──► normalized JSON ──┐
171
+ ├──► diff ──► SQL commands ──► apply
172
+ live database ──(reader)──► normalized JSON ─┘
173
+ ```
174
+
175
+ Both sides project to the same normalized JSON (hierarchy:
176
+ `root → schemas → tables → columns/relations/constraints/indexes`,
177
+ each entity carrying `entity`, `entity_name`, `attributes`). The diff
178
+ engine (`dictdiffer`) emits added/changed/removed events; the command
179
+ builder turns them into dialect-specific DDL; the executor assembles
180
+ and applies it. The JSON Schema of the contract is packaged as
181
+ `structure-1.0.json`.
182
+
183
+ ## Execution safety and recovery
184
+
185
+ `applyChanges()` is atomic by default where the generated DDL supports a
186
+ transaction. PostgreSQL, SQLite and SQL Server execute extensions and all
187
+ structural changes as one DDL unit. MySQL runs best-effort because its DDL can
188
+ implicitly commit; `applyChanges()` records an explicit warning and returns
189
+ `best_effort: true`.
190
+
191
+ Database creation is always a separate manager operation and cannot be part of
192
+ the target database transaction. If creating a new database succeeds but its
193
+ DDL later fails, the empty or partially initialized database remains, while the
194
+ transactional DDL unit is rolled back where supported.
195
+
196
+ Every failure stops execution immediately and raises
197
+ `MigrationExecutionError`. Its `phase`, `rolled_back` and
198
+ `partial_state_possible` attributes describe the outcome. The same invocation
199
+ does not try to repair or reanalyse the database. Run the migration again: it
200
+ re-introspects the current database and generates only the residual additive
201
+ changes. Objects already created are retained; no DROP or rename is inferred.
202
+
203
+ | Dialect | Default DDL mode | Failure in the DDL unit |
204
+ | --- | --- | --- |
205
+ | PostgreSQL | One transaction | Rolled back |
206
+ | SQLite | One transaction on the attached connection | Rolled back on an ordinary execution error; crash-level atomicity across multiple attached files depends on SQLite journal configuration |
207
+ | SQL Server | One transaction for the DDL generated by this library | Rolled back |
208
+ | MySQL | Best-effort, explicit warning | Earlier statements may remain committed |
209
+
210
+ ## Local development editor
211
+
212
+ The optional HTTP/MCP editor is a **local development tool** and requires
213
+ Python 3.11 or newer (the core library continues to support Python 3.10). It is
214
+ not a remotely deployable administration service and has no user-management
215
+ system. Start it on the loopback interface (the CLI default):
216
+
217
+ ```bash
218
+ pip install -e ".[app,postgresql]"
219
+ kajenn serve application=src/asqueel_migration/app.py:EditorApp \
220
+ --host 127.0.0.1 --port 8000
221
+ ```
222
+
223
+ The `app` extra uses Kajenn, the successor of genro-asgi. The editor is
224
+ verified against the published Kajenn 0.1.0 and development commit
225
+ `5b460b58f4bdb3a32ad94eecbf99a2e4510fe8fa`, with Bag/Builders 0.27.0,
226
+ TYTX 0.16.0, Routes 0.30.0 and Storage 0.8.1. Kajenn is constrained to the
227
+ 0.1 series while its API evolves; transitive dependencies are not locked.
228
+ Run `tests/test_editor_app.py` before advancing that range. For local Kajenn
229
+ development, install the desired checkout explicitly after this extra
230
+ (`python -m pip install -e /path/to/kajenn`). The core and database CLI do not
231
+ depend on Kajenn.
232
+
233
+ The application also checks the peer address and rejects non-loopback clients,
234
+ even if it is accidentally bound to another interface. `/introspect`,
235
+ `/migrate` and `/apply` accept POST requests with an `application/json` body
236
+ only. Query parameters are rejected so database passwords never enter URLs or
237
+ access logs, and operation errors redact the supplied password.
238
+
239
+ `/migrate` is the dry-run; `/apply` is the separate, deliberate execution
240
+ operation and remains REST-only. The editor follows additive compatibility:
241
+ database-only objects are retained, with no inferred rename or implicit DROP.
242
+
243
+ The XML is trusted developer input. Native SQL fields such as `sql_type`,
244
+ `sqldefault`, `extra_sql` and CHECK expressions can intentionally contain SQL;
245
+ do not open the editor to untrusted files or expose it through a network proxy.
246
+
247
+ ## Modules
248
+
249
+ | Module | Responsibility |
250
+ | --- | --- |
251
+ | `structures.py` | Contract constants, entity factories, name hashing |
252
+ | `validation.py` | `StructureValidator` — JSON Schema + semantic checks |
253
+ | `json_producer.py` | Human JSON → normalized JSON |
254
+ | `xml_producer.py` | XML → normalized JSON, and back (`struct_to_xml`) |
255
+ | `editor_service.py` | DB ↔ XML round-trip service for editors |
256
+ | `diff_engine.py` | Structure comparison → typed events |
257
+ | `command_builder.py` | Events → SQL command fragments |
258
+ | `executor.py` | SQL assembly, execution, backup verification |
259
+ | `migrator.py` | `SqlMigrator` — the orchestrator |
260
+ | `database.py` | Abstract `Database` / adapter interfaces |
261
+ | `readers/` | Per-dialect introspection (live DB → normalized JSON) |
262
+ | `writers/` | Per-dialect DDL generation |
263
+ | `adapters/` | Concrete `Database`/adapter pairs per dialect |
264
+
265
+ ## Documentation
266
+
267
+ Full documentation on
268
+ [Read the Docs](https://asqueel-migration.readthedocs.io).
269
+ Design notes and milestones live in [roadmap/](roadmap/).
270
+
271
+ ## License
272
+
273
+ Apache License 2.0 — Copyright Softwell S.r.l.
274
+ See [LICENSE](LICENSE) and [NOTICE](NOTICE).