Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6098881
DoctrineSchemaChangeBuilder.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
DoctrineSchemaChangeBuilder.php
View Options
<?php
namespace
Wikimedia\Rdbms
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\Comparator
;
use
Doctrine\DBAL\Schema\Schema
;
/**
* @experimental
* @unstable
*/
class
DoctrineSchemaChangeBuilder
implements
SchemaChangeBuilder
{
use
DoctrineAbstractSchemaTrait
;
private
AbstractPlatform
$platform
;
/**
* A builder object that take abstract schema definition and produces sql to create the tables.
*
* @param AbstractPlatform $platform A Doctrine Platform object, Can be Mysql, Sqlite, etc.
*/
public
function
__construct
(
AbstractPlatform
$platform
)
{
$this
->
platform
=
$platform
;
}
private
function
getTableSchema
(
array
$tableSpec
):
Schema
{
if
(
!
$tableSpec
)
{
// Used for not yet created tables.
return
new
Schema
();
}
return
$this
->
addTableToSchema
(
new
Schema
(),
$tableSpec
);
}
public
function
getSchemaChangeSql
(
array
$schemaChangeSpec
):
array
{
$comparator
=
new
Comparator
();
$schemaDiff
=
$comparator
->
compare
(
$this
->
getTableSchema
(
$schemaChangeSpec
[
'before'
]
),
$this
->
getTableSchema
(
$schemaChangeSpec
[
'after'
]
)
);
return
$schemaDiff
->
toSql
(
$this
->
platform
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 6 2026, 06:36 (7 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9b/40/3132193d6241d9eb8492d5afcbd3
Default Alt Text
DoctrineSchemaChangeBuilder.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment