abstract class Marten::DB::Management::SchemaEditor::Base

Overview

Base implementation of a database schema editor.

The database schema editor is used in the context of DB management in order to perform operation on models: create / delete models, add new fields, etc. It's heavily used by the migrations mechanism.

Direct Known Subclasses

Defined in:

marten/db/management/schema_editor/base.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(connection : Connection::Base) #

[View source]

Instance Method Detail

abstract def add_column(table : TableState, column : Column::Base) : Nil #

Adds a column to a specific table.


[View source]
abstract def add_index(table : TableState, index : Management::Index) : Nil #

Adds an index to a specific table.


[View source]
abstract def add_unique_constraint(table : TableState, unique_constraint : Management::Constraint::Unique) : Nil #

Adds a unique constraint to a specific table.


[View source]
abstract def change_column(project : ProjectState, table : TableState, old_column : Column::Base, new_column : Column::Base) : Nil #

Changes a column on a specific table.


[View source]
abstract def column_type_for_built_in_column(column : Column::Base) : String #

Returns the database type for a specific built-in column implementation.

Note that this method is only used when handling column types of Marten built-in types as custom column implementations must define a #db_type method.


[View source]
abstract def column_type_suffix_for_built_in_column(column : Column::Base) : String | Nil #

Returns the database type suffix for a specific built-in column implementation.

Note that this method is only used when handling column types of Marten built-in types.


[View source]
abstract def create_table(table : TableState) : Nil #

Creates a new table from a migration table state.


[View source]
abstract def ddl_rollbackable? : Bool #

Returns a boolean indicating if the schema editor implementation supports rollbacking DDL statements.


[View source]
def deferred_statements : Array(Marten::DB::Management::Statement) #

[View source]
abstract def delete_table(name : String) : Nil #

Deletes the a specific table.


[View source]
def delete_table(table : TableState) : Nil #

Deletes the table corresponding to a specific table state.


[View source]
def flush_model_tables : Nil #

Flushes all model tables.


[View source]
abstract def flush_tables(table_names : Array(String)) : Nil #

Flushes all the tables associated with the passed table names.


[View source]
abstract def quoted_default_value_for_built_in_column(value : ::DB::Any) : String #

Returns a prepared default value that can be inserted in a column definition.


[View source]
abstract def remove_column(table : TableState, column : Column::Base) : Nil #

Removes a column from a specific table.


[View source]
abstract def remove_index(table : TableState, index : Management::Index) : Nil #

Removes an index from a specific table.


[View source]
abstract def remove_unique_constraint(table : TableState, unique_constraint : Management::Constraint::Unique) : Nil #

Removes a unique constraint from a specific table.


[View source]
abstract def rename_column(table : TableState, column : Column::Base, new_name : String) #

Renames a specific column.


[View source]
abstract def rename_table(table : TableState, new_name : String) : Nil #

Renames a specific table.


[View source]
def sync_models : Nil #

Syncs all models for the current database connection.

Every model whose table is not yet created will be created at the database level. This method should not be used on production databases (those are likely to be mutated using migrations), but this can be usefull when initializing a database for the first time in development or when running tests.


[View source]