half-orm-dev 1.1.0a1__tar.gz → 2.0.0a1__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.
- {half_orm_dev-1.1.0a1/half_orm_dev.egg-info → half_orm_dev-2.0.0a1}/PKG-INFO +6 -9
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/README.md +2 -2
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/migrate.py +54 -36
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/main.py +41 -4
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/database.py +14 -2
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/file_executor.py +7 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migration_manager.py +52 -33
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/0/17/4/00_toml_dict_format.py +1 -4
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/modules.py +201 -32
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/release_file.py +1 -5
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/release_manager.py +103 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/repo.py +9 -3
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/pyproject.toml +2 -3
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/utils.py +24 -0
- half_orm_dev-2.0.0a1/half_orm_dev/version.txt +1 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1/half_orm_dev.egg-info}/PKG-INFO +6 -9
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev.egg-info/SOURCES.txt +0 -1
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev.egg-info/requires.txt +1 -4
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/pyproject.toml +16 -4
- half_orm_dev-1.1.0a1/half_orm_dev/version.txt +0 -1
- half_orm_dev-1.1.0a1/setup.py +0 -84
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/AUTHORS +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/LICENSE +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/__init__.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/_bootstrap_runner.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/__init__.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/__init__.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/apply.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/check.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/clone.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/init.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/patch.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/recover.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/release.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/restore.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/revert_migration.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/rollback.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/set_git_origin.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/sync.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/todo.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/undo.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli/commands/upgrade.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/cli_extension.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/decorators.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/hgit.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/0/17/1/00_move_to_hop.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/0/17/1/01_txt_to_toml.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/0/17/4/02_move_patches_to_subdirs.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/0/17/5/01_update_pyproject_dependency.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/0/18/0/00_add_async_support.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/0/18/0/01_update_default_tests.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/1/0/0/a20/01_update_gitignore.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/1/0/0/a33/00_metadata_to_data_sql.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/1/0/0/a35/00_drop_stale_release_schemas.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/1/0/0/a36/00_drop_release_schemas.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/migrations/hop/BREAKING_CHANGES-1.0.0.md +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/patch_manager.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/patch_validator.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/patches/0/1/0/00_half_orm_meta.database.sql +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/patches/0/1/0/01_alter_half_orm_meta.hop_release.sql +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/patches/0/1/0/02_half_orm_meta.view.hop_penultimate_release.sql +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/patches/log +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/patches/sql/half_orm_meta.sql +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/py.typed +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/scripts/repair-metadata.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/.gitignore +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/MANIFEST.in +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/README +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/conftest_template +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/git-hooks/pre-commit +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/git-hooks/pre-push +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/git-hooks/prepare-commit-msg +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/git-hooks/reference-transaction +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/init_module_template +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/module_template_1 +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/module_template_2 +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/module_template_3 +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/relation_test +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/sql_adapter +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/templates/warning +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev/venv_setup.py +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev.egg-info/dependency_links.txt +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev.egg-info/entry_points.txt +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/half_orm_dev.egg-info/top_level.txt +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/setup.cfg +0 -0
- {half_orm_dev-1.1.0a1 → half_orm_dev-2.0.0a1}/tests/test_bootstrap_runner.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: half_orm_dev
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0a1
|
|
4
4
|
Summary: half_orm development Framework.
|
|
5
5
|
Author-email: Joël Maïzi <joel.maizi@collorg.org>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -9,13 +9,12 @@ Keywords: postgres,relation-object mapping
|
|
|
9
9
|
Classifier: Development Status :: 3 - Alpha
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: Topic :: Software Development :: Build Tools
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
-
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
17
|
+
Requires-Python: >=3.11
|
|
19
18
|
Description-Content-Type: text/markdown
|
|
20
19
|
License-File: LICENSE
|
|
21
20
|
License-File: AUTHORS
|
|
@@ -25,11 +24,9 @@ Requires-Dist: packaging
|
|
|
25
24
|
Requires-Dist: pydash
|
|
26
25
|
Requires-Dist: pytest
|
|
27
26
|
Requires-Dist: pytest-asyncio
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist: tomli>=2.0.0; python_version < "3.11"
|
|
27
|
+
Requires-Dist: half-orm<3,>=2.0.0
|
|
30
28
|
Requires-Dist: tomli_w>=1.0.0
|
|
31
29
|
Dynamic: license-file
|
|
32
|
-
Dynamic: requires-dist
|
|
33
30
|
|
|
34
31
|
# half-orm-dev
|
|
35
32
|
|
|
@@ -39,7 +36,7 @@ Dynamic: requires-dist
|
|
|
39
36
|
|
|
40
37
|
**Git-centric patch management and PostgreSQL database versioning for half-orm projects**
|
|
41
38
|
|
|
42
|
-
[](https://www.python.org/downloads/)
|
|
43
40
|
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
44
41
|
[](https://github.com/half-orm/half-orm)
|
|
45
42
|
[](https://pepy.tech/projects/half-orm-dev)
|
|
@@ -120,7 +117,7 @@ half_orm dev patch merge
|
|
|
120
117
|
|
|
121
118
|
### Prerequisites
|
|
122
119
|
|
|
123
|
-
- **Python**: [Active versions](https://devguide.python.org/versions/) (currently 3.
|
|
120
|
+
- **Python**: [Active versions](https://devguide.python.org/versions/) (currently 3.11+)
|
|
124
121
|
- **PostgreSQL**: [Supported versions](https://www.postgresql.org/support/versioning/) (currently 13+)
|
|
125
122
|
- **Git** for version control
|
|
126
123
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
**Git-centric patch management and PostgreSQL database versioning for half-orm projects**
|
|
8
8
|
|
|
9
|
-
[](https://www.python.org/downloads/)
|
|
10
10
|
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
11
11
|
[](https://github.com/half-orm/half-orm)
|
|
12
12
|
[](https://pepy.tech/projects/half-orm-dev)
|
|
@@ -87,7 +87,7 @@ half_orm dev patch merge
|
|
|
87
87
|
|
|
88
88
|
### Prerequisites
|
|
89
89
|
|
|
90
|
-
- **Python**: [Active versions](https://devguide.python.org/versions/) (currently 3.
|
|
90
|
+
- **Python**: [Active versions](https://devguide.python.org/versions/) (currently 3.11+)
|
|
91
91
|
- **PostgreSQL**: [Supported versions](https://www.postgresql.org/support/versioning/) (currently 13+)
|
|
92
92
|
- **Git** for version control
|
|
93
93
|
|
|
@@ -7,10 +7,61 @@ is newer than the repository's hop_version in .hop/config.
|
|
|
7
7
|
|
|
8
8
|
import click
|
|
9
9
|
from half_orm_dev.repo import Repo, RepoError
|
|
10
|
-
from half_orm_dev.migration_manager import
|
|
10
|
+
from half_orm_dev.migration_manager import (
|
|
11
|
+
MigrationManager, HALF_ORM_BREAKING_CHANGES_URL)
|
|
11
12
|
from half_orm import utils
|
|
12
13
|
|
|
13
14
|
|
|
15
|
+
def announce_breaking_changes(repo, config_version: str, installed_version: str) -> bool:
|
|
16
|
+
"""Say what a migration breaks, before it is confirmed.
|
|
17
|
+
|
|
18
|
+
Two kinds of breaking change, shown differently:
|
|
19
|
+
|
|
20
|
+
* half-orm's, when its major version changes: what the application's
|
|
21
|
+
code must change. They are documented on half-orm's site, so a link
|
|
22
|
+
is enough -- migrating happens on a development machine.
|
|
23
|
+
* half_orm_dev's: what the migration about to run does to the
|
|
24
|
+
repository. Shown in full, since that is what is being confirmed.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
True when there was something to announce, and the migration calls
|
|
28
|
+
for an explicit "yes" rather than a y/n.
|
|
29
|
+
"""
|
|
30
|
+
mgr = MigrationManager(repo)
|
|
31
|
+
major_change = mgr.half_orm_major_change(config_version, installed_version)
|
|
32
|
+
notes = mgr.get_breaking_changes(config_version, installed_version)
|
|
33
|
+
|
|
34
|
+
if major_change:
|
|
35
|
+
from_major, to_major = major_change
|
|
36
|
+
click.echo(utils.Color.bold(
|
|
37
|
+
f"⚠️ half-orm {from_major}.x → {to_major}.x: a major release, "
|
|
38
|
+
"which may require changes to your code."))
|
|
39
|
+
click.echo(" Read what changed, and what to write instead, before going on:")
|
|
40
|
+
click.echo(f" {HALF_ORM_BREAKING_CHANGES_URL.format(major=to_major)}")
|
|
41
|
+
click.echo()
|
|
42
|
+
|
|
43
|
+
if notes:
|
|
44
|
+
width = 70
|
|
45
|
+
label = 'half-orm-dev'
|
|
46
|
+
lines = ['━' * width, " ⚠️ BREAKING CHANGES", '━' * width]
|
|
47
|
+
for note in notes:
|
|
48
|
+
lines.append(
|
|
49
|
+
f"\n ━━━ {label} {installed_version} "
|
|
50
|
+
f"{'━' * max(0, width - len(label) - len(installed_version) - 7)}")
|
|
51
|
+
lines.extend(f" {line}" for line in note['content'].splitlines())
|
|
52
|
+
lines.append(f"\n{'━' * width}")
|
|
53
|
+
click.echo_via_pager('\n'.join(lines) + '\n')
|
|
54
|
+
|
|
55
|
+
return bool(major_change or notes)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def confirm_breaking_migration() -> bool:
|
|
59
|
+
"Ask for the explicit \"yes\" a breaking migration calls for."
|
|
60
|
+
click.echo("Type \"yes\" to confirm you have read the breaking changes and want to proceed.")
|
|
61
|
+
answer = click.prompt("Proceed?", default="no")
|
|
62
|
+
return answer.strip().lower() == "yes"
|
|
63
|
+
|
|
64
|
+
|
|
14
65
|
@click.command()
|
|
15
66
|
@click.option(
|
|
16
67
|
'--verbose', '-v',
|
|
@@ -77,41 +128,8 @@ def migrate(verbose: bool) -> None:
|
|
|
77
128
|
click.echo()
|
|
78
129
|
|
|
79
130
|
# Check for breaking changes between current and target version
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
needs_explicit_confirm = False
|
|
84
|
-
if breaking_changes:
|
|
85
|
-
import importlib.metadata
|
|
86
|
-
try:
|
|
87
|
-
half_orm_installed = importlib.metadata.version('half-orm')
|
|
88
|
-
except importlib.metadata.PackageNotFoundError:
|
|
89
|
-
half_orm_installed = None
|
|
90
|
-
|
|
91
|
-
width = 70
|
|
92
|
-
lines = []
|
|
93
|
-
lines.append('━' * width)
|
|
94
|
-
lines.append(f" ⚠️ BREAKING CHANGES")
|
|
95
|
-
lines.append('━' * width)
|
|
96
|
-
for bc in breaking_changes:
|
|
97
|
-
if bc['component'] == 'hop':
|
|
98
|
-
label = 'half-orm-dev'
|
|
99
|
-
display_version = installed_version
|
|
100
|
-
else:
|
|
101
|
-
label = 'half-orm'
|
|
102
|
-
display_version = half_orm_installed or bc['version']
|
|
103
|
-
lines.append(f"\n ━━━ {label} {display_version} {'━' * max(0, width - len(label) - len(display_version) - 7)}")
|
|
104
|
-
for line in bc['content'].splitlines():
|
|
105
|
-
lines.append(f" {line}")
|
|
106
|
-
lines.append(f"\n{'━' * width}")
|
|
107
|
-
click.echo_via_pager('\n'.join(lines) + '\n')
|
|
108
|
-
needs_explicit_confirm = True
|
|
109
|
-
|
|
110
|
-
# Run migrations
|
|
111
|
-
if needs_explicit_confirm:
|
|
112
|
-
click.echo("Type \"yes\" to confirm you have read the breaking changes and want to proceed.")
|
|
113
|
-
answer = click.prompt("Proceed?", default="no")
|
|
114
|
-
confirmed = answer.strip().lower() == "yes"
|
|
131
|
+
if announce_breaking_changes(repo, config_version, installed_version):
|
|
132
|
+
confirmed = confirm_breaking_migration()
|
|
115
133
|
else:
|
|
116
134
|
confirmed = click.confirm("Do you want to proceed?", default=False)
|
|
117
135
|
|
|
@@ -10,7 +10,7 @@ import sys
|
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
12
|
import half_orm_dev as _half_orm_dev
|
|
13
|
-
from half_orm_dev.utils import hop_version
|
|
13
|
+
from half_orm_dev.utils import hop_version, is_production_checkout
|
|
14
14
|
from half_orm_dev.repo import Repo, OutdatedHalfORMDevError
|
|
15
15
|
from half_orm import utils
|
|
16
16
|
from .commands import ALL_COMMANDS
|
|
@@ -141,10 +141,27 @@ def create_cli_group():
|
|
|
141
141
|
cmd = super().get_command(ctx, cmd_name)
|
|
142
142
|
if cmd is not None:
|
|
143
143
|
return cmd
|
|
144
|
+
if hop.needs_hop_upgrade:
|
|
145
|
+
# No command is registered while half_orm_dev is too old, so
|
|
146
|
+
# `half_orm dev upgrade` answered "No such command 'upgrade'"
|
|
147
|
+
# before the group callback could say why -- and install the
|
|
148
|
+
# right version, or refuse to on a production server. Resolve
|
|
149
|
+
# the name to a placeholder, and let the callback speak.
|
|
150
|
+
@click.command(
|
|
151
|
+
cmd_name,
|
|
152
|
+
context_settings={
|
|
153
|
+
'allow_extra_args': True,
|
|
154
|
+
'ignore_unknown_options': True,
|
|
155
|
+
},
|
|
156
|
+
)
|
|
157
|
+
def _outdated():
|
|
158
|
+
sys.exit(1) # not reached: the callback exits or restarts
|
|
159
|
+
|
|
160
|
+
return _outdated
|
|
144
161
|
# Unknown command — show a specific message when migration is needed.
|
|
145
162
|
if hop.repo_checked and hop._Hop__repo.needs_migration():
|
|
146
163
|
installed_version = hop_version()
|
|
147
|
-
config_version = hop._Hop__repo.
|
|
164
|
+
config_version = hop._Hop__repo.config.hop_version
|
|
148
165
|
|
|
149
166
|
@click.command(
|
|
150
167
|
cmd_name,
|
|
@@ -193,6 +210,16 @@ def create_cli_group():
|
|
|
193
210
|
error = hop.hop_upgrade_error
|
|
194
211
|
required = error.required_version
|
|
195
212
|
installed = error.installed_version
|
|
213
|
+
if error.base_dir and is_production_checkout(error.base_dir):
|
|
214
|
+
# Nothing is installed behind an operator's back on a
|
|
215
|
+
# production server: the version is a decision.
|
|
216
|
+
click.echo(utils.Color.red(
|
|
217
|
+
f"\n This repository requires half-orm-dev {required} "
|
|
218
|
+
f"(installed: {installed})."), err=True)
|
|
219
|
+
click.echo(" Production server: nothing is installed automatically.", err=True)
|
|
220
|
+
click.echo(" Install it, then run the command again:", err=True)
|
|
221
|
+
click.echo(f" pip install half-orm-dev=={required}", err=True)
|
|
222
|
+
sys.exit(1)
|
|
196
223
|
click.echo(f"\n This repository requires half-orm-dev {required} "
|
|
197
224
|
f"(installed: {installed}).")
|
|
198
225
|
click.echo(f" Installing the required version...")
|
|
@@ -217,7 +244,7 @@ def create_cli_group():
|
|
|
217
244
|
# Propose automatic migration
|
|
218
245
|
from half_orm_dev.repo import RepoError
|
|
219
246
|
installed_version = hop_version()
|
|
220
|
-
config_version = hop._Hop__repo.
|
|
247
|
+
config_version = hop._Hop__repo.config.hop_version
|
|
221
248
|
current_branch = hop._Hop__repo.hgit.branch if hop._Hop__repo.hgit else 'unknown'
|
|
222
249
|
|
|
223
250
|
click.echo(f"\n{'='*70}")
|
|
@@ -234,8 +261,18 @@ def create_cli_group():
|
|
|
234
261
|
click.echo(f"\n 💡 You can interrupt (Ctrl+C) to backup .git/ if needed.")
|
|
235
262
|
click.echo(f"\n{'='*70}\n")
|
|
236
263
|
|
|
264
|
+
# What the migration breaks, if anything: this path used
|
|
265
|
+
# to migrate without showing any breaking change at all.
|
|
266
|
+
from half_orm_dev.cli.commands.migrate import (
|
|
267
|
+
announce_breaking_changes, confirm_breaking_migration)
|
|
268
|
+
if announce_breaking_changes(
|
|
269
|
+
hop._Hop__repo, config_version, installed_version):
|
|
270
|
+
apply = confirm_breaking_migration()
|
|
271
|
+
else:
|
|
272
|
+
apply = click.confirm("Apply migration now?", default=True)
|
|
273
|
+
|
|
237
274
|
# Ask for confirmation
|
|
238
|
-
if
|
|
275
|
+
if apply:
|
|
239
276
|
click.echo()
|
|
240
277
|
|
|
241
278
|
# Switch to ho-prod if needed
|
|
@@ -1222,8 +1222,20 @@ class Database:
|
|
|
1222
1222
|
if password_input == '':
|
|
1223
1223
|
# Empty password - assume trust/ident authentication
|
|
1224
1224
|
complete_params['password'] = None # Explicitly None for trust mode
|
|
1225
|
-
|
|
1226
|
-
|
|
1225
|
+
|
|
1226
|
+
# A local socket is the default that goes with peer/trust
|
|
1227
|
+
# auth, but a default only: an explicit --host, or PGHOST,
|
|
1228
|
+
# still wins. And the port is left alone so it is resolved
|
|
1229
|
+
# below like every other client tool resolves it - a socket
|
|
1230
|
+
# connection needs it too, since it selects which
|
|
1231
|
+
# .s.PGSQL.<port> to talk to. Forcing both to '' here made
|
|
1232
|
+
# `clone`/`init` ignore --port and PGPORT outright, and
|
|
1233
|
+
# wrote a configuration that named no cluster at all: the
|
|
1234
|
+
# cloned project then only worked in a shell that happened
|
|
1235
|
+
# to export PGPORT.
|
|
1236
|
+
if (complete_params.get('host') is None
|
|
1237
|
+
and os.environ.get('PGHOST') is None):
|
|
1238
|
+
complete_params['host'] = '' # Local socket connection
|
|
1227
1239
|
else:
|
|
1228
1240
|
complete_params['password'] = password_input
|
|
1229
1241
|
|
|
@@ -107,6 +107,11 @@ def execute_python_file(
|
|
|
107
107
|
text=True,
|
|
108
108
|
check=True
|
|
109
109
|
)
|
|
110
|
+
# A script that succeeds can still have something to say - notably
|
|
111
|
+
# the generated package logging a relation missing from the database.
|
|
112
|
+
# Dropping its stderr would make that warning unobservable.
|
|
113
|
+
if result.stderr:
|
|
114
|
+
sys.stderr.write(result.stderr)
|
|
110
115
|
return result.stdout.strip()
|
|
111
116
|
|
|
112
117
|
except subprocess.CalledProcessError as e:
|
|
@@ -170,6 +175,8 @@ def _execute_via_venv_runner(
|
|
|
170
175
|
text=True,
|
|
171
176
|
check=True
|
|
172
177
|
)
|
|
178
|
+
if result.stderr:
|
|
179
|
+
sys.stderr.write(result.stderr)
|
|
173
180
|
return result.stdout.strip()
|
|
174
181
|
except subprocess.CalledProcessError as e:
|
|
175
182
|
error_msg = f"Python execution failed in {file_path.name}"
|
|
@@ -34,10 +34,9 @@ from typing import List, Dict, Optional, Tuple
|
|
|
34
34
|
from half_orm import utils
|
|
35
35
|
from half_orm_dev.decorators import with_dynamic_branch_lock
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
get_breaking_changes_dir = None # type: ignore[assignment]
|
|
37
|
+
# Where half-orm documents what a major release requires of the code.
|
|
38
|
+
HALF_ORM_BREAKING_CHANGES_URL = (
|
|
39
|
+
'https://half-orm.github.io/half-orm/latest/breaking-changes/#breaking-{major}-0-0')
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
class MigrationManagerError(Exception):
|
|
@@ -721,13 +720,14 @@ class MigrationManager:
|
|
|
721
720
|
|
|
722
721
|
def get_breaking_changes(self, current_version: str, target_version: str) -> List[Dict]:
|
|
723
722
|
"""
|
|
724
|
-
Collect breaking-changes
|
|
723
|
+
Collect half_orm_dev's breaking-changes notes for ]current, target].
|
|
725
724
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
725
|
+
These describe what the migration about to run does to the
|
|
726
|
+
repository -- the .hop/ layout, a command, the generated code -- and
|
|
727
|
+
are shown in full before it runs. half-orm's own notes are not
|
|
728
|
+
collected: see half_orm_major_change().
|
|
729
729
|
|
|
730
|
-
|
|
730
|
+
Files live in migrations/hop/ as BREAKING_CHANGES-X.Y.Z.md.
|
|
731
731
|
|
|
732
732
|
Args:
|
|
733
733
|
current_version: Current hop version (exclusive lower bound)
|
|
@@ -735,7 +735,7 @@ class MigrationManager:
|
|
|
735
735
|
|
|
736
736
|
Returns:
|
|
737
737
|
List of dicts ordered by version, each with keys:
|
|
738
|
-
- component: 'hop'
|
|
738
|
+
- component: 'hop'
|
|
739
739
|
- version: version string from filename
|
|
740
740
|
- content: file content
|
|
741
741
|
"""
|
|
@@ -751,30 +751,49 @@ class MigrationManager:
|
|
|
751
751
|
except Exception:
|
|
752
752
|
return results
|
|
753
753
|
|
|
754
|
-
|
|
755
|
-
if
|
|
754
|
+
bc_dir = self._migrations_root / 'hop'
|
|
755
|
+
if not bc_dir.is_dir():
|
|
756
|
+
return results
|
|
757
|
+
for bc_file in sorted(bc_dir.glob('BREAKING_CHANGES-*.md')):
|
|
758
|
+
# filename: BREAKING_CHANGES-X.Y.Z.md (hyphens in pre-release OK)
|
|
759
|
+
raw = bc_file.stem[len('BREAKING_CHANGES-'):] # e.g. '1.0.0' or '1.0.0-rc1'
|
|
756
760
|
try:
|
|
757
|
-
|
|
761
|
+
file_version = version.parse(raw)
|
|
758
762
|
except Exception:
|
|
759
|
-
pass # older half-orm — ignore silently
|
|
760
|
-
|
|
761
|
-
for component, bc_dir in component_dirs.items():
|
|
762
|
-
if not bc_dir.is_dir():
|
|
763
763
|
continue
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
results.append({
|
|
773
|
-
'component': component,
|
|
774
|
-
'version': raw,
|
|
775
|
-
'content': bc_file.read_text(encoding='utf-8'),
|
|
776
|
-
})
|
|
777
|
-
|
|
778
|
-
# Sort by version, then by component for a stable display order
|
|
779
|
-
results.sort(key=lambda r: (version.parse(r['version']), r['component']))
|
|
764
|
+
if current_base < file_version <= target_base:
|
|
765
|
+
results.append({
|
|
766
|
+
'component': 'hop',
|
|
767
|
+
'version': raw,
|
|
768
|
+
'content': bc_file.read_text(encoding='utf-8'),
|
|
769
|
+
})
|
|
770
|
+
|
|
771
|
+
results.sort(key=lambda r: version.parse(r['version']))
|
|
780
772
|
return results
|
|
773
|
+
|
|
774
|
+
@staticmethod
|
|
775
|
+
def half_orm_major_change(current_version: str, target_version: str) -> Optional[Tuple[int, int]]:
|
|
776
|
+
"""
|
|
777
|
+
The half-orm major versions a migration moves between, if it does.
|
|
778
|
+
|
|
779
|
+
half-orm follows Semantic Versioning: only a major release requires
|
|
780
|
+
changes to the application's code, and its notes are on half-orm's
|
|
781
|
+
documentation, where a developer -- the one running this, on a
|
|
782
|
+
machine with a browser -- is pointed. half_orm_dev's major version
|
|
783
|
+
is half-orm's (its CLI loads nothing else), so a change of
|
|
784
|
+
half_orm_dev's major version is a change of half-orm's.
|
|
785
|
+
|
|
786
|
+
Args:
|
|
787
|
+
current_version: Current hop version
|
|
788
|
+
target_version: Target hop version
|
|
789
|
+
|
|
790
|
+
Returns:
|
|
791
|
+
``(from_major, to_major)``, or None when the major version does
|
|
792
|
+
not move forward or a version cannot be read.
|
|
793
|
+
"""
|
|
794
|
+
try:
|
|
795
|
+
current = version.parse(current_version).major
|
|
796
|
+
target = version.parse(target_version).major
|
|
797
|
+
except Exception:
|
|
798
|
+
return None
|
|
799
|
+
return (current, target) if target > current else None
|