PostgreSQLSchemaManager
extends AbstractSchemaManager
in package
PostgreSQL Schema Manager.
Tags
Table of Contents
Properties
- $_conn : Connection
- Holds instance of the Doctrine connection for this schema manager.
- $_platform : T
- Holds instance of the database platform used for this schema manager.
- $existingSchemaPaths : array<string|int, string>|null
Methods
- __construct() : mixed
- alterSchema() : void
- Alters an existing schema.
- alterTable() : void
- Alters an existing tables schema.
- createComparator() : Comparator
- createConstraint() : void
- Creates a constraint on a table.
- createDatabase() : void
- Creates a new database.
- createForeignKey() : void
- Creates a new foreign key.
- createIndex() : void
- Creates a new index on a table.
- createSchema() : Schema
- Creates a schema instance for the current database.
- createSchemaConfig() : SchemaConfig
- Creates the configuration for this schema.
- createSchemaObjects() : void
- createSequence() : void
- Creates a new sequence.
- createTable() : void
- Creates a new table.
- createUniqueConstraint() : void
- Creates a unique constraint on a table.
- createView() : void
- Creates a new view.
- dropAndCreateConstraint() : void
- Drops and creates a constraint.
- dropAndCreateDatabase() : void
- Drops and creates a new database.
- dropAndCreateForeignKey() : void
- Drops and creates a new foreign key.
- dropAndCreateIndex() : void
- Drops and creates a new index on a table.
- dropAndCreateSequence() : void
- Drops and create a new sequence.
- dropAndCreateTable() : void
- Drops and creates a new table.
- dropAndCreateView() : void
- Drops and creates a new view.
- dropConstraint() : void
- Drops the constraint from the given table.
- dropDatabase() : void
- Drops a database.
- dropForeignKey() : void
- Drops a foreign key from a table.
- dropIndex() : void
- Drops the index from the given table.
- dropSchema() : void
- Drops a schema.
- dropSchemaObjects() : void
- dropSequence() : void
- Drops a sequence with a given name.
- dropTable() : void
- Drops the given table.
- dropUniqueConstraint() : void
- Drops the unique constraint from the given table.
- dropView() : void
- Drops a view.
- getDatabasePlatform() : T
- Returns the associated platform.
- getSchemaNames() : array<string|int, string>
- Gets all the existing schema names.
- getSchemaSearchPaths() : array<string|int, string>
- The search path for namespaces in the currently connected database.
- introspectSchema() : Schema
- Returns a {@see Schema} instance representing the current database schema.
- introspectTable() : Table
- Introspects the table with the given name.
- listDatabases() : array<string|int, string>
- Lists the available databases for this connection.
- listNamespaceNames() : array<string|int, string>
- Returns a list of all namespaces in the current database.
- listSchemaNames() : array<int, string>
- Returns a list of the names of all schemata in the current database.
- listSequences() : array<string|int, Sequence>
- Lists the available sequences for this connection.
- listTableColumns() : array<string|int, Column>
- Lists the columns for a given table.
- listTableDetails() : Table
- listTableForeignKeys() : array<string|int, ForeignKeyConstraint>
- Lists the foreign keys for the given table.
- listTableIndexes() : array<string|int, Index>
- Lists the indexes for a given table returning an array of Index instances.
- listTableNames() : array<string|int, string>
- Returns a list of all tables in the current database.
- listTables() : array<int, Table>
- Lists the tables for this connection.
- listViews() : array<string|int, View>
- Lists the views this connection has.
- migrateSchema() : void
- Migrates an existing schema to a new schema.
- renameTable() : void
- Renames a given table to another name.
- tablesExist() : bool
- Returns true if all the given tables exist.
- tryMethod() : mixed
- Tries any method on the schema manager. Normally a method throws an exception when your DBMS doesn't support it or if an error occurs.
- _getPortableDatabaseDefinition() : mixed
- _getPortableDatabasesList() : array<string|int, string>
- _getPortableSequenceDefinition() : Sequence
- _getPortableSequencesList() : array<string|int, Sequence>
- _getPortableTableColumnDefinition() : Column
- Gets Table Column Definition.
- _getPortableTableColumnList() : array<string|int, Column>
- Independent of the database the keys of the column list result are lowercased.
- _getPortableTableDefinition() : string
- _getPortableTableForeignKeyDefinition() : ForeignKeyConstraint
- _getPortableTableForeignKeysList() : array<string|int, ForeignKeyConstraint>
- _getPortableTableIndexesList() : array<string|int, Index>
- Aggregates and groups the index results according to the required data result.
- _getPortableTablesList() : array<string|int, string>
- _getPortableViewDefinition() : View|false
- _getPortableViewsList() : array<string|int, View>
- doListTableColumns() : array<string|int, Column>
- doListTableDetails() : Table
- doListTableForeignKeys() : array<string|int, ForeignKeyConstraint>
- doListTableIndexes() : array<string|int, Index>
- doListTableNames() : array<int, string>
- doListTables() : array<int, Table>
- fetchForeignKeyColumnsByTable() : array<string, array<int, array<string, mixed>>>
- Fetches definitions of foreign key columns in the specified database and returns them grouped by table name.
- fetchIndexColumnsByTable() : array<string, array<int, array<string, mixed>>>
- Fetches definitions of index columns in the specified database and returns them grouped by table name.
- fetchTableColumnsByTable() : array<string, array<int, array<string, mixed>>>
- Fetches definitions of table columns in the specified database and returns them grouped by table name.
- fetchTableOptionsByTable() : array<string, array<string, mixed>>
- Fetches table options for the tables in the specified database and returns them grouped by table name.
- filterAssetNames() : array<string|int, mixed>
- Filters asset names if they are configured to return only a subset of all the found elements.
- getCurrentSchema() : string|null
- Returns the name of the current schema.
- getPortableNamespaceDefinition() : mixed
- Converts a namespace definition from the native DBMS data definition to a portable Doctrine definition.
- getPortableNamespacesList() : array<string|int, string>
- Converts a list of namespace names from the native DBMS data definition to a portable Doctrine definition.
- normalizeName() : string
- An extension point for those platforms where case sensitivity of the object name depends on whether it's quoted.
- selectForeignKeyColumns() : Result
- Selects definitions of foreign key columns in the specified database. If the table name is specified, narrows down the selection to this table.
- selectIndexColumns() : Result
- Selects definitions of index columns in the specified database. If the table name is specified, narrows down the selection to this table.
- selectTableColumns() : Result
- Selects definitions of table columns in the specified database. If the table name is specified, narrows down the selection to this table.
- selectTableNames() : Result
- Selects names of tables in the specified database.
- buildQueryConditions() : array<int, string>
- fetchAllAssociativeGrouped() : array<string, array<int, array<string, mixed>>>
- fixVersion94NegativeNumericDefaultValue() : mixed
- PostgreSQL 9.4 puts parentheses around negative numeric default values that need to be stripped eventually.
- getDatabase() : string
- parseDefaultExpression() : string|null
- Parses a default value expression as given by PostgreSQL
Properties
$_conn
Holds instance of the Doctrine connection for this schema manager.
protected
Connection
$_conn
$_platform
Holds instance of the database platform used for this schema manager.
protected
T
$_platform
$existingSchemaPaths
private
array<string|int, string>|null
$existingSchemaPaths
= null
Methods
__construct()
public
__construct(Connection $connection, T $platform) : mixed
Parameters
- $connection : Connection
- $platform : T
alterSchema()
Alters an existing schema.
public
alterSchema(SchemaDiff $schemaDiff) : void
Parameters
- $schemaDiff : SchemaDiff
Tags
alterTable()
Alters an existing tables schema.
public
alterTable(TableDiff $tableDiff) : void
Parameters
- $tableDiff : TableDiff
Tags
createComparator()
public
createComparator() : Comparator
Return values
ComparatorcreateConstraint()
Creates a constraint on a table.
public
createConstraint(Constraint $constraint, Table|string $table) : void
Parameters
- $constraint : Constraint
- $table : Table|string
Tags
createDatabase()
Creates a new database.
public
createDatabase(string $database) : void
Parameters
- $database : string
-
The name of the database to create.
Tags
createForeignKey()
Creates a new foreign key.
public
createForeignKey(ForeignKeyConstraint $foreignKey, Table|string $table) : void
Parameters
- $foreignKey : ForeignKeyConstraint
-
The ForeignKey instance.
- $table : Table|string
-
The name of the table on which the foreign key is to be created.
Tags
createIndex()
Creates a new index on a table.
public
createIndex(Index $index, Table|string $table) : void
Parameters
Tags
createSchema()
Creates a schema instance for the current database.
public
createSchema() : Schema
Tags
Return values
SchemacreateSchemaConfig()
Creates the configuration for this schema.
public
createSchemaConfig() : SchemaConfig
Tags
Return values
SchemaConfigcreateSchemaObjects()
public
createSchemaObjects(Schema $schema) : void
Parameters
- $schema : Schema
Tags
createSequence()
Creates a new sequence.
public
createSequence(Sequence $sequence) : void
Parameters
- $sequence : Sequence
Tags
createTable()
Creates a new table.
public
createTable(Table $table) : void
Parameters
- $table : Table
Tags
createUniqueConstraint()
Creates a unique constraint on a table.
public
createUniqueConstraint(UniqueConstraint $uniqueConstraint, string $tableName) : void
Parameters
- $uniqueConstraint : UniqueConstraint
- $tableName : string
Tags
createView()
Creates a new view.
public
createView(View $view) : void
Parameters
- $view : View
Tags
dropAndCreateConstraint()
Drops and creates a constraint.
public
dropAndCreateConstraint(Constraint $constraint, Table|string $table) : void
Parameters
- $constraint : Constraint
- $table : Table|string
Tags
dropAndCreateDatabase()
Drops and creates a new database.
public
dropAndCreateDatabase(string $database) : void
Parameters
- $database : string
-
The name of the database to create.
Tags
dropAndCreateForeignKey()
Drops and creates a new foreign key.
public
dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, Table|string $table) : void
Parameters
- $foreignKey : ForeignKeyConstraint
-
An associative array that defines properties of the foreign key to be created.
- $table : Table|string
-
The name of the table on which the foreign key is to be created.
Tags
dropAndCreateIndex()
Drops and creates a new index on a table.
public
dropAndCreateIndex(Index $index, Table|string $table) : void
Parameters
Tags
dropAndCreateSequence()
Drops and create a new sequence.
public
dropAndCreateSequence(Sequence $sequence) : void
Parameters
- $sequence : Sequence
Tags
dropAndCreateTable()
Drops and creates a new table.
public
dropAndCreateTable(Table $table) : void
Parameters
- $table : Table
Tags
dropAndCreateView()
Drops and creates a new view.
public
dropAndCreateView(View $view) : void
Parameters
- $view : View
Tags
dropConstraint()
Drops the constraint from the given table.
public
dropConstraint(Constraint $constraint, Table|string $table) : void
Parameters
- $constraint : Constraint
- $table : Table|string
-
The name of the table.
Tags
dropDatabase()
Drops a database.
public
dropDatabase(string $database) : void
NOTE: You can not drop the database this SchemaManager is currently connected to.
Parameters
- $database : string
-
The name of the database to drop.
Tags
dropForeignKey()
Drops a foreign key from a table.
public
dropForeignKey(ForeignKeyConstraint|string $foreignKey, Table|string $table) : void
Parameters
- $foreignKey : ForeignKeyConstraint|string
-
The name of the foreign key.
- $table : Table|string
-
The name of the table with the foreign key.
Tags
dropIndex()
Drops the index from the given table.
public
dropIndex(Index|string $index, Table|string $table) : void
Parameters
Tags
dropSchema()
Drops a schema.
public
dropSchema(string $schemaName) : void
Parameters
- $schemaName : string
Tags
dropSchemaObjects()
public
dropSchemaObjects(Schema $schema) : void
Parameters
- $schema : Schema
Tags
dropSequence()
Drops a sequence with a given name.
public
dropSequence(string $name) : void
Parameters
- $name : string
-
The name of the sequence to drop.
Tags
dropTable()
Drops the given table.
public
dropTable(string $name) : void
Parameters
- $name : string
-
The name of the table to drop.
Tags
dropUniqueConstraint()
Drops the unique constraint from the given table.
public
dropUniqueConstraint(string $name, string $tableName) : void
Parameters
- $name : string
- $tableName : string
Tags
dropView()
Drops a view.
public
dropView(string $name) : void
Parameters
- $name : string
-
The name of the view.
Tags
getDatabasePlatform()
Returns the associated platform.
public
getDatabasePlatform() : T
Tags
Return values
TgetSchemaNames()
Gets all the existing schema names.
public
getSchemaNames() : array<string|int, string>
Tags
Return values
array<string|int, string>getSchemaSearchPaths()
The search path for namespaces in the currently connected database.
public
getSchemaSearchPaths() : array<string|int, string>
Tags
Return values
array<string|int, string>introspectSchema()
Returns a {@see Schema} instance representing the current database schema.
public
introspectSchema() : Schema
Tags
Return values
SchemaintrospectTable()
Introspects the table with the given name.
public
introspectTable(string $name) : Table
Parameters
- $name : string
Tags
Return values
TablelistDatabases()
Lists the available databases for this connection.
public
listDatabases() : array<string|int, string>
Tags
Return values
array<string|int, string>listNamespaceNames()
Returns a list of all namespaces in the current database.
public
listNamespaceNames() : array<string|int, string>
Tags
Return values
array<string|int, string>listSchemaNames()
Returns a list of the names of all schemata in the current database.
public
listSchemaNames() : array<int, string>
Return values
array<int, string>listSequences()
Lists the available sequences for this connection.
public
listSequences([string|null $database = null ]) : array<string|int, Sequence>
Parameters
- $database : string|null = null
Tags
Return values
array<string|int, Sequence>listTableColumns()
Lists the columns for a given table.
public
listTableColumns(mixed $table[, mixed $database = null ]) : array<string|int, Column>
Parameters
- $table : mixed
-
The name of the table.
- $database : mixed = null
Return values
array<string|int, Column>listTableDetails()
public
listTableDetails(mixed $name) : Table
Parameters
- $name : mixed
Tags
Return values
TablelistTableForeignKeys()
Lists the foreign keys for the given table.
public
listTableForeignKeys(mixed $table[, mixed $database = null ]) : array<string|int, ForeignKeyConstraint>
Parameters
- $table : mixed
-
The name of the table.
- $database : mixed = null
Return values
array<string|int, ForeignKeyConstraint>listTableIndexes()
Lists the indexes for a given table returning an array of Index instances.
public
listTableIndexes(mixed $table) : array<string|int, Index>
Parameters
- $table : mixed
-
The name of the table.
Return values
array<string|int, Index>listTableNames()
Returns a list of all tables in the current database.
public
listTableNames() : array<string|int, string>
Return values
array<string|int, string>listTables()
Lists the tables for this connection.
public
listTables() : array<int, Table>
Return values
array<int, Table>listViews()
Lists the views this connection has.
public
listViews() : array<string|int, View>
Tags
Return values
array<string|int, View>migrateSchema()
Migrates an existing schema to a new schema.
public
migrateSchema(Schema $toSchema) : void
Parameters
- $toSchema : Schema
Tags
renameTable()
Renames a given table to another name.
public
renameTable(string $name, string $newName) : void
Parameters
- $name : string
-
The current name of the table.
- $newName : string
-
The new name of the table.
Tags
tablesExist()
Returns true if all the given tables exist.
public
tablesExist(string|array<string|int, string> $names) : bool
The usage of a string $tableNames is deprecated. Pass a one-element array instead.
Parameters
- $names : string|array<string|int, string>
Tags
Return values
booltryMethod()
Tries any method on the schema manager. Normally a method throws an exception when your DBMS doesn't support it or if an error occurs.
public
tryMethod() : mixed
This method allows you to try and method on your SchemaManager instance and will return false if it does not work or is not supported.
$result = $sm->tryMethod('dropView', 'view_name');
Tags
_getPortableDatabaseDefinition()
protected
_getPortableDatabaseDefinition(mixed $database) : mixed
Parameters
- $database : mixed
_getPortableDatabasesList()
protected
_getPortableDatabasesList(array<string|int, mixed> $databases) : array<string|int, string>
Parameters
- $databases : array<string|int, mixed>
Return values
array<string|int, string>_getPortableSequenceDefinition()
protected
_getPortableSequenceDefinition(mixed $sequence) : Sequence
Parameters
- $sequence : mixed
Return values
Sequence_getPortableSequencesList()
protected
_getPortableSequencesList(array<string|int, array<string|int, mixed>> $sequences) : array<string|int, Sequence>
Parameters
- $sequences : array<string|int, array<string|int, mixed>>
Tags
Return values
array<string|int, Sequence>_getPortableTableColumnDefinition()
Gets Table Column Definition.
protected
_getPortableTableColumnDefinition(mixed $tableColumn) : Column
Parameters
- $tableColumn : mixed
Return values
Column_getPortableTableColumnList()
Independent of the database the keys of the column list result are lowercased.
protected
_getPortableTableColumnList(string $table, string $database, array<string|int, array<string|int, mixed>> $tableColumns) : array<string|int, Column>
The name of the created column instance however is kept in its case.
Parameters
- $table : string
-
The name of the table.
- $database : string
- $tableColumns : array<string|int, array<string|int, mixed>>
Tags
Return values
array<string|int, Column>_getPortableTableDefinition()
protected
_getPortableTableDefinition(mixed $table) : string
Parameters
- $table : mixed
Return values
string_getPortableTableForeignKeyDefinition()
protected
_getPortableTableForeignKeyDefinition(mixed $tableForeignKey) : ForeignKeyConstraint
Parameters
- $tableForeignKey : mixed
Return values
ForeignKeyConstraint_getPortableTableForeignKeysList()
protected
_getPortableTableForeignKeysList(array<string|int, array<string|int, mixed>> $tableForeignKeys) : array<string|int, ForeignKeyConstraint>
Parameters
- $tableForeignKeys : array<string|int, array<string|int, mixed>>
Return values
array<string|int, ForeignKeyConstraint>_getPortableTableIndexesList()
Aggregates and groups the index results according to the required data result.
protected
_getPortableTableIndexesList(mixed $tableIndexes[, mixed $tableName = null ]) : array<string|int, Index>
Parameters
- $tableIndexes : mixed
- $tableName : mixed = null
Tags
Return values
array<string|int, Index>_getPortableTablesList()
protected
_getPortableTablesList(array<string|int, array<string|int, mixed>> $tables) : array<string|int, string>
Parameters
- $tables : array<string|int, array<string|int, mixed>>
Return values
array<string|int, string>_getPortableViewDefinition()
protected
_getPortableViewDefinition(mixed $view) : View|false
Parameters
- $view : mixed
Return values
View|false_getPortableViewsList()
protected
_getPortableViewsList(array<string|int, array<string|int, mixed>> $views) : array<string|int, View>
Parameters
- $views : array<string|int, array<string|int, mixed>>
Return values
array<string|int, View>doListTableColumns()
protected
doListTableColumns(string $table[, string|null $database = null ]) : array<string|int, Column>
Parameters
- $table : string
- $database : string|null = null
Tags
Return values
array<string|int, Column>doListTableDetails()
protected
doListTableDetails(string $name) : Table
Parameters
- $name : string
Tags
Return values
TabledoListTableForeignKeys()
protected
doListTableForeignKeys(string $table[, string|null $database = null ]) : array<string|int, ForeignKeyConstraint>
Parameters
- $table : string
- $database : string|null = null
Tags
Return values
array<string|int, ForeignKeyConstraint>doListTableIndexes()
protected
doListTableIndexes(string $table) : array<string|int, Index>
Parameters
- $table : string
Tags
Return values
array<string|int, Index>doListTableNames()
protected
doListTableNames() : array<int, string>
Tags
Return values
array<int, string>doListTables()
protected
doListTables() : array<int, Table>
Tags
Return values
array<int, Table>fetchForeignKeyColumnsByTable()
Fetches definitions of foreign key columns in the specified database and returns them grouped by table name.
protected
fetchForeignKeyColumnsByTable(string $databaseName) : array<string, array<int, array<string, mixed>>>
Parameters
- $databaseName : string
Tags
Return values
array<string, array<int, array<string, mixed>>>fetchIndexColumnsByTable()
Fetches definitions of index columns in the specified database and returns them grouped by table name.
protected
fetchIndexColumnsByTable(string $databaseName) : array<string, array<int, array<string, mixed>>>
Parameters
- $databaseName : string
Tags
Return values
array<string, array<int, array<string, mixed>>>fetchTableColumnsByTable()
Fetches definitions of table columns in the specified database and returns them grouped by table name.
protected
fetchTableColumnsByTable(string $databaseName) : array<string, array<int, array<string, mixed>>>
Parameters
- $databaseName : string
Tags
Return values
array<string, array<int, array<string, mixed>>>fetchTableOptionsByTable()
Fetches table options for the tables in the specified database and returns them grouped by table name.
protected
fetchTableOptionsByTable(string $databaseName[, string|null $tableName = null ]) : array<string, array<string, mixed>>
Parameters
- $databaseName : string
- $tableName : string|null = null
Return values
array<string, array<string, mixed>>filterAssetNames()
Filters asset names if they are configured to return only a subset of all the found elements.
protected
filterAssetNames(array<string|int, mixed> $assetNames) : array<string|int, mixed>
Parameters
- $assetNames : array<string|int, mixed>
Return values
array<string|int, mixed>getCurrentSchema()
Returns the name of the current schema.
protected
getCurrentSchema() : string|null
Tags
Return values
string|nullgetPortableNamespaceDefinition()
Converts a namespace definition from the native DBMS data definition to a portable Doctrine definition.
protected
getPortableNamespaceDefinition(array<string|int, mixed> $namespace) : mixed
Parameters
- $namespace : array<string|int, mixed>
-
The native DBMS namespace definition.
Tags
getPortableNamespacesList()
Converts a list of namespace names from the native DBMS data definition to a portable Doctrine definition.
protected
getPortableNamespacesList(array<int, array<string, mixed>> $namespaces) : array<string|int, string>
Parameters
- $namespaces : array<int, array<string, mixed>>
-
The list of namespace names in the native DBMS data definition.
Tags
Return values
array<string|int, string>normalizeName()
An extension point for those platforms where case sensitivity of the object name depends on whether it's quoted.
protected
normalizeName(string $name) : string
Such platforms should convert a possibly quoted name into a value of the corresponding case.
Parameters
- $name : string
Return values
stringselectForeignKeyColumns()
Selects definitions of foreign key columns in the specified database. If the table name is specified, narrows down the selection to this table.
protected
selectForeignKeyColumns(string $databaseName[, string|null $tableName = null ]) : Result
Parameters
- $databaseName : string
- $tableName : string|null = null
Return values
ResultselectIndexColumns()
Selects definitions of index columns in the specified database. If the table name is specified, narrows down the selection to this table.
protected
selectIndexColumns(string $databaseName[, string|null $tableName = null ]) : Result
Parameters
- $databaseName : string
- $tableName : string|null = null
Return values
ResultselectTableColumns()
Selects definitions of table columns in the specified database. If the table name is specified, narrows down the selection to this table.
protected
selectTableColumns(string $databaseName[, string|null $tableName = null ]) : Result
Parameters
- $databaseName : string
- $tableName : string|null = null
Return values
ResultselectTableNames()
Selects names of tables in the specified database.
protected
selectTableNames(string $databaseName) : Result
Parameters
- $databaseName : string
Return values
ResultbuildQueryConditions()
private
buildQueryConditions(string|null $tableName) : array<int, string>
Parameters
- $tableName : string|null
Return values
array<int, string>fetchAllAssociativeGrouped()
private
fetchAllAssociativeGrouped(Result $result) : array<string, array<int, array<string, mixed>>>
Parameters
- $result : Result
Tags
Return values
array<string, array<int, array<string, mixed>>>fixVersion94NegativeNumericDefaultValue()
PostgreSQL 9.4 puts parentheses around negative numeric default values that need to be stripped eventually.
private
fixVersion94NegativeNumericDefaultValue(mixed $defaultValue) : mixed
Parameters
- $defaultValue : mixed
getDatabase()
private
getDatabase(string $methodName) : string
Parameters
- $methodName : string
Tags
Return values
stringparseDefaultExpression()
Parses a default value expression as given by PostgreSQL
private
parseDefaultExpression(string|null $default) : string|null
Parameters
- $default : string|null