DDL
DDL API in my ORM
TableManipulationInterface
Method:
alterTable:
tableName: The name of the table to be altered (string).
getQueryString: Boolean value indicating whether to get the query string (boolean).
Returns:
AlterTableResultInterface
, which includes various methods for table manipulation.
AlterTableResultInterface
Methods:
addColumn:
parameters: An object with parameters for adding a column, including
columnName
andoptions
(depending on the database).
deleteColumn:
parameters: An object with parameters for deleting a column, including
columnName
(depending on the database).
addDefaultValue:
parameters: An object with parameters for adding a default value, including
columnName
andvalue
.
dropDefaultValue:
parameters: An object with parameters for removing a default value, including
columnName
.
changeDataTypeOfColumn:
parameters: An object with parameters for changing the data type of a column, including
columnName
,dataType
,length
,precision
,scale
.
addNotNullToColumn:
parameters: An object with parameters for adding a NOT NULL constraint, including
columnName
.
dropNotNullFromColumn:
parameters: An object with parameters for removing a NOT NULL constraint, including
columnName
.
addUniqueToColumn:
parameters: An object with parameters for adding a unique constraint, including
columnName
and optionalconstraintName
(depending on the database).
renameColumn:
parameters: An object with parameters for renaming a column, including
columnName
andfutureColumnName
.
renameTable:
parameters: An object with parameters for renaming a table, including
tableName
.
addCheckConstraintToColumn:
parameters: An object with parameters for adding a check constraint, including
columnName
,check
, and optionalnameOfCheckConstraint
.
deleteCheckConstraintOfColumn:
parameters: An object with parameters for deleting a check constraint, including
columnName
.
dropConstraint:
parameters: An object with parameters for removing a constraint, including
constraintName
.
deleteUniqueFromColumn:
parameters: An object with parameters for removing a unique constraint, including
columnName
.
addPrimaryGeneratedColumn:
parameters: An object with parameters for adding an auto-generated column, including
columnName
,type
, and optional additional parameters (depending on the database).
addForeignKey:
parameters: An object with parameters for adding a foreign key, including
foreignKey
,referencedTable
,referencedColumn
.
addComputedColumn:
parameters: An object with parameters for adding a computed column, including
dataType
,calculate
, and optional additional parameters (depending on the database).
dropTable:
parameters: An object with parameters for removing a table, including optional drop type and existence check parameters (depending on the database).
Method Parameters
AddColumnInterface
columnName: The name of the column (string).
options: Column options, such as data type, length, uniqueness, etc. (depends on the database).
ColumnOptionsInterface
Postgres:
dataType
,nullable
,length
,check
,nameOfCheckConstraint
,defaultValue
,unique
,nullsNotDistinct
.MySQL:
dataType
,nullable
,length
,check
,nameOfCheckConstraint
,defaultValue
,unique
,displayWidth
,isUnsigned
,isZerofill
,isAutoIncrement
,values
,scale
,precision
.
DeleteColumnInterface
Postgres:
columnName
, optionalisCascade
.MySQL:
columnName
.
AddDefaultValueInterface
columnName: The name of the column (string).
value: The default value (string, number, or boolean).
DropDefaultValueInterface
columnName: The name of the column (string).
ChangeColumnDatatypeInterface
columnName: The name of the column (string).
dataType: The new data type (string).
length, precision, scale: Additional data type parameters (strings).
AddNotNullToColumnInterface
columnName: The name of the column (string).
DropNotNullFromColumnInterface
columnName: The name of the column (string).
AddUniqueToColumnInterface
Postgres:
columnName
, optionalconstraintName
.MySQL:
columnName
.
RenameColumnInterface
columnName: The name of the existing column (string).
futureColumnName: The new name of the column (string).
RenameTableInterface
tableName: The name of the table (string).
AddCheckConstraintToColumnInterface
columnName: The name of the column (string).
check: The check expression (string).
nameOfCheckConstraint: The name of the constraint (optional, string).
DeleteCheckConstraintOfColumnInterface
columnName: The name of the column (string).
DropConstraintInterface
constraintName: The name of the constraint (string).
DeleteUniqueFromColumnInterface
columnName: The name of the column (string).
AddPrimaryGeneratedColumnInterface
Postgres:
columnName
,type
, optionalstartWith
,incrementBy
,minValue
,maxValue
,isCycle
,cache
,ownedBy
,restartWith
,noOrder
.MySQL:
columnName
,type
, optionalstartWith
,incrementBy
,minValue
,maxValue
,isCycle
,cache
,ownedBy
.
AddForeignKeyInterface
foreignKey: The name of the foreign key (string).
referencedTable: The name of the table referenced by the key (string).
referencedColumn: The name of the column referenced by the key (string).
AddComputedColumnInterface
Postgres:
dataType
,calculate
.MySQL:
dataType
,calculate
, optionalstored
.
DropTableInterface
Postgres: Optional
type
(CASCADE or RESTRICT) andifExist
.MySQL: Optional
ifExist
.
Last updated