django-compose 0.1.0.dev6__tar.gz → 0.1.0.dev7__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.
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/CHANGELOG.md +6 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/PKG-INFO +1 -1
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/README.md +2 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/SPEC.md +42 -2
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/dependencies.md +1 -1
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/migrations.md +55 -2
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/packaging.md +4 -4
- django_compose-0.1.0.dev7/docs/proposals/0003-existing-baseline-adoption.md +32 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/pyproject.toml +1 -1
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/scripts/check_distribution.py +77 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/__init__.py +1 -0
- django_compose-0.1.0.dev7/src/django_compose/management/commands/adopt_transition.py +41 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/migrations.py +181 -36
- django_compose-0.1.0.dev7/tests/test_baseline_adoption.py +530 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/uv.lock +1 -1
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/.gitignore +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/AGENTS.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/CONTRIBUTING.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/COPYING +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/LICENSE +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/Makefile +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/NOTICE +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/README.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/ROADMAP.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/components.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/configuration.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/extensions.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/models.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/proposals/0001-native-url-collisions.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/proposals/0002-supplied-distribution-metadata.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/proposals/README.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/provisioning.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/docs/quickstart.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/.gitignore +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/README.md +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/__init__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/apps.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/autoconfig.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/integrations.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/management/__init__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/management/commands/verify_context.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/models.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/pyproject.toml +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/schema.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/transport.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/catalog/urls.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/contexts.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/manage.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/reviews/__init__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/reviews/apps.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/reviews/autoconfig.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/reviews/models.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/reviews/pyproject.toml +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/settings.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/urls.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/examples/shop/verify.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/__init__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/__main__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/apps.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/artifacts.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/asgi.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/autoreload.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/build.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/checks.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/cli.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/components.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/conf.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/declarations.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/history.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/check_migrations.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/compose.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/makemigrations.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/migrate.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/provision.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/reset_migration_history.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/retire_history.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/migration_imports.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/model_composition.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/models.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/provision.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/py.typed +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/rendering.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/serving.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/snapshot.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/sources.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/typing.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/src/django_compose/urls.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/core_fixtures/__init__.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_artifacts.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_asgi.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_autoreload.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_bootstrap.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_boundaries.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_command_context.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_components.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_conf.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_history.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_initial_history.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_integrations.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_launcher.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_migration_imports.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_migration_scaffold.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_migrations.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_migrations_guards.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_migrations_postgres.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_models.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_provision.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_provision_postgres.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_snapshot.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_sources.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_startup.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_typing.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/test_urls.py +0 -0
- {django_compose-0.1.0.dev6 → django_compose-0.1.0.dev7}/tests/typing_fixtures/__init__.py +0 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0.dev7
|
|
4
|
+
|
|
5
|
+
- Add explicit `adopt_transition` authoring for a declared transition satisfied by
|
|
6
|
+
a named retained native initial, with frozen source checks, sealed anchor
|
|
7
|
+
provenance, idempotent retries and database-free dry-run validation.
|
|
8
|
+
|
|
3
9
|
## 0.1.0.dev6
|
|
4
10
|
|
|
5
11
|
- Allow transition owners to declare an adoption-safe initial baseline through
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-compose
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev7
|
|
4
4
|
Summary: Compose reusable Django apps into a runnable project.
|
|
5
5
|
Project-URL: Source, https://github.com/ang-ee/django-compose
|
|
6
6
|
Project-URL: Documentation, https://github.com/ang-ee/django-compose/tree/main/docs
|
|
@@ -29,6 +29,7 @@ Use the [django-compose launcher](configuration.md#managepy) in `manage.py`.
|
|
|
29
29
|
| `makemigrations`, `migrate` | Author and apply ordinary Django migration history | [Migrations](migrations.md) |
|
|
30
30
|
| `runserver` | Recompose before Django's development-server reloads | [Development](configuration.md#serve-the-project) |
|
|
31
31
|
| `provision` | Apply migrations and optional app hooks; `--check` verifies readiness | [Provisioning](provisioning.md) |
|
|
32
|
+
| `adopt_transition` | Attest that an opted-in transition is satisfied by a named retained initial and append its empty native origin; `--dry-run` validates without writes | [Baseline adoption](migrations.md#adopt-an-explicit-retained-initial-baseline) |
|
|
32
33
|
| `check_migrations` | Compare model/history state; `--imports` audits retained Python dependencies | [History checks](migrations.md#disable-delete-or-uninstall) |
|
|
33
34
|
| `retire_history`, `reset_migration_history` | Perform explicit, guarded history maintenance | [Advanced migrations](migrations.md#advanced-destructive-changes-and-history-cutoffs) |
|
|
34
35
|
|
|
@@ -53,6 +54,7 @@ validation and lifecycle rules live in the [API reference](SPEC.md).
|
|
|
53
54
|
| `components.active_requirements(requirements)` | Return native `Requirement` values active on this platform with `extra=""` |
|
|
54
55
|
| `conf.apply_app_settings(namespace, closure)` | Apply app settings to a project using ordinary authored concrete models |
|
|
55
56
|
| `snapshot.discover_transitions(entries)` | Read default transition records from resolved app identities for an integration to annotate without importing migration code |
|
|
57
|
+
| `migrations.TransitionBinding.adoption_plan(origin, baseline)` / `.adopt(origin, baseline, dry_run=False)` | Validate or author one explicit retained-baseline adoption through native migration history |
|
|
56
58
|
| `provision.require_provisioned(using="default", timeout=0)` | Require recorded database readiness for the verified build |
|
|
57
59
|
| `serving.artifact_path(relative)` | Locate and verify a generated artifact |
|
|
58
60
|
| `serving.receipt_lease()` / `verified_receipt()` | Hold a shared build-record lease / read the startup-verified record |
|
|
@@ -488,8 +488,8 @@ not crash-atomic publication of multiple files.
|
|
|
488
488
|
`TransitionBinding` uses frozen snapshot records by default, or explicit
|
|
489
489
|
`declarations=`. It binds native migration origins `<declaring_app>:<name>` to
|
|
490
490
|
the project's actual graph leaves. Each source provides a native `Migration`
|
|
491
|
-
and a pure `applies(ProjectState) -> bool` guard.
|
|
492
|
-
unless its owner declares `initial_baseline: "satisfied"` and the label acquired
|
|
491
|
+
and a pure `applies(ProjectState) -> bool` guard. Ordinary planning and
|
|
492
|
+
`makemigrations` refuse a pending false guard unless its owner declares `initial_baseline: "satisfied"` and the label acquired
|
|
493
493
|
its first native disk nodes in this successful command's initial-authoring phase,
|
|
494
494
|
including native prerequisite expansion. The assertion means the final-schema
|
|
495
495
|
initial baseline satisfies this transition on every database adopting it,
|
|
@@ -512,6 +512,46 @@ Legacy `angee_origin` and `angee_source_sha256` metadata is read only for
|
|
|
512
512
|
historical adoption; new metadata uses `compose_origin` and
|
|
513
513
|
`compose_source_sha256`.
|
|
514
514
|
|
|
515
|
+
Explicit existing-baseline adoption uses
|
|
516
|
+
`TransitionBinding.adoption_plan(origin, baseline)` and
|
|
517
|
+
`TransitionBinding.adopt(origin, baseline, *, dry_run=False)`, or the thin
|
|
518
|
+
`adopt_transition DECLARING_APP:NAME --baseline APP_LABEL.MIGRATION_NAME
|
|
519
|
+
[--dry-run]` management command. The selected normalized declaration and source
|
|
520
|
+
SHA must match `COMPOSE_SNAPSHOT.transition_records` and `transitions`, and the
|
|
521
|
+
owner must already assert `initial_baseline: "satisfied"`.
|
|
522
|
+
|
|
523
|
+
The explicit action is the caller's attestation that the named retained initial
|
|
524
|
+
is the baseline covered by that owner assertion. Native graph structure and
|
|
525
|
+
false guards establish the action's scope; they prove neither historical data
|
|
526
|
+
completion nor schema equivalence. The named anchor must be same-target-label,
|
|
527
|
+
retained on disk and active in Django's graph, and an ancestor of the unique
|
|
528
|
+
current target leaf. It must have `Migration.initial is True`, or `initial is
|
|
529
|
+
None` and be a native same-app graph root. This root criterion is conservative
|
|
530
|
+
scope for adoption, not a reimplementation of Django's soft-initial detection;
|
|
531
|
+
`run_before` can affect native graph roots. A true guard either after the named
|
|
532
|
+
anchor or at the resolved binding pre-state refuses adoption. Unrelated current
|
|
533
|
+
model drift remains for ordinary `makemigrations`.
|
|
534
|
+
|
|
535
|
+
Only the selected pending declaration is loaded. Native graph resolution freezes
|
|
536
|
+
its dependency and `run_before` edges; missing or pending explicit prerequisites
|
|
537
|
+
or successors, cycles and ambiguous relevant leaves refuse. Unrelated pending
|
|
538
|
+
sources are not imported or implicitly adopted. The new sealed native empty
|
|
539
|
+
origin depends on the current retained target leaf, preserving existing files.
|
|
540
|
+
The footer retains the existing source/body seals and baseline-satisfaction
|
|
541
|
+
marker, plus `compose_adopted_baseline` (the anchor Node) and
|
|
542
|
+
`compose_adopted_baseline_sha256` (the exact native anchor file hash).
|
|
543
|
+
|
|
544
|
+
`adoption_plan` returns a `TransitionPlan`, or `None` for an exact retained
|
|
545
|
+
adoption. `adopt` returns the authored path tuple, the prospective path tuple
|
|
546
|
+
for dry-run, or an empty tuple for an exact repeat. A repeat validates the sealed
|
|
547
|
+
origin's native empty semantics, selected source, matching anchor and anchor SHA
|
|
548
|
+
without rewriting or rebinding it, including after later native descendants.
|
|
549
|
+
Existing ordinary or first-authoring origins are not silently converted to
|
|
550
|
+
adoptions. Dry-run validates without writes; failed publication removes only
|
|
551
|
+
its newly authored files through the same exclusive rollback owner as normal
|
|
552
|
+
binding. Authoring never queries the database or writes the migration recorder;
|
|
553
|
+
Django's subsequent `migrate` owns application and recording.
|
|
554
|
+
|
|
515
555
|
`DropGuardAutodetector`, shared by native `makemigrations` and `migrate`, requires
|
|
516
556
|
relevant rows or columns to be empty on every database eligible for the native
|
|
517
557
|
operation before automatic destructive changes. Eligibility includes native
|
|
@@ -50,7 +50,7 @@ The `typing` extra is unnecessary for building or running a project. Install it
|
|
|
50
50
|
in the project's environment when you want composed-model analysis:
|
|
51
51
|
|
|
52
52
|
```sh
|
|
53
|
-
python -m pip install 'django-compose[typing]==0.1.0.
|
|
53
|
+
python -m pip install 'django-compose[typing]==0.1.0.dev7'
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
The extra installs published Angee forks of mypy and django-stubs, keeping their
|
|
@@ -202,8 +202,9 @@ keep that work in a separate native transition whose guard is true on the final
|
|
|
202
202
|
schema and whose operations handle both empty and preexisting tables. True guards
|
|
203
203
|
always run their original operations, even when the declaration has this option.
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
During ordinary `makemigrations`, only a declared false guard targeting a label
|
|
206
|
+
actually initialized by its native initial-authoring phase becomes a sealed
|
|
207
|
+
zero-operation origin.
|
|
207
208
|
Native prerequisite expansion contributes its exact newly initialized labels.
|
|
208
209
|
Existing initial-looking files do not qualify, and ordinary planning/checks and
|
|
209
210
|
history reset stay strict. The sealed `compose_initial_baseline = "satisfied"`
|
|
@@ -226,6 +227,58 @@ New bindings use `compose_*` metadata. Existing `angee_origin` and
|
|
|
226
227
|
there is no need to rewrite old migration files. Check and dry-run paths do not
|
|
227
228
|
create migration packages or files.
|
|
228
229
|
|
|
230
|
+
### Adopt an explicit retained initial baseline
|
|
231
|
+
|
|
232
|
+
A project may already retain a native initial authored from its final schema,
|
|
233
|
+
while an opted-in reusable transition is still pending with a false guard.
|
|
234
|
+
Ordinary `makemigrations` and checks stay strict in this situation. After reviewing
|
|
235
|
+
the transition owner's `initial_baseline: "satisfied"` assertion, explicitly
|
|
236
|
+
attest that the retained initial is the baseline covered by that assertion:
|
|
237
|
+
|
|
238
|
+
```sh
|
|
239
|
+
python manage.py compose
|
|
240
|
+
python manage.py adopt_transition inventory:rename_legacy --baseline inventory.0001_initial --dry-run
|
|
241
|
+
python manage.py adopt_transition inventory:rename_legacy --baseline inventory.0001_initial
|
|
242
|
+
python manage.py makemigrations
|
|
243
|
+
python manage.py migrate
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
This action names one declared origin and one exact retained native initial.
|
|
247
|
+
It appends a sealed empty origin after the current target leaf; it does not
|
|
248
|
+
rewrite the initial, other migrations or applied-history records. The transition
|
|
249
|
+
record and source hash must match the frozen snapshot. The owner assertion must
|
|
250
|
+
cover every adopting database, including existing rows and native fake-initial
|
|
251
|
+
adoption, as described above. Neither the initial flag nor a false guard proves
|
|
252
|
+
that original operations ran or that historical data work is complete; invoking
|
|
253
|
+
the command is the caller's baseline attestation.
|
|
254
|
+
|
|
255
|
+
The anchor must be in active disk-backed native history for the same target app,
|
|
256
|
+
an ancestor of its unique current leaf, and native initial (`initial=True`, or
|
|
257
|
+
`initial=None` at a same-app graph root). The root test is this action's
|
|
258
|
+
conservative scope, not Django's fake-initial detector. Guards must be false both
|
|
259
|
+
after the named anchor and at the actual binding pre-state. True-guard work stays
|
|
260
|
+
ordinary migration work, and unrelated model changes remain for
|
|
261
|
+
`makemigrations`.
|
|
262
|
+
|
|
263
|
+
Native dependencies and `run_before` edges remain authoritative. Author/adopt
|
|
264
|
+
explicit prerequisites first; missing pending prerequisites or successors,
|
|
265
|
+
cycles and ambiguous graphs refuse. Only the named pending origin is loaded and
|
|
266
|
+
authored. Other pending sources are neither imported nor implicitly adopted.
|
|
267
|
+
|
|
268
|
+
Dry-run validates the same inputs without writing. An exact repeat verifies the
|
|
269
|
+
retained origin's source, named anchor and anchor file hash and writes nothing,
|
|
270
|
+
even after later native descendants. It does not convert an existing ordinary
|
|
271
|
+
or first-authoring origin into an adoption. Keep the sealed origin in native
|
|
272
|
+
history after removing its source declaration. The footer records
|
|
273
|
+
`compose_adopted_baseline` and `compose_adopted_baseline_sha256` alongside the
|
|
274
|
+
existing immutable seals and native empty-migration marker.
|
|
275
|
+
|
|
276
|
+
Adoption authoring is database-free and uses the existing exclusive publication
|
|
277
|
+
and exception rollback. It makes no readiness claim about any deployment
|
|
278
|
+
connection. Apply the appended no-op with Django's ordinary `migrate`; existing
|
|
279
|
+
table adoption and `--fake-initial` remain Django's separate application policy.
|
|
280
|
+
See the [canonical adoption API](SPEC.md#native-history-and-transitions).
|
|
281
|
+
|
|
229
282
|
## Advanced: destructive changes and history cutoffs
|
|
230
283
|
|
|
231
284
|
The shared `DropGuardAutodetector` requires relevant rows or columns to be empty
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Installation and deployment
|
|
2
2
|
|
|
3
|
-
The current version is the development preview `0.1.0.
|
|
3
|
+
The current version is the development preview `0.1.0.dev7`, including component
|
|
4
4
|
selection, isolated inspection and native provisioning.
|
|
5
5
|
Python 3.14 is the verified environment. The declared constraints are Python
|
|
6
6
|
`>=3.14` and Django `>=6.1.2,<6.2`; see [dependencies](dependencies.md) and
|
|
@@ -9,10 +9,10 @@ Python 3.14 is the verified environment. The declared constraints are Python
|
|
|
9
9
|
## Install from PyPI
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
python -m pip install django-compose==0.1.0.
|
|
12
|
+
python -m pip install django-compose==0.1.0.dev7
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Use `django-compose[typing]==0.1.0.
|
|
15
|
+
Use `django-compose[typing]==0.1.0.dev7` for the optional composition plugin and
|
|
16
16
|
its published typing dependencies; see [advanced typing](dependencies.md#advanced-typing).
|
|
17
17
|
|
|
18
18
|
## Install locally
|
|
@@ -36,7 +36,7 @@ environment:
|
|
|
36
36
|
# In the django-compose checkout, with uv installed:
|
|
37
37
|
uv build --wheel
|
|
38
38
|
# In the project environment, using the actual archive path:
|
|
39
|
-
python -m pip install /path/to/django-compose/dist/django_compose-0.1.0.
|
|
39
|
+
python -m pip install /path/to/django-compose/dist/django_compose-0.1.0.dev7-py3-none-any.whl
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
The base installation includes Django, packaging and django-yamlconf. Optional extras are described in
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# 0003: explicit adoption of a retained initial baseline
|
|
2
|
+
|
|
3
|
+
Status: accepted.
|
|
4
|
+
|
|
5
|
+
First-authoring baseline satisfaction deliberately does not exempt existing
|
|
6
|
+
native initials. Projects retaining an initial authored from their final schema
|
|
7
|
+
need an explicit way to associate that history with an already opted-in reusable
|
|
8
|
+
transition without rewriting history or claiming that its operations executed.
|
|
9
|
+
|
|
10
|
+
Extend the existing `TransitionBinding` owner with one-origin adoption against
|
|
11
|
+
a named retained native initial. Invoking the action attests that this anchor is
|
|
12
|
+
the baseline covered by the transition owner's existing satisfaction assertion.
|
|
13
|
+
Native active-history identity, initial/root scope, unique-leaf ancestry and two
|
|
14
|
+
false guard evaluations constrain the action; they do not prove historical data
|
|
15
|
+
completion. Whole-app model cleanliness is outside this action.
|
|
16
|
+
|
|
17
|
+
Reuse the frozen declaration/source snapshot, native MigrationLoader and graph,
|
|
18
|
+
shared guard and native-empty selection, existing renderer/seals and exclusive
|
|
19
|
+
publication rollback. Seal the named anchor and its exact source hash for
|
|
20
|
+
idempotent provenance. A thin management command dispatches to that owner. No
|
|
21
|
+
new registry, source scanner, database inference or recorder policy is introduced.
|
|
22
|
+
|
|
23
|
+
The change is additive. Ordinary false-guard authoring, first-authoring
|
|
24
|
+
satisfaction and reset retain their contracts. Only an explicitly selected
|
|
25
|
+
pending origin is adopted; existing origins are never silently converted and
|
|
26
|
+
unrelated pending sources are not imported. Existing source bytes and native
|
|
27
|
+
history remain immutable; no existing migration needs a format migration. The
|
|
28
|
+
ordinary binding path shares guard, native-empty and publication owners with
|
|
29
|
+
adoption, replacing the former inline-only implementations.
|
|
30
|
+
|
|
31
|
+
The current API lives in the [specification](../SPEC.md#native-history-and-transitions)
|
|
32
|
+
and the [migration guide](../migrations.md#adopt-an-explicit-retained-initial-baseline).
|
|
@@ -60,6 +60,13 @@ def component_wheel(directory: Path, package: str, *, dependency: str | None = N
|
|
|
60
60
|
}
|
|
61
61
|
if dependency is None:
|
|
62
62
|
members[package + "/validators.py"] = "def retained(value):\n pass\n"
|
|
63
|
+
members[package + "/legacy.py"] = """from django.db import migrations
|
|
64
|
+
def applies(state):
|
|
65
|
+
return "old_title" in state.models["installed_catalog", "item"].fields
|
|
66
|
+
class Migration(migrations.Migration):
|
|
67
|
+
dependencies = []
|
|
68
|
+
operations = [migrations.RenameField("item", "old_title", "title")]
|
|
69
|
+
"""
|
|
63
70
|
members[package + "/models.py"] = """from django.db import models
|
|
64
71
|
from django_compose.models import Composable
|
|
65
72
|
from .validators import retained
|
|
@@ -227,6 +234,75 @@ assert set(state.apps.get_model("installed_catalog", "Grandchild")._meta.parents
|
|
|
227
234
|
)
|
|
228
235
|
assert "compose-smoke-reviews provides enabled app installed_reviews" in refusal, refusal
|
|
229
236
|
|
|
237
|
+
# An installed addon may introduce an origin after this host's final-schema
|
|
238
|
+
# initial already exists and has been applied. Adoption appends history only.
|
|
239
|
+
(host / "settings.py").write_text(
|
|
240
|
+
settings.replace(
|
|
241
|
+
"configure(globals())",
|
|
242
|
+
"""COMPOSE_TRANSITION_SOURCE = [{
|
|
243
|
+
"declaring_app": "installed_catalog", "name": "rename_legacy",
|
|
244
|
+
"app_label": "installed_catalog", "module": "installed_catalog.legacy",
|
|
245
|
+
"initial_baseline": "satisfied",
|
|
246
|
+
}]
|
|
247
|
+
configure(globals())""",
|
|
248
|
+
)
|
|
249
|
+
)
|
|
250
|
+
run([*compiler, "compose"], cwd=host, env=env)
|
|
251
|
+
histories = {
|
|
252
|
+
path: (path.read_bytes(), stat.S_IMODE(path.stat().st_mode))
|
|
253
|
+
for path in sorted((host / "runtime").glob("*/migrations/*.py"))
|
|
254
|
+
}
|
|
255
|
+
database = (host / "shop.sqlite3").read_bytes()
|
|
256
|
+
refusal = run(
|
|
257
|
+
[*compiler, "makemigrations", "installed_catalog", "--check", "--dry-run"],
|
|
258
|
+
cwd=host,
|
|
259
|
+
env=env,
|
|
260
|
+
success=False,
|
|
261
|
+
)
|
|
262
|
+
assert "false guard cannot prove" in refusal, refusal
|
|
263
|
+
adoption = [
|
|
264
|
+
*compiler,
|
|
265
|
+
"adopt_transition",
|
|
266
|
+
"installed_catalog:rename_legacy",
|
|
267
|
+
"--baseline",
|
|
268
|
+
"installed_catalog.0001_initial",
|
|
269
|
+
]
|
|
270
|
+
run([*adoption, "--dry-run"], cwd=host, env=env)
|
|
271
|
+
assert set((host / "runtime").glob("*/migrations/*.py")) == set(histories)
|
|
272
|
+
run(adoption, cwd=host, env=env)
|
|
273
|
+
origin = host / "runtime/installed_catalog/migrations/rename_legacy.py"
|
|
274
|
+
assert set((host / "runtime").glob("*/migrations/*.py")) == {*histories, origin}
|
|
275
|
+
authored = origin.read_bytes()
|
|
276
|
+
run(adoption, cwd=host, env=env)
|
|
277
|
+
assert origin.read_bytes() == authored
|
|
278
|
+
assert (host / "shop.sqlite3").read_bytes() == database
|
|
279
|
+
for path, expected in histories.items():
|
|
280
|
+
assert (path.read_bytes(), stat.S_IMODE(path.stat().st_mode)) == expected, path
|
|
281
|
+
run([*compiler, "migrate", "--noinput"], cwd=host, env=env)
|
|
282
|
+
run([*compiler, "compose", "--check"], cwd=host, env=env)
|
|
283
|
+
run(
|
|
284
|
+
[
|
|
285
|
+
str(python),
|
|
286
|
+
"-c",
|
|
287
|
+
"""import django
|
|
288
|
+
django.setup()
|
|
289
|
+
from django.apps import apps
|
|
290
|
+
from django.db import connection
|
|
291
|
+
from django.db.migrations.loader import MigrationLoader
|
|
292
|
+
loader = MigrationLoader(connection)
|
|
293
|
+
node = ("installed_catalog", "rename_legacy")
|
|
294
|
+
assert loader.disk_migrations[node].operations == []
|
|
295
|
+
assert node in loader.applied_migrations
|
|
296
|
+
row = apps.get_model("installed_catalog", "Child").objects.get()
|
|
297
|
+
assert (row.title, row.detail, row.rating, row.reviewed) == (
|
|
298
|
+
"installed component", "child", 5, True,
|
|
299
|
+
)
|
|
300
|
+
""",
|
|
301
|
+
],
|
|
302
|
+
cwd=host,
|
|
303
|
+
env=env,
|
|
304
|
+
)
|
|
305
|
+
|
|
230
306
|
|
|
231
307
|
def main() -> None:
|
|
232
308
|
(wheel,) = sorted((ROOT / "dist").glob("django_compose-*.whl"))
|
|
@@ -247,6 +323,7 @@ def main() -> None:
|
|
|
247
323
|
"build.py",
|
|
248
324
|
"typing.py",
|
|
249
325
|
"management/commands/makemigrations.py",
|
|
326
|
+
"management/commands/adopt_transition.py",
|
|
250
327
|
"management/commands/provision.py",
|
|
251
328
|
):
|
|
252
329
|
assert f"django_compose/{required}" in names, required
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Append a declared transition origin satisfied by retained native baseline history."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
6
|
+
from django.core.management.base import BaseCommand, CommandError, CommandParser
|
|
7
|
+
|
|
8
|
+
from django_compose.management import require_serving_mode
|
|
9
|
+
from django_compose.management.commands.makemigrations import history_labels
|
|
10
|
+
from django_compose.migrations import TransitionBinding
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Command(BaseCommand):
|
|
14
|
+
help = (
|
|
15
|
+
"Attest that the named retained initial is covered by the transition owner's "
|
|
16
|
+
"baseline-satisfaction assertion, and append a sealed native no-op origin."
|
|
17
|
+
)
|
|
18
|
+
requires_system_checks: list[str] = []
|
|
19
|
+
|
|
20
|
+
def add_arguments(self, parser: CommandParser) -> None:
|
|
21
|
+
parser.add_argument("origin", metavar="DECLARING_APP:NAME")
|
|
22
|
+
parser.add_argument("--baseline", required=True, metavar="APP_LABEL.MIGRATION_NAME")
|
|
23
|
+
parser.add_argument("--dry-run", action="store_true")
|
|
24
|
+
|
|
25
|
+
def handle(self, *args: Any, **options: Any) -> None:
|
|
26
|
+
require_serving_mode()
|
|
27
|
+
label, separator, name = options["baseline"].partition(".")
|
|
28
|
+
if not separator or not label or not name:
|
|
29
|
+
raise CommandError("--baseline must name APP_LABEL.MIGRATION_NAME")
|
|
30
|
+
origin = options["origin"]
|
|
31
|
+
try:
|
|
32
|
+
paths = TransitionBinding(labels=history_labels()).adopt(
|
|
33
|
+
origin, (label, name), dry_run=options["dry_run"]
|
|
34
|
+
)
|
|
35
|
+
except (RuntimeError, ImproperlyConfigured) as error:
|
|
36
|
+
raise CommandError(str(error)) from error
|
|
37
|
+
if not paths:
|
|
38
|
+
self.stdout.write(f"Already adopted {origin} against {options['baseline']}")
|
|
39
|
+
else:
|
|
40
|
+
action = "Would author" if options["dry_run"] else "Authored"
|
|
41
|
+
self.stdout.write(f"{action} {paths[0]}")
|