\CodeIgniter\Database\SQLite3Table

Class Table

Provides missing features for altering tables that are common in other supported databases, but are missing from SQLite. These are needed in order to support migrations during testing when another database is used as the primary engine, but SQLite in memory databases are used for faster test execution.

Summary

Methods
Properties
Constants
__construct()
fromTable()
run()
dropColumn()
modifyColumn()
dropForeignKey()
No public properties found
No constants found
createTable()
copyData()
formatFields()
formatKeys()
dropIndexes()
$fields
$keys
$foreignKeys
$tableName
$prefixedTableName
$db
$forge
N/A
No private methods found
No private properties found
N/A

Properties

$fields

$fields : array

All of the fields this table represents.

Type

array

$keys

$keys : array

All of the unique/primary keys in the table.

Type

array

$foreignKeys

$foreignKeys : array

All of the foreign keys in the table.

Type

array

$tableName

$tableName : string

The name of the table we're working with.

Type

string

$prefixedTableName

$prefixedTableName : string

The name of the table, with database prefix

Type

string

Methods

fromTable()

fromTable(string  $table) : \CodeIgniter\Database\SQLite3\Table

Reads an existing database table and collects all of the information needed to recreate this table.

Parameters

string $table

Returns

\CodeIgniter\Database\SQLite3\Table

run()

run() : boolean

Called after `fromTable` and any actions, like `dropColumn`, etc, to finalize the action. It creates a temp table, creates the new table with modifications, and copies the data over to the new table.

Returns

boolean

dropColumn()

dropColumn(string  $column) : \CodeIgniter\Database\SQLite3\Table

Drops a column from the table.

Parameters

string $column

Returns

\CodeIgniter\Database\SQLite3\Table

modifyColumn()

modifyColumn(array  $field) : \CodeIgniter\Database\SQLite3\Table

Modifies a field, including changing data type, renaming, etc.

Parameters

array $field

Returns

\CodeIgniter\Database\SQLite3\Table

dropForeignKey()

dropForeignKey(string  $column) : \CodeIgniter\Database\SQLite3\Table

Drops a foreign key from this table so that it won't be recreated in the future.

Parameters

string $column

Returns

\CodeIgniter\Database\SQLite3\Table

createTable()

createTable() : mixed

Creates the new table based on our current fields.

Returns

mixed

copyData()

copyData() : void

Copies data from our old table to the new one, taking care map data correctly based on any columns that have been renamed.

formatFields()

formatFields(array|boolean  $fields) : mixed

Converts fields retrieved from the database to the format needed for creating fields with Forge.

Parameters

array|boolean $fields

Returns

mixed

formatKeys()

formatKeys(mixed  $keys) : mixed

Converts keys retrieved from the database to the format needed to create later.

Parameters

mixed $keys

Returns

mixed

dropIndexes()

dropIndexes() : null|void

Attempts to drop all indexes and constraints from the database for this table.

Returns

null|void