CreateMatrixContentTable

Type
Class
Namespace
craft\migrations
Inherits
craft\migrations\CreateMatrixContentTable » craft\db\Migration » yii\db\Migration » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable, yii\db\MigrationInterface
Uses traits
yii\db\SchemaBuilderTrait
Since
3.0

CreateMatrixContentTable Migration

View source

Public Properties

PropertyDescription
behaviorsyii\base\Behavior – List of behaviors attached to this component
compactboolean – Indicates whether the console output should be compacted.
dbyii\db\Connection, array, string – The DB connection object or the application component ID of the DB connection that this migration should work with.
maxSqlOutputLengthinteger – Max number of characters of the SQL outputted.
tableNamestring, null – The table name

tableName

Type
string, null

The table name

View source

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
addColumn()Builds and executes a SQL statement for adding a new DB column.
addCommentOnColumn()Builds and execute a SQL statement for adding comment to column.
addCommentOnTable()Builds a SQL statement for adding comment to table.
addForeignKey()Builds a SQL statement for adding a foreign key constraint to an existing table.
addForeignKeys()Adds the foreign keys.
addPrimaryKey()Builds and executes a SQL statement for creating a primary key.
alterColumn()Builds and executes a SQL statement for changing the definition of a column.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
batchInsert()Creates and executes an batch INSERT SQL statement.
behaviors()Returns a list of behaviors that this component should behave as.
bigInteger()Creates a bigint column.
bigPrimaryKey()Creates a big primary key column.
binary()Creates a binary column.
boolean()Creates a boolean column.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
char()Creates a char column.
className()Returns the fully qualified name of this class.
createIndex()Builds and executes a SQL statement for creating a new index.
createTable()Builds and executes a SQL statement for creating a new DB table.
date()Creates a date column.
dateTime()Creates a datetime column.
decimal()Creates a decimal column.
delete()Creates and executes a DELETE SQL statement.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
double()Creates a double column.
down()This method contains the logic to be executed when removing this migration.
dropColumn()Builds and executes a SQL statement for dropping a DB column.
dropCommentFromColumn()Builds and execute a SQL statement for dropping comment from column.
dropCommentFromTable()Builds a SQL statement for dropping comment from table.
dropForeignKey()Builds a SQL statement for dropping a foreign key constraint.
dropIndex()Builds and executes a SQL statement for dropping an index.
dropPrimaryKey()Builds and executes a SQL statement for dropping a primary key.
dropTable()Builds and executes a SQL statement for dropping a DB table.
dropTableIfExists()Creates and executes a SQL statement for dropping a DB table, if it exists.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
enum()Creates an enum column for MySQL and PostgreSQL, or a string column with a check constraint for others.
execute()Executes a SQL statement.
float()Creates a float column.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.
insert()Creates and executes an INSERT SQL statement.
integer()Creates an integer column.
json()Creates a JSON column.
longText()Creates a longtext column for MySQL, or text column for others.
mediumText()Creates a mediumtext column for MySQL, or text column for others.
money()Creates a money column.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
primaryKey()Creates a primary key column.
renameColumn()Builds and executes a SQL statement for renaming a column.
renameSequence()Creates and executes a SQL statement for renaming a DB sequence.
renameTable()Builds and executes a SQL statement for renaming a DB table.
replace()Creates and executes a SQL statement for replacing some text with other text in a given table column.
restore()Creates and executes a SQL statement for restoring a soft-deleted row.
safeDown()This method contains the logic to be executed when removing this migration.
safeUp()This method contains the logic to be executed when applying this migration.
smallInteger()Creates a smallint column.
softDelete()Creates and executes a SQL statement for soft-deleting a row.
string()Creates a string column.
text()Creates a text column.
time()Creates a time column.
timestamp()Creates a timestamp column.
tinyInteger()Creates a tinyint column. If tinyint is not supported by the DBMS, smallint will be used.
tinyText()Creates a tinytext column for MySQL, or text column for others.
trigger()Triggers an event.
truncateTable()Builds and executes a SQL statement for truncating a DB table.
uid()Shortcut for creating a uid column
up()This method contains the logic to be executed when applying this migration.
update()Creates and executes an UPDATE SQL statement.
upsert()Creates and executes a command to insert rows into a database table if they do not already exist (matching unique constraints), or update them if they do.

addForeignKeys()

Adds the foreign keys.

View source

safeDown()

This method contains the logic to be executed when removing this migration.

This method differs from down() in that the DB logic implemented here will be enclosed within a DB transaction. Child classes may implement this method instead of down() if the DB logic needs to be within a transaction.

Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples, please refer to implicit commit.

View source

Returns

boolean – Return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

safeUp()

This method contains the logic to be executed when applying this migration.

This method differs from up() in that the DB logic implemented here will be enclosed within a DB transaction. Child classes may implement this method instead of up() if the DB logic needs to be within a transaction.

Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples, please refer to implicit commit.

View source

Returns

boolean – Return a false value to indicate the migration fails and should not proceed further. All other return values mean the migration succeeds.

Protected Methods

MethodDescription
beginCommand()Prepares for a command to be executed, and outputs to the console.
endCommand()Finalizes after the command has been executed, and outputs to the console the time elapsed.
getDb()