Skip to content

Spike: prove that a Django-managed archive database works #362

Description

@bjester

Overview

This spike (milestone M0) tests the risky parts of the archive design before other work starts. The spike code is temporary. The result is a set of findings, and changes to the design spec if a finding disagrees with it.

Background & Motivation

The disk export writes an archive: a SQLite file that Django manages as a second database. Morango has never used a second database at runtime. Several parts of the design depend on Django and django-mptt behavior that nobody tested in this codebase.

If one of these assumptions is wrong, later tasks build on a bad base. A short spike finds these problems early and at low cost.

Design: spec. Plan: implementation plan, Task 1.

Description & Expected Outcomes

The spike answers these questions:

  • Can Django 3.2 add a database alias at runtime, with full default settings?
  • Can MigrationExecutor create all morango tables in that alias, without the contenttypes app?
  • Does django-mptt send queries to the default database when a certificate is saved with save(using=alias)?
  • Can bulk_create with explicit tree fields write a certificate chain that parent walks can read?
  • Does PRAGMA auto_vacuum=INCREMENTAL, set before migration, let PRAGMA incremental_vacuum shrink the file?
  • Can the alias be removed again, so that no trace stays in connections.databases?

The spike runs on a SQLite host and on a PostgreSQL host.

Deliverables & Contracts

The spike delivers:

  • Written findings for each question.
  • Updates to spec §3.3 or §3.5 when a finding disagrees with the spec.
  • No code that stays in the repository.

Acceptance Criteria

  • Each question has a recorded answer, with the host database (SQLite or PostgreSQL) for each result.
  • If a finding disagrees with the spec, the spec is updated before Explicit database handle for sync database access #365 starts.
  • The tests/testapp/tests/spike/ directory does not exist at the end of the task.

Technical Pointers & Architecture

  • Target Components: Django connections handling, django.db.migrations.executor.MigrationExecutor, morango/models/certificates.py (Certificate, an MPTT model).
  • Related Patterns: morango/deferrable_foreign_keys.py already works with schema_editor.connection in a migration.
  • Data Model & Schema Considerations: The morango migrations declare no dependencies on other apps (0001_squashed_0024…).
  • Resilience & Failure Modes: The spike records whether a restrictive router or a missing default setting causes a clear error.

Notes & Tradeoffs

Metadata

  • Complexity: Medium
  • Target Branch: release-v0.9.x

AI Usage

Drafted with Claude (Claude Code) from the approved design spec and implementation plan. The author reviewed the requirements, and the code references were checked against the release-v0.9.x codebase.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions