Copied!
Abstract
Methods
public description() : string
 

Returns a description of the migration

public abstract down() : bool
 

Returns true if the up migrate worked

public executeAlters() : bool
 

Run all the cached alter statements. You will need to call if this directly if you need to change a table altered in the current migration.

public getAllTables(string $type = 'BASE TABLE') : array
 
  • return string[] of table names
public getErrors() : array
 
  • return string[]
public getMySQLSetting(string $variable) : string
 
  • return string a MySQL setting
public id() : int
 

Returns the migration id. Class name should be Migration_x

public ran() : string
public runSQL(string $sql, array $input = []) : bool
 

Runs the current SQL statement immediately

  • param array $input
public setRan(string $ran) : static
public abstract up() : bool
 

Returns true if the up migrate worked

Properties
protected array $errors = []
 
  • var string[]
protected array $myslqDefaults = ['CURRENT_TIMESTAMP', 'CURRENT_DATE', 'true', 'false', 'b'0'', 'b'1'']
 
  • var string[]
Methods
protected addColumn(string $table, string $field, string $parameters) : bool
 

Always adds a column

protected addForeignKey(string $toTable, string $referenceTable, array $columns, string $onDelete = 'CASCADE', string $onUpdate = 'CASCADE') : bool
 

Creates a foreign key on the table referencing the given table and columns.

  • param string[] $columns
protected addIndex(string $table, array|string $fields, string $indexType = '') : bool
 

Add an index on the fields in the array.

  • param string[]|string $fields
protected addPrimaryKey(string $table, array $fields) : bool
 

Adds a primary key to the table.

  • param string[] $fields
protected addPrimaryKeyAutoIncrement(string $table, string $field = '', string $newFieldName = '') : bool
 

Adds a primary key to the table. If $field is not specified, it will the primary key will be the table name with Id appended. If $newFieldName is not specified, it will default to $field. This method works on an existing field only.

protected alterColumn(string $table, string $field, string $parameters, string $newName = '') : bool
 

Alters a column incluing a reneme if $newName is provided

protected deleteDuplicateRows(string $table, array $keys) : bool
 

Duplicate rows with the same key values will be deleted

  • param string[] $keys
protected dropAllIndexes(string $table) : void
 

Drops all indexes on a table but not the primary key.

protected dropColumn(string $table, string $field) : bool
 

Drops a column if it exists

protected dropForeignKey(string $table, array $columns) : bool
 

Drops the foreign key on the table

  • param string[] $columns
protected dropIndex(string $table, array|string $fields) : bool
 

Drops an index by the name used by addIndex

  • param string[]|string $fields
protected dropPrimaryKey(string $table) : bool
 

Drops the primary key

protected dropTable(string $table) : bool
 

Drops a table if it exists

protected dropTables(array $tables) : void
 

Drops tables contained in the array

  • param string[] $tables
protected dropView(string $view) : bool
 

Drops a view if it exists

protected dropViews(array $views) : void
 

Drops views contained in the array

  • param string[] $views
protected indexExists(string $table, string $indexName) : bool
 

Tests for existance of an index on the table

protected renameTable(string $oldName, string $newName) : bool
 

Renames an existing table

Properties
private array $alters = []
 
  • var array<string,string[]>
private string $ran = ''
Methods
private alter(string $type, string $table, string $field, string $extra = '', string $newName = '') : void
private getFieldInfo(string $table, string $fieldName) : ?PHPFUI\ORM\Schema\Field
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration