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
ac910457
Commit
ac910457
authored
Jun 13, 2010
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'eriksencosta/DBAL-18'
parents
22c9f44b
63f78cf6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
SchemaDiff.php
lib/Doctrine/DBAL/Schema/SchemaDiff.php
+8
-7
SchemaDiffTest.php
tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
+10
-4
No files found.
lib/Doctrine/DBAL/Schema/SchemaDiff.php
View file @
ac910457
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -84,7 +82,7 @@ class SchemaDiff
* @param array(string=>TableDiff) $changedTables
* @param array(string=>bool) $removedTables
*/
public
function
__construct
(
$newTables
=
array
(),
$changedTables
=
array
(),
$removedTables
=
array
()
)
public
function
__construct
(
$newTables
=
array
(),
$changedTables
=
array
(),
$removedTables
=
array
()
)
{
$this
->
newTables
=
$newTables
;
$this
->
changedTables
=
$changedTables
;
...
...
@@ -155,10 +153,13 @@ class SchemaDiff
$sql
,
$platform
->
getCreateTableSQL
(
$table
,
AbstractPlatform
::
CREATE_INDEXES
)
);
if
(
$platform
->
supportsForeignKeyConstraints
())
{
foreach
(
$table
->
getForeignKeys
()
AS
$foreignKey
)
{
$foreignKeySql
[]
=
$platform
->
getCreateForeignKeySQL
(
$foreignKey
,
$table
);
}
}
}
$sql
=
array_merge
(
$sql
,
$foreignKeySql
);
if
(
$saveMode
===
false
)
{
...
...
tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
View file @
ac910457
...
...
@@ -23,7 +23,7 @@ class SchemaDiffTest extends \PHPUnit_Framework_TestCase
$sql
=
$diff
->
toSql
(
$platform
);
$expected
=
array
(
'drop_orphan_fk'
,
'drop_seq'
,
'create_seq'
,
'drop_seq'
,
'create_seq'
,
'create_table'
,
'drop_table'
,
'alter_table'
);
$expected
=
array
(
'drop_orphan_fk'
,
'drop_seq'
,
'create_seq'
,
'drop_seq'
,
'create_seq'
,
'create_table'
,
'
create_foreign_key'
,
'
drop_table'
,
'alter_table'
);
$this
->
assertEquals
(
$expected
,
$sql
);
}
...
...
@@ -35,7 +35,7 @@ class SchemaDiffTest extends \PHPUnit_Framework_TestCase
$sql
=
$diff
->
toSaveSql
(
$platform
);
$expected
=
array
(
'drop_seq'
,
'create_seq'
,
'create_seq'
,
'create_table'
,
'alter_table'
);
$expected
=
array
(
'drop_seq'
,
'create_seq'
,
'create_seq'
,
'create_table'
,
'
create_foreign_key'
,
'
alter_table'
);
$this
->
assertEquals
(
$expected
,
$sql
);
}
...
...
@@ -61,6 +61,10 @@ class SchemaDiffTest extends \PHPUnit_Framework_TestCase
->
method
(
'getCreateTableSql'
)
->
with
(
$this
->
isInstanceof
(
'Doctrine\DBAL\Schema\Table'
))
->
will
(
$this
->
returnValue
(
array
(
'create_table'
)));
$platform
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'getCreateForeignKeySQL'
)
->
with
(
$this
->
isInstanceOf
(
'Doctrine\DBAL\Schema\ForeignKeyConstraint'
))
->
will
(
$this
->
returnValue
(
'create_foreign_key'
));
$platform
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'getAlterTableSql'
)
->
with
(
$this
->
isInstanceOf
(
'Doctrine\DBAL\Schema\TableDiff'
))
...
...
@@ -74,7 +78,7 @@ class SchemaDiffTest extends \PHPUnit_Framework_TestCase
$platform
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'supportsSequences'
)
->
will
(
$this
->
returnValue
(
true
));
$platform
->
expects
(
$this
->
exactly
(
1
))
$platform
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'supportsForeignKeyConstraints'
)
->
will
(
$this
->
returnValue
(
true
));
return
$platform
;
...
...
@@ -89,6 +93,8 @@ class SchemaDiffTest extends \PHPUnit_Framework_TestCase
$diff
->
newTables
[
'foo_table'
]
=
new
Table
(
'foo_table'
);
$diff
->
removedTables
[
'bar_table'
]
=
new
Table
(
'bar_table'
);
$diff
->
changedTables
[
'baz_table'
]
=
new
TableDiff
(
'baz_table'
);
$diff
->
newTables
[
'foo_table'
]
->
addColumn
(
'foreign_id'
,
'integer'
);
$diff
->
newTables
[
'foo_table'
]
->
addForeignKeyConstraint
(
'foreign_table'
,
array
(
'foreign_id'
),
array
(
'id'
));
$fk
=
new
\Doctrine\DBAL\Schema\ForeignKeyConstraint
(
array
(
'id'
),
'foreign_table'
,
array
(
'id'
));
$fk
->
setLocalTable
(
new
Table
(
'local_table'
));
$diff
->
orphanedForeignKeys
[]
=
$fk
;
...
...
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