class

Marten::DB::Management::SchemaEditor::Base

Inherits Reference / Object

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.

Constructors

new(connection : Connection::Base)
Source

Instance methods

add_column(table : TableState, column : Column::Base) : Nil

Adds a column to a specific table.

Source
add_index(table : TableState, index : Management::Index) : Nil

Adds an index to a specific table.

Source
add_unique_constraint(table : TableState, unique_constraint : Management::Constraint::Unique) : Nil

Adds a unique constraint to a specific table.

Source
change_column(project : ProjectState, table : TableState, old_column : Column::Base, new_column : Column::Base) : Nil

Changes a column on a specific table.

Source
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.

Source
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.

Source
create_table(table : TableState) : Nil

Creates a new table from a migration table state.

Source
ddl_rollbackable?

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

Source
deferred_statements
Source
delete_table(name : String) : Nil

Deletes the a specific table.

Source
delete_table(table : TableState) : Nil

Deletes the table corresponding to a specific table state.

Source
flush_model_tables

Flushes all model tables.

Source
flush_tables(table_names : Array(String)) : Nil

Flushes all the tables associated with the passed table names.

Source
quoted_default_value_for_built_in_column(value : ::DB::Any) : String

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

Source
remove_column(table : TableState, column : Column::Base) : Nil

Removes a column from a specific table.

Source
remove_index(table : TableState, index : Management::Index) : Nil

Removes an index from a specific table.

Source
remove_unique_constraint(table : TableState, unique_constraint : Management::Constraint::Unique) : Nil

Removes a unique constraint from a specific table.

Source
rename_column(table : TableState, column : Column::Base, new_name : String)

Renames a specific column.

Source
rename_table(table : TableState, new_name : String) : Nil

Renames a specific table.

Source
sync_models

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.

Source