MigrationHelper

Type
Class
Namespace
Craft
Inherits
Craft\MigrationHelper
Since
1.1

Migration utility methods.

See also http://craftcms.com

View source (opens new window)

# Public Methods

Method Description
dropAllForeignKeysOnTable() Drops all the foreign keys on 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.
findForeignKeysTo() Returns a list of all the foreign keys that point to a given table/column.
getTable() Returns info about a given table.
getTables() Returns info about all of the tables.
makeElemental() Creates elements for all rows in a given table, swaps its 'id' PK for 'elementId', and updates the names of any FK's in other tables.
refresh() Refreshes our record of everything.
renameColumn() Renames a column, while also updating any index and FK names that use the column.
renameTable() Renames a table, while also updating its index and FK names, as well as any other FK names pointing to the table.
restoreAllForeignKeysOnTable() Restores all the foreign keys on a table.
restoreAllIndexesOnTable() Restores all the indexes on a table.
restoreAllUniqueIndexesOnTable() Restores all the unique indexes on a table.
restoreForeignKey() Restores a foreign key.
restoreIndex() Restores an index.

# dropAllForeignKeysOnTable()

Drops all the foreign keys on a table.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null dropAllForeignKeysOnTable ( $table )

# dropAllIndexesOnTable()

Drops all the indexes on a table.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null dropAllIndexesOnTable ( $table )

# dropAllUniqueIndexesOnTable()

Drops all the unique indexes on a table.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null dropAllUniqueIndexesOnTable ( $table )

# dropForeignKey()

Signature

public static null dropForeignKey ( $fk )

# dropForeignKeyIfExists()

Drops a foreign key if it exists.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null dropForeignKeyIfExists ( $tableName, $columns )

# dropIndex()

Signature

public static null dropIndex ( $index )

# dropIndexIfExists()

Signature

public static false dropIndexIfExists ( $tableName, $columns, $unique = false )

# findForeignKeysTo()

Returns a list of all the foreign keys that point to a given table/column.

View source (opens new window)

Arguments

Returns

array (opens new window) – A list of the foreign keys pointing to that table/column.

Signature

public static array findForeignKeysTo ( $table, $column = 'id' )

# getTable()

Signature

public static object, null getTable ( $table )

# getTables()

Returns info about all of the tables.

View source (opens new window)

Returns

array (opens new window)

Signature

public static array getTables ( )

# makeElemental()

Creates elements for all rows in a given table, swaps its 'id' PK for 'elementId', and updates the names of any FK's in other tables.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null makeElemental ( $table, $elementType, $hasContent = false, $isLocalized = false, $locales = null )

# refresh()

Refreshes our record of everything.

View source (opens new window)

Returns

null (opens new window)

Signature

public static null refresh ( )

# renameColumn()

Renames a column, while also updating any index and FK names that use the column.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null renameColumn ( $tableName, $oldName, $newName )

# renameTable()

Renames a table, while also updating its index and FK names, as well as any other FK names pointing to the table.

View source (opens new window)

Arguments

Returns

false (opens new window)

Signature

public static false renameTable ( $oldName, $newName )

# restoreAllForeignKeysOnTable()

Restores all the foreign keys on a table.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null restoreAllForeignKeysOnTable ( $table )

# restoreAllIndexesOnTable()

Restores all the indexes on a table.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null restoreAllIndexesOnTable ( $table )

# restoreAllUniqueIndexesOnTable()

Restores all the unique indexes on a table.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public static null restoreAllUniqueIndexesOnTable ( $table )

# restoreForeignKey()

Signature

public static null restoreForeignKey ( $fk )

# restoreIndex()

Signature

public static null restoreIndex ( $index )