Skip to content

Latest commit

 

History

History
100 lines (54 loc) · 4.81 KB

File metadata and controls

100 lines (54 loc) · 4.81 KB
graph LR
    SchemaDiffer["SchemaDiffer"]
    MigrationManager["MigrationManager"]
    SchemaSnapshot["SchemaSnapshot"]
    Serialisation["Serialisation"]
    CommandsNew["CommandsNew"]
    CommandsForwards["CommandsForwards"]
    PiccoloTable["PiccoloTable"]
    QueryMethodsAlter["QueryMethodsAlter"]
    SchemaDiffer -- "reads definitions from" --> PiccoloTable
    SchemaDiffer -- "relies on" --> SchemaSnapshot
    CommandsForwards -- "orchestrates" --> MigrationManager
    MigrationManager -- "interacts with" --> QueryMethodsAlter
    SchemaSnapshot -- "uses" --> Serialisation
    CommandsNew -- "initiates" --> SchemaDiffer
    CommandsNew -- "uses" --> SchemaSnapshot
Loading

CodeBoardingDemoContact

Details

The Piccolo migration subsystem automates database schema evolution. It centers around SchemaDiffer, which compares the current PiccoloTable definitions with a SchemaSnapshot to identify schema changes. These changes are then used by CommandsNew to generate new migration files. For applying these migrations, CommandsForwards orchestrates the MigrationManager, which in turn interacts with QueryMethodsAlter to execute the necessary DDL operations on the database. SchemaSnapshot relies on Serialisation for storing and retrieving schema definitions, ensuring a consistent reference point for schema comparisons. This design ensures a robust and automated process for managing database schema changes.

SchemaDiffer

Compares the current application's ORM PiccoloTable definitions with a stored SchemaSnapshot to identify differences and generates AlterStatements (migration operations).

Related Classes/Methods:

MigrationManager

Executes generated AlterStatements against the database to modify the schema, handling both forward application and backward reversion of migrations.

Related Classes/Methods:

SchemaSnapshot

Manages the creation, storage, and retrieval of database schema snapshots, serving as a historical reference point for schema comparisons.

Related Classes/Methods:

Serialisation

Handles the serialization and deserialization of Python objects (specifically Table and Column definitions) to enable SchemaSnapshot storage and retrieval.

Related Classes/Methods:

CommandsNew

The CLI command responsible for automatically generating new migration files based on schema changes detected by SchemaDiffer.

Related Classes/Methods:

CommandsForwards

The CLI command for applying pending migrations to the database by orchestrating the MigrationManager.

Related Classes/Methods:

PiccoloTable

Represents the desired database schema as defined by the application's ORM models, serving as the authoritative input for SchemaDiffer.

Related Classes/Methods:

QueryMethodsAlter

Part of Piccolo's Query Builder, responsible for performing DDL (Data Definition Language) operations on the database, utilized by MigrationManager to execute schema changes.

Related Classes/Methods: