class CQL::AlterTable
Reference
< Object
The CQL::AlterTable
class is responsible for handling alterations to the database schema. It allows you to add, drop, rename, and change columns in a table.
Example: Altering a Table
Constructors
def new
Creates a new AlterTable
object.
@return [AlterTable] The new alter table object.
Methods
def add_column(column : Symbol, type : String)
Adds a new column to the table.
@param column [Symbol] The name of the column to add.
@param type [String] The data type of the new column.
@return [AlterTable] The updated alter table object.
Example:
def drop_column(column : Symbol)
Drops a column from the table.
@param column [Symbol] The name of the column to drop.
@return [AlterTable] The updated alter table object.
Example:
def rename_column(old_name : Symbol, new_name : Symbol)
Renames a column in the table.
@param old_name [Symbol] The current name of the column.
@param new_name [Symbol] The new name for the column.
@return [AlterTable] The updated alter table object.
Example:
def change_column(column : Symbol, new_type : String)
Changes the data type of a column.
@param column [Symbol] The name of the column to change.
@param new_type [String] The new data type for the column.
@return [AlterTable] The updated alter table object.
Example: