class Schema extends AbstractAsset (View source)

Object representation of a database schema

Properties

protected string $_name from AbstractAsset
protected $_quoted from AbstractAsset
protected array $_tables
protected array $_sequences
protected SchemaConfig $_schemaConfig

Methods

_setName(string $name)

Set name of this asset

bool
isQuoted(string $identifier)

Check if this identifier is quoted.

string
trimQuotes(string $identifier)

Trim quotes from the identifier.

string
getName()

Return name of this schema asset.

string
getQuotedName(AbstractPlatform $platform)

Get the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.

string
_generateIdentifierName(array $columnNames, string $prefix = '', int $maxSize = 30)

Generate an identifier from a list of column names obeying a certain string length.

__construct(array $tables = array(), array $sequences = array(), SchemaConfig $schemaConfig = null)

No description

bool
hasExplicitForeignKeyIndexes()

No description

_addTable(Table $table)

No description

_addSequence(Sequence $sequence)

No description

array
getTables()

Get all tables of this schema.

getTable(string $tableName)

No description

hasTable(string $tableName)

Does this schema have a table with the given name?

bool
hasSequence(string $sequenceName)

No description

Sequence
getSequence(string $sequenceName)

No description

Sequence[]
getSequences()

No description

createTable(string $tableName)

Create a new table

renameTable(string $oldTableName, string $newTableName)

Rename a table

dropTable(string $tableName)

Drop a table from the schema.

createSequence(string $sequenceName, int $allocationSize = 1, int $initialValue = 1)

Create a new sequence

dropSequence(string $sequenceName)

No description

array
toSql(AbstractPlatform $platform)

Return an array of necessary sql queries to create the schema on the given platform.

array
toDropSql(AbstractPlatform $platform)

Return an array of necessary sql queries to drop the schema on the given platform.

getMigrateToSql(Schema $toSchema, AbstractPlatform $platform)

No description

getMigrateFromSql(Schema $fromSchema, AbstractPlatform $platform)

No description

visit(Visitor $visitor)

No description

void
__clone()

Cloning a Schema triggers a deep clone of all related assets.

Details

protected _setName(string $name)

Set name of this asset

Parameters

string $name

protected bool isQuoted(string $identifier)

Check if this identifier is quoted.

Parameters

string $identifier

Return Value

bool

protected string trimQuotes(string $identifier)

Trim quotes from the identifier.

Parameters

string $identifier

Return Value

string

string getName()

Return name of this schema asset.

Return Value

string

string getQuotedName(AbstractPlatform $platform)

Get the quoted representation of this asset but only if it was defined with one. Otherwise return the plain unquoted value as inserted.

Parameters

AbstractPlatform $platform

Return Value

string

protected string _generateIdentifierName(array $columnNames, string $prefix = '', int $maxSize = 30)

Generate an identifier from a list of column names obeying a certain string length.

This is especially important for Oracle, since it does not allow identifiers larger than 30 chars, however building idents automatically for foreign keys, composite keys or such can easily create very long names.

Parameters

array $columnNames
string $prefix
int $maxSize

Return Value

string

__construct(array $tables = array(), array $sequences = array(), SchemaConfig $schemaConfig = null)

Parameters

array $tables
array $sequences
SchemaConfig $schemaConfig

bool hasExplicitForeignKeyIndexes()

Return Value

bool

protected _addTable(Table $table)

Parameters

Table $table

protected _addSequence(Sequence $sequence)

Parameters

Sequence $sequence

array getTables()

Get all tables of this schema.

Return Value

array

Table getTable(string $tableName)

Parameters

string $tableName

Return Value

Table

Schema hasTable(string $tableName)

Does this schema have a table with the given name?

Parameters

string $tableName

Return Value

Schema

bool hasSequence(string $sequenceName)

Parameters

string $sequenceName

Return Value

bool

Sequence getSequence(string $sequenceName)

Parameters

string $sequenceName

Return Value

Sequence

Exceptions

SchemaException

Sequence[] getSequences()

Return Value

Sequence[]

Table createTable(string $tableName)

Create a new table

Parameters

string $tableName

Return Value

Table

Schema renameTable(string $oldTableName, string $newTableName)

Rename a table

Parameters

string $oldTableName
string $newTableName

Return Value

Schema

Schema dropTable(string $tableName)

Drop a table from the schema.

Parameters

string $tableName

Return Value

Schema

Sequence createSequence(string $sequenceName, int $allocationSize = 1, int $initialValue = 1)

Create a new sequence

Parameters

string $sequenceName
int $allocationSize
int $initialValue

Return Value

Sequence

Schema dropSequence(string $sequenceName)

Parameters

string $sequenceName

Return Value

Schema

array toSql(AbstractPlatform $platform)

Return an array of necessary sql queries to create the schema on the given platform.

Parameters

AbstractPlatform $platform

Return Value

array

array toDropSql(AbstractPlatform $platform)

Return an array of necessary sql queries to drop the schema on the given platform.

Parameters

AbstractPlatform $platform

Return Value

array

getMigrateToSql(Schema $toSchema, AbstractPlatform $platform)

Parameters

Schema $toSchema
AbstractPlatform $platform

getMigrateFromSql(Schema $fromSchema, AbstractPlatform $platform)

Parameters

Schema $fromSchema
AbstractPlatform $platform

visit(Visitor $visitor)

Parameters

Visitor $visitor

void __clone()

Cloning a Schema triggers a deep clone of all related assets.

Return Value

void