class Marten::DB::Management::Migrations::Graph

Overview

Represents a directed acyclic graph of migrations.

In such graph, every migration corresponds to a node in the graph while dependencies between migrations correspond to edges. Thus if a migration X depends on a migration Y, an edge between Y and X will be defined indicating that Y must be applied before X.

Defined in:

marten/db/management/migrations/graph.cr
marten/db/management/migrations/graph/node.cr

Instance Method Summary

Instance Method Detail

def add_dependency(migration : Migration, dependency_id : String) #

Configures a migration dependency.


[View source]
def add_node(migration : Migration) #

Adds a migration object to the graph.


[View source]
def ensure_acyclic_property : Nil #

Verifies that the graph does not contain cycles.


[View source]
def find_node(id : String) #

Returns the node associated with a given migration ID.


[View source]
def leaves #

Return the leaves of the graph.

Leaves correspond to migration nodes that don't have any child (that is no other migrations depend on them) inside their app.


[View source]
def path_backward(migration : Migration) #

Returns an array of migration nodes to unapply in order to unapply a specific migration node node.

The returned array will start with the nodes that depend on the target node and will end with the target node. The resulting "path" should be followed in order to unapply the migration corresponding to the target node.


[View source]
def path_backward(target_node : Node) #

Returns an array of migration nodes to unapply in order to unapply a specific migration node node.

The returned array will start with the nodes that depend on the target node and will end with the target node. The resulting "path" should be followed in order to unapply the migration corresponding to the target node.


[View source]
def path_forward(migration : Migration) #

Returns an array of migration nodes to apply in order to apply a specific migration node.

The returned array will start with the depdendencies of the target node and will end with the target node. The resulting "path" should be followed in order to apply the migration corresponding to the target node.


[View source]
def path_forward(target_node : Node) #

Returns an array of migration nodes to apply in order to apply a specific migration node.

The returned array will start with the depdendencies of the target node and will end with the target node. The resulting "path" should be followed in order to apply the migration corresponding to the target node.


[View source]
def roots #

Return the roots of the graph.

Roots correspond to migration nodes that don't have any dependencies inside their app.


[View source]
def setup_replacement(migration : Migration) #

Setup a replacement migration.

From a Marten::DB::Migration object defining replacements, this method ensures that all the "replaced" migrations are removed from the current graph. All other migrations referencing the replaced migrations are updated to reference the replacing migration.


[View source]
def teardown_replacement(migration : Migration) #

Teardown a replacement migration.

From a Marten::DB::Migration object defining replacements, this method ensures that the replacement migration is removed from the graph and that the replacement migrations reference the replacement migration child nodes.


[View source]
def to_project_state #

Returns the project state corresponding to the considered graph of migration nodes.


[View source]