django-compose 0.1.0.dev5__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.dev5 → django_compose-0.1.0.dev7}/CHANGELOG.md +15 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/PKG-INFO +1 -1
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/README.md +3 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/SPEC.md +78 -5
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/dependencies.md +1 -1
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/migrations.md +118 -0
- {django_compose-0.1.0.dev5 → 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.dev5 → django_compose-0.1.0.dev7}/pyproject.toml +1 -1
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/scripts/check_distribution.py +77 -0
- {django_compose-0.1.0.dev5 → 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.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/makemigrations.py +104 -4
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/migrations.py +270 -54
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/snapshot.py +14 -7
- django_compose-0.1.0.dev7/tests/test_baseline_adoption.py +530 -0
- django_compose-0.1.0.dev7/tests/test_initial_history.py +752 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_migrations.py +26 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_snapshot.py +48 -1
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/uv.lock +1 -1
- django_compose-0.1.0.dev5/tests/test_initial_history.py +0 -171
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/.gitignore +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/AGENTS.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/CONTRIBUTING.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/COPYING +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/LICENSE +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/Makefile +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/NOTICE +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/README.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/ROADMAP.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/components.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/configuration.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/extensions.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/models.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/proposals/0001-native-url-collisions.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/proposals/0002-supplied-distribution-metadata.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/proposals/README.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/provisioning.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/docs/quickstart.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/.gitignore +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/README.md +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/__init__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/apps.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/autoconfig.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/integrations.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/management/__init__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/management/commands/verify_context.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/models.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/pyproject.toml +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/schema.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/transport.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/catalog/urls.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/contexts.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/manage.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/reviews/__init__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/reviews/apps.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/reviews/autoconfig.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/reviews/models.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/reviews/pyproject.toml +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/settings.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/urls.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/examples/shop/verify.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/__init__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/__main__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/apps.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/artifacts.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/asgi.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/autoreload.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/build.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/checks.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/cli.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/components.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/conf.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/declarations.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/history.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/__init__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/check_migrations.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/compose.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/migrate.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/provision.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/reset_migration_history.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/management/commands/retire_history.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/migration_imports.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/model_composition.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/models.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/provision.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/py.typed +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/rendering.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/serving.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/sources.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/typing.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/src/django_compose/urls.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/core_fixtures/__init__.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_artifacts.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_asgi.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_autoreload.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_bootstrap.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_boundaries.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_command_context.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_components.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_conf.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_history.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_integrations.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_launcher.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_migration_imports.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_migration_scaffold.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_migrations_guards.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_migrations_postgres.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_models.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_provision.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_provision_postgres.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_sources.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_startup.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_typing.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/test_urls.py +0 -0
- {django_compose-0.1.0.dev5 → django_compose-0.1.0.dev7}/tests/typing_fixtures/__init__.py +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
9
|
+
## 0.1.0.dev6
|
|
10
|
+
|
|
11
|
+
- Allow transition owners to declare an adoption-safe initial baseline through
|
|
12
|
+
`initial_baseline: "satisfied"`, preserving true-guard data work and immutable
|
|
13
|
+
source hashes. Roll back initial schema, bindings and reconciliation together
|
|
14
|
+
when migration authoring raises.
|
|
15
|
+
- Expose the existing transition discovery owner as `discover_transitions` so
|
|
16
|
+
settings adapters can annotate addon-owned records without copying discovery.
|
|
17
|
+
|
|
3
18
|
## 0.1.0.dev5
|
|
4
19
|
|
|
5
20
|
- Respect Django's swapped-model storage semantics when guarding migrations, so
|
|
@@ -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
|
|
|
@@ -52,6 +53,8 @@ validation and lifecycle rules live in the [API reference](SPEC.md).
|
|
|
52
53
|
| `components.index_components(distributions, *, group)` | Apply the same indexing rules to supplied native `Distribution` objects |
|
|
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 |
|
|
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 |
|
|
55
58
|
| `provision.require_provisioned(using="default", timeout=0)` | Require recorded database readiness for the verified build |
|
|
56
59
|
| `serving.artifact_path(relative)` | Locate and verify a generated artifact |
|
|
57
60
|
| `serving.receipt_lease()` / `verified_receipt()` | Hold a shared build-record lease / read the startup-verified record |
|
|
@@ -286,10 +286,23 @@ setup. Snapshot and serving do not import the model compiler or execute integrat
|
|
|
286
286
|
|
|
287
287
|
Without `COMPOSE_TRANSITION_SOURCE`, each selected app contributes sorted
|
|
288
288
|
`compose_migrations/<label>/<name>.py` files in app order, including numeric
|
|
289
|
-
migration names.
|
|
290
|
-
`
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
migration names. The public owner is
|
|
290
|
+
`snapshot.discover_transitions(entries: Iterable[Entry]) -> tuple[Mapping[str, str], ...]`.
|
|
291
|
+
It accepts resolved identities such as `Closure.app_entries`, preserves their
|
|
292
|
+
order, reports watched paths and returns immutable normalized records without
|
|
293
|
+
importing apps or migration modules. Default snapshot discovery calls this same
|
|
294
|
+
function. A settings adapter can use the already resolved `COMPOSE_CLOSURE` during
|
|
295
|
+
an app's `settings(namespace)` callback, annotate copies using owner-declared
|
|
296
|
+
facts, and return concrete `COMPOSE_TRANSITION_SOURCE` records before the snapshot.
|
|
297
|
+
Preserve other records and any explicitly authored replacement source; selecting
|
|
298
|
+
apps again or reading lazy Django settings during configuration is unnecessary.
|
|
299
|
+
An explicit source replaces discovery. Records require
|
|
300
|
+
`declaring_app`, `name`, `app_label` and `module` string keys, and optionally
|
|
301
|
+
`initial_baseline: "satisfied"`; other keys or baseline values are invalid.
|
|
302
|
+
Omission retains strict guard handling. The explicit transition-owner provider
|
|
303
|
+
supplies this assertion; default discovery does not infer it from source modules.
|
|
304
|
+
Modules relative to the declaring app are normalized once. Duplicate
|
|
305
|
+
`<declaring_app>:<name>` origins fail. `Snapshot.transition_records` retains the frozen normalized records;
|
|
293
306
|
`Snapshot.transitions` stores their origin/sha256 pairs. Build and native history
|
|
294
307
|
use the same records.
|
|
295
308
|
|
|
@@ -466,11 +479,31 @@ expansion. Initial `--check` retains Django's exit status 1 for missing history;
|
|
|
466
479
|
are refused before initial schema authoring. If native expansion requires changes
|
|
467
480
|
to an app with existing history, the command refuses before writes and asks the
|
|
468
481
|
caller to author that app's transitions first; existing history bytes remain intact.
|
|
482
|
+
Initial authoring, binding and final reconciliation share an exception rollback
|
|
483
|
+
boundary: restore affected pre-call migration bytes and permissions, remove exact
|
|
484
|
+
newly authored files and invalidate migration imports, without recorder writes.
|
|
485
|
+
A failed attempt can retry from the same disk history. This is exception safety,
|
|
486
|
+
not crash-atomic publication of multiple files.
|
|
469
487
|
|
|
470
488
|
`TransitionBinding` uses frozen snapshot records by default, or explicit
|
|
471
489
|
`declarations=`. It binds native migration origins `<declaring_app>:<name>` to
|
|
472
490
|
the project's actual graph leaves. Each source provides a native `Migration`
|
|
473
|
-
and a pure `applies(ProjectState) -> bool` guard
|
|
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
|
+
its first native disk nodes in this successful command's initial-authoring phase,
|
|
494
|
+
including native prerequisite expansion. The assertion means the final-schema
|
|
495
|
+
initial baseline satisfies this transition on every database adopting it,
|
|
496
|
+
including existing rows adopted through native `migrate --fake-initial`. It does
|
|
497
|
+
not assert that the original operations executed. Existing initial-looking
|
|
498
|
+
files, reset-created initials and global read-only checks supply no exemption.
|
|
499
|
+
True guards always retain their operations, including bootstrap and backfill
|
|
500
|
+
work. A false-guard baseline binding substitutes Django's native empty migration
|
|
501
|
+
before downstream graph state calculation. Its materialization footer seals a
|
|
502
|
+
native zero-operation Migration subclass and `compose_initial_baseline =
|
|
503
|
+
"satisfied"`, omitting any source-class state or database lifecycle overrides. This
|
|
504
|
+
durable origin must be retained like any other native history node after its
|
|
505
|
+
source declaration is removed. Its source bytes and source SHA remain unchanged;
|
|
506
|
+
adding the optional declaration does not rewrite or invalidate existing origins.
|
|
474
507
|
Immutable source/body digests, dependencies, `run_before`, `replaces` and complete
|
|
475
508
|
squash chains are preserved. Materialized history remains executable after its
|
|
476
509
|
source declaration is removed. Changed immutable sources, duplicate origins,
|
|
@@ -479,6 +512,46 @@ Legacy `angee_origin` and `angee_source_sha256` metadata is read only for
|
|
|
479
512
|
historical adoption; new metadata uses `compose_origin` and
|
|
480
513
|
`compose_source_sha256`.
|
|
481
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
|
+
|
|
482
555
|
`DropGuardAutodetector`, shared by native `makemigrations` and `migrate`, requires
|
|
483
556
|
relevant rows or columns to be empty on every database eligible for the native
|
|
484
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
|
|
@@ -156,11 +156,129 @@ helpers still need their providers. A guard that sees a final schema cannot prov
|
|
|
156
156
|
that a data operation already ran. Native dependencies, replacements and complete
|
|
157
157
|
squash chains retain that execution history.
|
|
158
158
|
|
|
159
|
+
A transition owner can explicitly assert that a final-schema initial baseline
|
|
160
|
+
satisfies a transition by adding `initial_baseline: "satisfied"` to its existing
|
|
161
|
+
explicit declaration provider, without editing its immutable migration source:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
# inventory/transitions.py; safe to call before Django setup.
|
|
165
|
+
def declarations():
|
|
166
|
+
return [{
|
|
167
|
+
"declaring_app": "inventory",
|
|
168
|
+
"name": "rename_legacy",
|
|
169
|
+
"app_label": "inventory",
|
|
170
|
+
"module": "inventory.compose_migrations.inventory.rename_legacy",
|
|
171
|
+
"initial_baseline": "satisfied",
|
|
172
|
+
}]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Wire that provider through `COMPOSE_TRANSITION_SOURCE =
|
|
176
|
+
"inventory.transitions.declarations"`. The explicit provider replaces default
|
|
177
|
+
filename discovery, so include every required transition record. Omission is
|
|
178
|
+
strict; no other baseline value is accepted. The frozen declaration participates
|
|
179
|
+
in the snapshot digest while migration source bytes and hashes stay unchanged.
|
|
180
|
+
|
|
181
|
+
Integrations that annotate discovered transitions can reuse the public discovery
|
|
182
|
+
owner instead of maintaining another list or directory scanner:
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
# Inside an integration's autoconfig.settings(namespace) callback:
|
|
186
|
+
from django_compose.snapshot import discover_transitions
|
|
187
|
+
|
|
188
|
+
records = discover_transitions(namespace["COMPOSE_CLOSURE"].app_entries)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
One shared adapter can consult each selected app's own declarations, copy the
|
|
192
|
+
matching records with `dict(record, initial_baseline="satisfied")`, and return
|
|
193
|
+
the resulting ordered sequence as `COMPOSE_TRANSITION_SOURCE`. Keep all other
|
|
194
|
+
records unchanged and respect any explicit project-authored replacement. The
|
|
195
|
+
snapshot then freezes the result; no migration module is imported by discovery.
|
|
196
|
+
The package defines no extra addon metadata format for these policy facts.
|
|
197
|
+
|
|
198
|
+
This is a strong assertion: no original operation is needed on **any** database
|
|
199
|
+
adopting the final-schema baseline, including existing tables and rows adopted
|
|
200
|
+
with native `migrate --fake-initial`. If those rows need conversion or backfill,
|
|
201
|
+
keep that work in a separate native transition whose guard is true on the final
|
|
202
|
+
schema and whose operations handle both empty and preexisting tables. True guards
|
|
203
|
+
always run their original operations, even when the declaration has this option.
|
|
204
|
+
|
|
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.
|
|
208
|
+
Native prerequisite expansion contributes its exact newly initialized labels.
|
|
209
|
+
Existing initial-looking files do not qualify, and ordinary planning/checks and
|
|
210
|
+
history reset stay strict. The sealed `compose_initial_baseline = "satisfied"`
|
|
211
|
+
metadata identifies satisfaction by the baseline, rather than execution of the
|
|
212
|
+
original operations. Planning and sealed history use a native empty migration,
|
|
213
|
+
so source-class state and database lifecycle overrides are omitted too. Keep that
|
|
214
|
+
native origin node after removing the declaration; it preserves source/body digests, imports and resolved graph edges and remains
|
|
215
|
+
executable without the original source module. Imported helpers still need their
|
|
216
|
+
providers.
|
|
217
|
+
|
|
218
|
+
If initial generation, binding or final reconciliation raises, authoring restores
|
|
219
|
+
affected pre-call migration bytes and permissions and removes its exact new
|
|
220
|
+
files. It invalidates migration imports and never writes the migration recorder;
|
|
221
|
+
a retry starts from the same disk history. This exception rollback does not
|
|
222
|
+
promise crash-atomic multi-file filesystem publication. Django owns subsequent
|
|
223
|
+
application and database retry behavior.
|
|
224
|
+
|
|
159
225
|
New bindings use `compose_*` metadata. Existing `angee_origin` and
|
|
160
226
|
`angee_source_sha256` metadata remain readable for historical compatibility;
|
|
161
227
|
there is no need to rewrite old migration files. Check and dry-run paths do not
|
|
162
228
|
create migration packages or files.
|
|
163
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
|
+
|
|
164
282
|
## Advanced: destructive changes and history cutoffs
|
|
165
283
|
|
|
166
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]}")
|