abstract class Marten::DB::Migration::Operation::Base

Overview

Base abstract class for migration operations.

A migration operation is responsible for (i) mutating project states in order to identify changes to a given set of models and (ii) mutating actual databases (applying or unapplying a given operation at the database level).

Included Modules

Direct Known Subclasses

Defined in:

marten/db/migration/operation/base.cr

Instance Method Summary

Instance methods inherited from module Marten::DB::CanFormatStringsOrSymbols

format_string_or_symbol(value : String) format_string_or_symbol

Instance Method Detail

abstract def describe : String #

Returns a human-friendly description of what the operation is doing.


[View source]
def faked=(faked : Bool) #

Allows to set whether or not the mutation should be faked.


[View source]
def faked? : Bool #

Returns true if the mutation should be faked.


[View source]
abstract def mutate_db_backward(app_label : String, schema_editor : Management::SchemaEditor::Base, from_state : Management::ProjectState, to_state : Management::ProjectState) : Nil #

Applies the operation in a backward way at the database level.

For most operation, this will involve "unapplying" whatever was done as part of the #mutate_db_forward method.


[View source]
abstract def mutate_db_forward(app_label : String, schema_editor : Management::SchemaEditor::Base, from_state : Management::ProjectState, to_state : Management::ProjectState) : Nil #

Applies the operation at the database level.


[View source]
abstract def mutate_state_forward(app_label : String, state : Management::ProjectState) : Nil #

Applies the operation at the project state level.


[View source]
abstract def optimize(operation : Base) : Optimization::Result #

Combines the specified operation with the current one and return an array of corresponding operations.


[View source]
abstract def references_column?(other_table_name : String, other_column_name : String) : Bool #

Returns true if the operation references the specified table column.


[View source]
abstract def references_table?(other_table_name : String) : Bool #

Returns true if the operation references the specified table.


[View source]
abstract def serialize : String #

Renders a serialized version of the mutation.

This method is used when generating migrations: the serialized operation is inserted in the #plan method of the generated migration.


[View source]