Skip to content

Lakehouse

The AMSDAL Lakehouse records a complete history of both your data and your data schemas. Every mutation creates a new immutable version — enabling audit trails, time-travel queries, and rollback.

How It Works

The Lakehouse uses a historical connection — an immutable data store where records are never updated or deleted. Instead, each change creates a new version:

  • Data history: every save() and delete() creates a new version of the object
  • Schema history: every migration creates a new version of the class schema
  • Transaction history: every transaction is logged with links to all affected objects

Supported Backends

Backend Config alias Notes
PostgreSQL postgres-historical Recommended for production
SQLite sqlite-historical Good for local development

Async variants: postgres-historical-async, sqlite-historical-async.

Configuration

Add a historical connection to your config.yml:

connections:
  - name: my-lakehouse
    backend: postgres-historical
    credentials:
      - dsn: postgresql://user:password@localhost:5432/lakehouse_db

resources_config:
  lakehouse: my-lakehouse

Querying Historical Data

Use .using('lakehouse') to query the historical connection:

from amsdal import Versions

# All versions of all persons
all_versions = Person.objects.using('lakehouse').filter(
    _address__object_version=Versions.ALL,
).execute()

# Only the latest version of each person
latest = Person.objects.using('lakehouse').filter(
    _address__object_version=Versions.LATEST,
).execute()
from amsdal import Versions

all_versions = await Person.objects.using('lakehouse').filter(
    _address__object_version=Versions.ALL,
).aexecute()

latest = await Person.objects.using('lakehouse').filter(
    _address__object_version=Versions.LATEST,
).aexecute()

See Field Lookups — Address for more version filtering options, and Transactions — Rollback for rolling back to a previous state.