DatabaseSchemaService
class DatabaseSchemaService (View source)
Methods
List all tables in the current database
Create a new table
Create the secondary indexes declared for a table.
Add the foreign keys declared for a table via ALTER TABLE. Call after every table exists.
Execute multiple prepared statement operations with different parameter sets
Drop an existing table
Details
__construct(PDO $db)
No description
array
listTables()
List all tables in the current database
void
createTable(string $name, array $fields, array $options = array())
Create a new table
void
createIndexes(string $tableName, array $indexes)
Create the secondary indexes declared for a table.
Accepts both structure-array shapes: nested (['fields' => ['col' => []], 'type' => 'unique'])
and flat (['col1', 'col2', 'unique' => true]). On PostgreSQL/SQLite index names are
schema-global, so a name that doesn't already carry the table name is prefixed with it to
avoid collisions between the generic names the structure array reuses across tables.
void
createForeignKeys(string $tableName, array $foreignKeys)
Add the foreign keys declared for a table via ALTER TABLE. Call after every table exists.
SQLite is skipped: it can only declare foreign keys inline at CREATE TABLE time (no ALTER TABLE ADD CONSTRAINT), matching the installer's long-standing behavior there.
void
executeMultiple(PDOStatement $stmt, array $params)
Execute multiple prepared statement operations with different parameter sets
void
dropTable(string $name)
Drop an existing table