MigrationHelper
- Type
- Class
- Namespace
- craft\helpers
- Inherits
- craft\helpers\MigrationHelper
- Since
- 3.0.0
Migration utility methods.
# Public Methods
Method | Description |
---|---|
doesForeignKeyExist() | Returns whether a foreign key exists. |
doesIndexExist() | Returns whether an index exists. |
dropAllForeignKeysOnTable() | Drops all the foreign keys on a table. |
dropAllForeignKeysToTable() | Drops all the foreign keys that reference a table. |
dropAllIndexesOnTable() | Drops all the indexes on a table. |
dropAllUniqueIndexesOnTable() | Drops all the unique indexes on a table. |
dropForeignKey() | Drops a foreign key. |
dropForeignKeyIfExists() | Drops a foreign key if it exists. |
dropIndex() | Drops an index. |
dropIndexIfExists() | Drops an index if it exists. |
dropTable() | Drops a table, its own foreign keys, and any foreign keys referencing it. |
findForeignKey() | Returns whether a foreign key exists. |
findForeignKeysTo() | Returns a list of all the foreign keys that point to a given table/column. |
renameColumn() | Renames a column, while also updating any index and FK names that use the column. |
renameTable() | Renames a table, while also updating its sequence, index, and FK names, as well as any other FK names pointing to the table. |
restoreForeignKey() | Restores a foreign key. |
restoreIndex() | Restores an index. |
# doesForeignKeyExist()
Returns whether a foreign key exists.
Arguments
Returns
# doesIndexExist()
Returns whether an index exists.
Arguments
Returns
# dropAllForeignKeysOnTable()
Drops all the foreign keys on a table.
Arguments
$tableName
(string)$migration
(craft\db\Migration, null)
Returns
array – An array of the foreign keys that were just dropped.
# dropAllForeignKeysToTable()
Drops all the foreign keys that reference a table.
Arguments
$tableName
(string)$migration
(craft\db\Migration, null)
# dropAllIndexesOnTable()
Drops all the indexes on a table.
Arguments
$tableName
(string)$migration
(craft\db\Migration, null)
Returns
array – An array of the indexes that were just dropped.
# dropAllUniqueIndexesOnTable()
DEPRECATED
Deprecated in 3.1.0
Drops all the unique indexes on a table.
Arguments
$tableName
(string)$migration
(craft\db\Migration, null)
# dropForeignKey()
Drops a foreign key.
Arguments
$tableName
(string)$columns
(string, string[])$migration
(craft\db\Migration, null)
# dropForeignKeyIfExists()
Drops a foreign key if it exists.
Arguments
$tableName
(string)$columns
(string, string[])$migration
(craft\db\Migration, null)
# dropIndex()
DEPRECATED
Deprecated in 3.1.0. Use dropIndexIfExists() instead.
Drops an index.
Arguments
$tableName
(string)$columns
(string, string[])$unique
(boolean)$migration
(craft\db\Migration, null)
# dropIndexIfExists()
Drops an index if it exists.
Arguments
$tableName
(string)$columns
(string, string[])$unique
(boolean)$migration
(craft\db\Migration, null)
# dropTable()
Drops a table, its own foreign keys, and any foreign keys referencing it.
Arguments
$tableName
(string)$migration
(craft\db\Migration, null)
# findForeignKey()
- Since
- 3.0.27
Returns whether a foreign key exists.
Arguments
Returns
string, null – The foreign key name, or null if it doesn't exist
# findForeignKeysTo()
Returns a list of all the foreign keys that point to a given table/column.
Arguments
$tableName
(string) – The table the foreign keys should point to.$column
(string) – The column the foreign keys should point to. Defaults to 'id'.
Returns
array – A list of the foreign keys pointing to that table/column.
# renameColumn()
Renames a column, while also updating any index and FK names that use the column.
Arguments
$tableName
(string)$oldName
(string)$newName
(string)$migration
(craft\db\Migration, null)
# renameTable()
Renames a table, while also updating its sequence, index, and FK names, as well as any other FK names pointing to the table.
Arguments
$oldName
(string)$newName
(string)$migration
(craft\db\Migration, null)
# restoreForeignKey()
DEPRECATED
Deprecated in 3.1.0
Restores a foreign key.
Arguments
$tableName
(string)$columns
(string, string[])$refTable
(string)$refColumns
(array)$onUpdate
(string)$onDelete
(string)$migration
(craft\db\Migration, null)
# restoreIndex()
DEPRECATED
Deprecated in 3.1.0
Restores an index.
Arguments
← MailerHelper Number →