11
11
12
12
namespace Symfony \Component \Security \Acl \Dbal ;
13
13
14
+ use Doctrine \DBAL \Platforms \SQLServerPlatform ;
14
15
use Doctrine \DBAL \Schema \Schema as BaseSchema ;
15
16
use Doctrine \DBAL \Connection ;
16
17
22
23
final class Schema extends BaseSchema
23
24
{
24
25
protected $ options ;
26
+ protected $ dbms ;
25
27
26
28
/**
27
29
* Constructor.
28
30
*
29
31
* @param array $options the names for tables
30
32
* @param Connection $connection
33
+ * @throws \Doctrine\DBAL\DBALException
31
34
*/
32
35
public function __construct (array $ options , Connection $ connection = null )
33
36
{
@@ -36,6 +39,7 @@ public function __construct(array $options, Connection $connection = null)
36
39
parent ::__construct (array (), array (), $ schemaConfig );
37
40
38
41
$ this ->options = $ options ;
42
+ $ this ->dbms = $ connection ->getDatabasePlatform ();
39
43
40
44
$ this ->addClassTable ();
41
45
$ this ->addSecurityIdentitiesTable ();
@@ -134,7 +138,12 @@ protected function addObjectIdentityAncestorsTable()
134
138
135
139
$ oidTable = $ this ->getTable ($ this ->options ['oid_table_name ' ]);
136
140
$ table ->addForeignKeyConstraint ($ oidTable , array ('object_identity_id ' ), array ('id ' ), array ('onDelete ' => 'CASCADE ' , 'onUpdate ' => 'CASCADE ' ));
137
- $ table ->addForeignKeyConstraint ($ oidTable , array ('ancestor_id ' ), array ('id ' ), array ('onDelete ' => 'CASCADE ' , 'onUpdate ' => 'CASCADE ' ));
141
+ // MS SQL Server does not support recursive cascading
142
+ if ($ this ->dbms instanceof SQLServerPlatform) {
143
+ $ table ->addForeignKeyConstraint ($ oidTable , array ('ancestor_id ' ), array ('id ' ), array ('onDelete ' => 'NO ACTION ' , 'onUpdate ' => 'NO ACTION ' ));
144
+ } else {
145
+ $ table ->addForeignKeyConstraint ($ oidTable , array ('ancestor_id ' ), array ('id ' ), array ('onDelete ' => 'CASCADE ' , 'onUpdate ' => 'CASCADE ' ));
146
+ }
138
147
}
139
148
140
149
/**
0 commit comments