abstract class Marten::DB::Management::SchemaEditor::Base
- Marten::DB::Management::SchemaEditor::Base
- Reference
- Object
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
- Marten::DB::Management::SchemaEditor::MySQL
- Marten::DB::Management::SchemaEditor::PostgreSQL
- Marten::DB::Management::SchemaEditor::SQLite
Defined in:
marten/db/management/schema_editor/base.crConstructors
Instance Method Summary
-
#add_column(table : TableState, column : Column::Base) : Nil
Adds a column to a specific table.
-
#add_index(table : TableState, index : Management::Index) : Nil
Adds an index to a specific table.
-
#add_unique_constraint(table : TableState, unique_constraint : Management::Constraint::Unique) : Nil
Adds a unique constraint to a specific table.
-
#change_column(project : ProjectState, table : TableState, old_column : Column::Base, new_column : Column::Base) : Nil
Changes a column on a specific table.
-
#column_type_for_built_in_column(column : Column::Base) : String
Returns the database type for a specific built-in column implementation.
-
#column_type_suffix_for_built_in_column(column : Column::Base) : String | Nil
Returns the database type suffix for a specific built-in column implementation.
-
#create_table(table : TableState) : Nil
Creates a new table from a migration table state.
-
#ddl_rollbackable? : Bool
Returns a boolean indicating if the schema editor implementation supports rollbacking DDL statements.
- #deferred_statements : Array(Marten::DB::Management::Statement)
-
#delete_table(name : String) : Nil
Deletes the a specific table.
-
#delete_table(table : TableState) : Nil
Deletes the table corresponding to a specific table state.
-
#flush_model_tables : Nil
Flushes all model tables.
-
#flush_tables(table_names : Array(String)) : Nil
Flushes all the tables associated with the passed table names.
-
#quoted_default_value_for_built_in_column(value : ::DB::Any) : String
Returns a prepared default value that can be inserted in a column definition.
-
#remove_column(table : TableState, column : Column::Base) : Nil
Removes a column from a specific table.
-
#remove_index(table : TableState, index : Management::Index) : Nil
Removes an index from a specific table.
-
#remove_unique_constraint(table : TableState, unique_constraint : Management::Constraint::Unique) : Nil
Removes a unique constraint from a specific table.
-
#rename_column(table : TableState, column : Column::Base, new_name : String)
Renames a specific column.
-
#rename_table(table : TableState, new_name : String) : Nil
Renames a specific table.
-
#sync_models : Nil
Syncs all models for the current database connection.
Constructor Detail
Instance Method Detail
Adds a column to a specific table.
Adds an index to a specific table.
Adds a unique constraint to a specific table.
Changes a column on a specific table.
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.
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.
Creates a new table from a migration table state.
Returns a boolean indicating if the schema editor implementation supports rollbacking DDL statements.
Deletes the table corresponding to a specific table state.
Flushes all the tables associated with the passed table names.
Returns a prepared default value that can be inserted in a column definition.
Removes a column from a specific table.
Removes an index from a specific table.
Removes a unique constraint from a specific table.
Renames a specific column.
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.