Doctrine\ORM\Tools\SchemaTool
The SchemaTool is a tool to create/drop/update database schemas based on <tt>ClassMetadata</tt> class descriptors.
- Author: Guilherme Blanco <guilhermeblanco@hotmail.com>
Synopsis
class SchemaTool
{
- // members
- private EntityManager $em;
- private AbstractPlatform $platform;
- private QuoteStrategy $quoteStrategy;
- // methods
- public void __construct()
- public void createSchema()
- public array getCreateSchemaSql()
- private bool processingNotRequired()
- public Schema getSchemaFromMetadata()
- private array addDiscriminatorColumnDefinition()
- private array _gatherColumns()
- private array _gatherColumn()
- private void _gatherRelationsSql()
- private array(ClassMetadata getDefiningClass()
- private void _gatherRelationJoinColumns()
- public void dropSchema()
- public void dropDatabase()
- public array getDropDatabaseSQL()
- public array getDropSchemaSQL()
- public void updateSchema()
- public array getUpdateSchemaSql()
Members
private
- $em — \Doctrine\ORM\EntityManager
- $platform — \Doctrine\DBAL\Platforms\AbstractPlatform
- $quoteStrategy
—
\Doctrine\ORM\Mapping\QuoteStrategy
The quote strategy.
Methods
private
- _gatherColumn() — Creates a column definition as required by the DBAL from an ORM field mapping definition.
- _gatherColumns() — Gathers the column definitions as required by the DBAL of all field mappings found in the given class.
- _gatherRelationJoinColumns() — Gather columns and fk constraints that are required for one part of relationship.
- _gatherRelationsSql() — Gathers the SQL for properly setting up the relations of the given class.
- addDiscriminatorColumnDefinition() — Gets a portable column definition as required by the DBAL for the discriminator column of a class.
- getDefiningClass() — Get the class metadata that is responsible for the definition of the referenced column name.
- processingNotRequired() — Some instances of ClassMetadata don't need to be processed in the SchemaTool context. This method detects them.
public
- __construct() — Initializes a new SchemaTool instance that uses the connection of the provided EntityManager.
- createSchema() — Creates the database schema for the given array of ClassMetadata instances.
- dropDatabase() — Drops all elements in the database of the current connection.
- dropSchema() — Drops the database schema for the given classes.
- getCreateSchemaSql() — Gets the list of DDL statements that are required to create the database schema for the given list of ClassMetadata instances.
- getDropDatabaseSQL() — Gets the SQL needed to drop the database schema for the connections database.
- getDropSchemaSQL() — Get SQL to drop the tables defined by the passed classes.
- getSchemaFromMetadata() — From a given set of metadata classes this method creates a Schema instance.
- getUpdateSchemaSql() — Gets the sequence of SQL statements that need to be performed in order to bring the given class mappings in-synch with the relational schema.
- updateSchema() — Updates the database schema of the given classes by comparing the ClassMetadata instances to the current database schema that is inspected. If $saveMode is set to true the command is executed in the Database, else SQL is returned.