Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
4e53f63a
Unverified
Commit
4e53f63a
authored
Aug 19, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the Synchronizer package
parent
79c34f77
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
4 additions
and
364 deletions
+4
-364
UPGRADE.md
UPGRADE.md
+4
-0
AbstractSchemaSynchronizer.php
src/Schema/Synchronizer/AbstractSchemaSynchronizer.php
+0
-52
SchemaSynchronizer.php
src/Schema/Synchronizer/SchemaSynchronizer.php
+0
-74
SingleDatabaseSynchronizer.php
src/Schema/Synchronizer/SingleDatabaseSynchronizer.php
+0
-160
SingleDatabaseSynchronizerTest.php
tests/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
+0
-78
No files found.
UPGRADE.md
View file @
4e53f63a
# Upgrade to 3.0
# Upgrade to 3.0
## BC BREAK: removed `Synchronizer` package
The
`Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer`
interface and all its implementations have been removed.
## BC BREAK: removed wrapper `Connection` methods
## BC BREAK: removed wrapper `Connection` methods
The following methods of the
`Connection`
class have been removed:
The following methods of the
`Connection`
class have been removed:
...
...
src/Schema/Synchronizer/AbstractSchemaSynchronizer.php
deleted
100644 → 0
View file @
79c34f77
<?php
namespace
Doctrine\DBAL\Schema\Synchronizer
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\DBALException
;
use
Throwable
;
/**
* Abstract schema synchronizer with methods for executing batches of SQL.
*
* @deprecated
*/
abstract
class
AbstractSchemaSynchronizer
implements
SchemaSynchronizer
{
/** @var Connection */
protected
$conn
;
public
function
__construct
(
Connection
$conn
)
{
$this
->
conn
=
$conn
;
}
/**
* @param string[] $sql
*
* @return void
*/
protected
function
processSqlSafely
(
array
$sql
)
{
foreach
(
$sql
as
$s
)
{
try
{
$this
->
conn
->
executeStatement
(
$s
);
}
catch
(
Throwable
$e
)
{
}
}
}
/**
* @param string[] $sql
*
* @return void
*
* @throws DBALException
*/
protected
function
processSql
(
array
$sql
)
{
foreach
(
$sql
as
$s
)
{
$this
->
conn
->
executeStatement
(
$s
);
}
}
}
src/Schema/Synchronizer/SchemaSynchronizer.php
deleted
100644 → 0
View file @
79c34f77
<?php
namespace
Doctrine\DBAL\Schema\Synchronizer
;
use
Doctrine\DBAL\Schema\Schema
;
/**
* The synchronizer knows how to synchronize a schema with the configured
* database.
*
* @deprecated
*/
interface
SchemaSynchronizer
{
/**
* Gets the SQL statements that can be executed to create the schema.
*
* @return string[]
*/
public
function
getCreateSchema
(
Schema
$createSchema
);
/**
* Gets the SQL Statements to update given schema with the underlying db.
*
* @param bool $noDrops
*
* @return string[]
*/
public
function
getUpdateSchema
(
Schema
$toSchema
,
$noDrops
=
false
);
/**
* Gets the SQL Statements to drop the given schema from underlying db.
*
* @return string[]
*/
public
function
getDropSchema
(
Schema
$dropSchema
);
/**
* Gets the SQL statements to drop all schema assets from underlying db.
*
* @return string[]
*/
public
function
getDropAllSchema
();
/**
* Creates the Schema.
*
* @return void
*/
public
function
createSchema
(
Schema
$createSchema
);
/**
* Updates the Schema to new schema version.
*
* @param bool $noDrops
*
* @return void
*/
public
function
updateSchema
(
Schema
$toSchema
,
$noDrops
=
false
);
/**
* Drops the given database schema from the underlying db.
*
* @return void
*/
public
function
dropSchema
(
Schema
$dropSchema
);
/**
* Drops all assets from the underlying db.
*
* @return void
*/
public
function
dropAllSchema
();
}
src/Schema/Synchronizer/SingleDatabaseSynchronizer.php
deleted
100644 → 0
View file @
79c34f77
<?php
namespace
Doctrine\DBAL\Schema\Synchronizer
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\Comparator
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector
;
use
function
count
;
/**
* Schema Synchronizer for Default DBAL Connection.
*
* @deprecated
*/
class
SingleDatabaseSynchronizer
extends
AbstractSchemaSynchronizer
{
/** @var AbstractPlatform */
private
$platform
;
public
function
__construct
(
Connection
$conn
)
{
parent
::
__construct
(
$conn
);
$this
->
platform
=
$conn
->
getDatabasePlatform
();
}
/**
* {@inheritdoc}
*/
public
function
getCreateSchema
(
Schema
$createSchema
)
{
return
$createSchema
->
toSql
(
$this
->
platform
);
}
/**
* {@inheritdoc}
*/
public
function
getUpdateSchema
(
Schema
$toSchema
,
$noDrops
=
false
)
{
$comparator
=
new
Comparator
();
$sm
=
$this
->
conn
->
getSchemaManager
();
$fromSchema
=
$sm
->
createSchema
();
$schemaDiff
=
$comparator
->
compare
(
$fromSchema
,
$toSchema
);
if
(
$noDrops
)
{
return
$schemaDiff
->
toSaveSql
(
$this
->
platform
);
}
return
$schemaDiff
->
toSql
(
$this
->
platform
);
}
/**
* {@inheritdoc}
*/
public
function
getDropSchema
(
Schema
$dropSchema
)
{
$visitor
=
new
DropSchemaSqlCollector
(
$this
->
platform
);
$sm
=
$this
->
conn
->
getSchemaManager
();
$fullSchema
=
$sm
->
createSchema
();
foreach
(
$fullSchema
->
getTables
()
as
$table
)
{
if
(
$dropSchema
->
hasTable
(
$table
->
getName
()))
{
$visitor
->
acceptTable
(
$table
);
}
foreach
(
$table
->
getForeignKeys
()
as
$foreignKey
)
{
if
(
!
$dropSchema
->
hasTable
(
$table
->
getName
()))
{
continue
;
}
if
(
!
$dropSchema
->
hasTable
(
$foreignKey
->
getForeignTableName
()))
{
continue
;
}
$visitor
->
acceptForeignKey
(
$table
,
$foreignKey
);
}
}
if
(
!
$this
->
platform
->
supportsSequences
())
{
return
$visitor
->
getQueries
();
}
foreach
(
$dropSchema
->
getSequences
()
as
$sequence
)
{
$visitor
->
acceptSequence
(
$sequence
);
}
foreach
(
$dropSchema
->
getTables
()
as
$table
)
{
$primaryKey
=
$table
->
getPrimaryKey
();
if
(
$primaryKey
===
null
)
{
continue
;
}
$columns
=
$primaryKey
->
getColumns
();
if
(
count
(
$columns
)
>
1
)
{
continue
;
}
$checkSequence
=
$table
->
getName
()
.
'_'
.
$columns
[
0
]
.
'_seq'
;
if
(
!
$fullSchema
->
hasSequence
(
$checkSequence
))
{
continue
;
}
$visitor
->
acceptSequence
(
$fullSchema
->
getSequence
(
$checkSequence
));
}
return
$visitor
->
getQueries
();
}
/**
* {@inheritdoc}
*/
public
function
getDropAllSchema
()
{
$sm
=
$this
->
conn
->
getSchemaManager
();
$visitor
=
new
DropSchemaSqlCollector
(
$this
->
platform
);
$schema
=
$sm
->
createSchema
();
$schema
->
visit
(
$visitor
);
return
$visitor
->
getQueries
();
}
/**
* {@inheritdoc}
*/
public
function
createSchema
(
Schema
$createSchema
)
{
$this
->
processSql
(
$this
->
getCreateSchema
(
$createSchema
));
}
/**
* {@inheritdoc}
*/
public
function
updateSchema
(
Schema
$toSchema
,
$noDrops
=
false
)
{
$this
->
processSql
(
$this
->
getUpdateSchema
(
$toSchema
,
$noDrops
));
}
/**
* {@inheritdoc}
*/
public
function
dropSchema
(
Schema
$dropSchema
)
{
$this
->
processSqlSafely
(
$this
->
getDropSchema
(
$dropSchema
));
}
/**
* {@inheritdoc}
*/
public
function
dropAllSchema
()
{
$this
->
processSql
(
$this
->
getDropAllSchema
());
}
}
tests/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
deleted
100644 → 0
View file @
79c34f77
<?php
namespace
Doctrine\DBAL\Tests\Schema\Synchronizer
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\DriverManager
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer
;
use
PHPUnit\Framework\TestCase
;
/**
* @requires extension pdo_sqlite
*/
class
SingleDatabaseSynchronizerTest
extends
TestCase
{
/** @var Connection */
private
$conn
;
/** @var SingleDatabaseSynchronizer */
private
$synchronizer
;
protected
function
setUp
()
:
void
{
$this
->
conn
=
DriverManager
::
getConnection
([
'driver'
=>
'pdo_sqlite'
,
'memory'
=>
true
,
]);
$this
->
synchronizer
=
new
SingleDatabaseSynchronizer
(
$this
->
conn
);
}
public
function
testGetCreateSchema
()
:
void
{
$schema
=
new
Schema
();
$table
=
$schema
->
createTable
(
'test'
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
setPrimaryKey
([
'id'
]);
$sql
=
$this
->
synchronizer
->
getCreateSchema
(
$schema
);
self
::
assertEquals
([
'CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'
],
$sql
);
}
public
function
testGetUpdateSchema
()
:
void
{
$schema
=
new
Schema
();
$table
=
$schema
->
createTable
(
'test'
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
setPrimaryKey
([
'id'
]);
$sql
=
$this
->
synchronizer
->
getUpdateSchema
(
$schema
);
self
::
assertEquals
([
'CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'
],
$sql
);
}
public
function
testGetDropSchema
()
:
void
{
$schema
=
new
Schema
();
$table
=
$schema
->
createTable
(
'test'
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
setPrimaryKey
([
'id'
]);
$this
->
synchronizer
->
createSchema
(
$schema
);
$sql
=
$this
->
synchronizer
->
getDropSchema
(
$schema
);
self
::
assertEquals
([
'DROP TABLE test'
],
$sql
);
}
public
function
testGetDropAllSchema
()
:
void
{
$schema
=
new
Schema
();
$table
=
$schema
->
createTable
(
'test'
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
setPrimaryKey
([
'id'
]);
$this
->
synchronizer
->
createSchema
(
$schema
);
$sql
=
$this
->
synchronizer
->
getDropAllSchema
();
self
::
assertEquals
([
'DROP TABLE test'
],
$sql
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment