Install
- Type
- Class
- Namespace
- craft\commerce\migrations
- Inherits
- craft\commerce\migrations\Install » craft\db\Migration (opens new window) » yii\db\Migration (opens new window) » yii\base\Component (opens new window) » yii\base\BaseObject (opens new window)
- Implements
- yii\base\Configurable (opens new window), yii\db\MigrationInterface (opens new window)
- Uses traits
- yii\db\SchemaBuilderTrait (opens new window)
- Since
- 2.0
Installation Migration
View source (opens new window)
# Public Properties
Property | Description |
---|---|
behaviors (opens new window) | yii\base\Behavior (opens new window) – List of behaviors attached to this component. |
compact (opens new window) | boolean (opens new window) – Indicates whether the console output should be compacted. |
db (opens new window) | craft\db\Connection (opens new window) – the DB connection that this command is associated with |
maxSqlOutputLength (opens new window) | integer (opens new window) – Max number of characters of the SQL outputted. |
# Public Methods
Method | Description |
---|---|
__call() (opens new window) | Calls the named method which is not a class method. |
__clone() (opens new window) | This method is called after the object is created by cloning an existing one. |
__construct() (opens new window) | Constructor. |
__get() (opens new window) | Returns the value of a component property. |
__isset() (opens new window) | Checks if a property is set, i.e. defined and not null. |
__set() (opens new window) | Sets the value of a component property. |
__unset() (opens new window) | Sets a component property to be null. |
_defaultDonationPurchasable() | Add the donation purchasable |
addColumn() (opens new window) | Builds and executes a SQL statement for adding a new DB column. |
addCommentOnColumn() (opens new window) | Builds and execute a SQL statement for adding comment to column. |
addCommentOnTable() (opens new window) | Builds a SQL statement for adding comment to table. |
addForeignKey() (opens new window) | Builds a SQL statement for adding a foreign key constraint to an existing table. |
addForeignKeys() | Adds the foreign keys. |
addPrimaryKey() (opens new window) | Builds and executes a SQL statement for creating a primary key. |
alterColumn() (opens new window) | Builds and executes a SQL statement for changing the definition of a column. |
archiveTableIfExists() (opens new window) | Creates and executes a SQL statement for renaming a DB table to *_old , if it exists. |
attachBehavior() (opens new window) | Attaches a behavior to this component. |
attachBehaviors() (opens new window) | Attaches a list of behaviors to the component. |
batchInsert() (opens new window) | Creates and executes a batch INSERT SQL statement. |
behaviors() (opens new window) | Returns a list of behaviors that this component should behave as. |
bigInteger() (opens new window) | Creates a bigint column. |
bigPrimaryKey() (opens new window) | Creates a big primary key column. |
binary() (opens new window) | Creates a binary column. |
boolean() (opens new window) | Creates a boolean column. |
canGetProperty() (opens new window) | Returns a value indicating whether a property can be read. |
canSetProperty() (opens new window) | Returns a value indicating whether a property can be set. |
char() (opens new window) | Creates a char column. |
className() (opens new window) | Returns the fully qualified name of this class. |
createIndex() (opens new window) | Builds and executes a SQL statement for creating a new index. |
createIndexIfMissing() (opens new window) | Creates a new index if a similar one doesn’t already exist. |
createIndexes() | Creates the indexes. |
createTable() (opens new window) | Builds and executes a SQL statement for creating a new DB table. |
createTables() | Creates the tables for Craft Commerce |
date() (opens new window) | Creates a date column. |
dateTime() (opens new window) | Creates a datetime column. |
decimal() (opens new window) | Creates a decimal column. |
delete() (opens new window) | Creates and executes a DELETE SQL statement. |
deleteDuplicates() (opens new window) | Creates and executes a DELETE SQL statement that will only delete duplicate rows from a table. |
detachBehavior() (opens new window) | Detaches a behavior from the component. |
detachBehaviors() (opens new window) | Detaches all behaviors from the component. |
double() (opens new window) | Creates a double column. |
down() (opens new window) | This method contains the logic to be executed when removing this migration. |
dropAllForeignKeysToTable() (opens new window) | Creates and executes a SQL statement for dropping all foreign keys to a table. |
dropColumn() (opens new window) | Builds and executes a SQL statement for dropping a DB column. |
dropCommentFromColumn() (opens new window) | Builds and execute a SQL statement for dropping comment from column. |
dropCommentFromTable() (opens new window) | Builds a SQL statement for dropping comment from table. |
dropForeignKey() (opens new window) | Builds a SQL statement for dropping a foreign key constraint. |
dropForeignKeyIfExists() (opens new window) | Creates and executes a SQL statement for dropping a foreign key if it exists. |
dropForeignKeys() | Removes the foreign keys. |
dropIndex() (opens new window) | Builds and executes a SQL statement for dropping an index. |
dropIndexIfExists() (opens new window) | Creates and executes a SQL statement for dropping an index if it exists. |
dropPrimaryKey() (opens new window) | Builds and executes a SQL statement for dropping a primary key. |
dropProjectConfig() | Deletes the project config entry. |
dropTable() (opens new window) | Builds and executes a SQL statement for dropping a DB table. |
dropTableIfExists() (opens new window) | Creates and executes a SQL statement for dropping a DB table, if it exists. |
dropTables() | Drop the tables |
ensureBehaviors() (opens new window) | Makes sure that the behaviors declared in behaviors() (opens new window) are attached to this component. |
enum() (opens new window) | Creates an enum column for MySQL and PostgreSQL, or a string column with a check constraint for others. |
execute() (opens new window) | Executes a SQL statement. |
float() (opens new window) | Creates a float column. |
getBehavior() (opens new window) | Returns the named behavior object. |
getBehaviors() (opens new window) | Returns all behaviors attached to this component. |
hasEventHandlers() (opens new window) | Returns a value indicating whether there is any handler attached to the named event. |
hasMethod() (opens new window) | Returns a value indicating whether a method is defined. |
hasProperty() (opens new window) | Returns a value indicating whether a property is defined for this component. |
init() (opens new window) | Initializes the migration. |
insert() (opens new window) | Creates and executes an INSERT SQL statement. |
insertDefaultData() | Insert the default data. |
integer() (opens new window) | Creates an integer column. |
json() (opens new window) | Creates a JSON column. |
longText() (opens new window) | Creates a longtext column for MySQL, or text column for others. |
mediumText() (opens new window) | Creates a mediumtext column for MySQL, or text column for others. |
money() (opens new window) | Creates a money column. |
off() (opens new window) | Detaches an existing event handler from this component. |
on() (opens new window) | Attaches an event handler to an event. |
primaryKey() (opens new window) | Creates a primary key column. |
renameColumn() (opens new window) | Builds and executes a SQL statement for renaming a column. |
renameSequence() (opens new window) | Creates and executes a SQL statement for renaming a DB sequence. |
renameTable() (opens new window) | Builds and executes a SQL statement for renaming a DB table and its corresponding sequence (if PostgreSQL). |
replace() (opens new window) | Creates and executes a SQL statement for replacing some text with other text in a given table column. |
restore() (opens new window) | 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() (opens new window) | Creates a smallint column. |
softDelete() (opens new window) | Creates and executes a SQL statement for soft-deleting a row. |
string() (opens new window) | Creates a string column. |
text() (opens new window) | Creates a text column. |
time() (opens new window) | Creates a time column. |
timestamp() (opens new window) | Creates a timestamp column. |
tinyInteger() (opens new window) | Creates a tinyint column. If tinyint is not supported by the DBMS, smallint will be used. |
tinyText() (opens new window) | Creates a tinytext column for MySQL, or text column for others. |
trigger() (opens new window) | Triggers an event. |
truncateTable() (opens new window) | Builds and executes a SQL statement for truncating a DB table. |
uid() (opens new window) | Shortcut for creating a uid column |
up() (opens new window) | This method contains the logic to be executed when applying this migration. |
update() (opens new window) | Creates and executes an UPDATE SQL statement. |
upsert() (opens new window) | 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. |
# _defaultDonationPurchasable()
Add the donation purchasable
View source (opens new window)
# addForeignKeys()
Adds the foreign keys.
View source (opens new window)
# createIndexes()
Creates the indexes.
View source (opens new window)
# createTables()
Creates the tables for Craft Commerce
View source (opens new window)
# dropForeignKeys()
Removes the foreign keys.
View source (opens new window)
# dropProjectConfig()
Deletes the project config entry.
View source (opens new window)
# dropTables()
Drop the tables
View source (opens new window)
# insertDefaultData()
Insert the default data.
View source (opens new window)
# safeDown()
This method contains the logic to be executed when removing this migration.
This method differs from down() (opens new window) in that the DB logic implemented here will be enclosed within a DB transaction. Child classes may implement this method instead of down() (opens new window) 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 (opens new window).
View source (opens new window)
Returns
false (opens new window), void
, mixed
– 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() (opens new window) in that the DB logic implemented here will be enclosed within a DB transaction. Child classes may implement this method instead of up() (opens new window) 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 (opens new window).
View source (opens new window)
Returns
false (opens new window), void
, mixed
– Return a false value to indicate the migration fails
and should not proceed further. All other return values mean the migration succeeds.
# Protected Methods
Method | Description |
---|---|
beginCommand() (opens new window) | Prepares for a command to be executed, and outputs to the console. |
endCommand() (opens new window) | Finalizes after the command has been executed, and outputs to the console the time elapsed. |
getDb() (opens new window) |
← VariantMatrix Coupon →