@@ -15,6 +15,7 @@ class AlterTable extends AbstractSql implements SqlInterface
15
15
public const CHANGE_COLUMNS = 'changeColumns ' ;
16
16
public const DROP_COLUMNS = 'dropColumns ' ;
17
17
public const DROP_CONSTRAINTS = 'dropConstraints ' ;
18
+ public const DROP_INDEXES = 'dropIndexes ' ;
18
19
public const TABLE = 'table ' ;
19
20
20
21
/** @var array */
@@ -32,6 +33,9 @@ class AlterTable extends AbstractSql implements SqlInterface
32
33
/** @var array */
33
34
protected $ dropConstraints = [];
34
35
36
+ /** @var array */
37
+ protected $ dropIndexes = [];
38
+
35
39
/**
36
40
* Specifications for Sql String generation
37
41
*
@@ -64,6 +68,11 @@ class AlterTable extends AbstractSql implements SqlInterface
64
68
[1 => "DROP CONSTRAINT %1 \$s, \n" , 'combinedby ' => "" ],
65
69
],
66
70
],
71
+ self ::DROP_INDEXES => [
72
+ '%1$s ' => [
73
+ [1 => "DROP INDEX %1 \$s, \n" , 'combinedby ' => '' ],
74
+ ],
75
+ ],
67
76
];
68
77
69
78
/** @var string */
@@ -141,6 +150,17 @@ public function addConstraint(Constraint\ConstraintInterface $constraint)
141
150
return $ this ;
142
151
}
143
152
153
+ /**
154
+ * @param string $name
155
+ * @return self Provides a fluent interface
156
+ */
157
+ public function dropIndex ($ name )
158
+ {
159
+ $ this ->dropIndexes [] = $ name ;
160
+
161
+ return $ this ;
162
+ }
163
+
144
164
/**
145
165
* @param string|null $key
146
166
* @return array
@@ -154,6 +174,7 @@ public function getRawState($key = null)
154
174
self ::CHANGE_COLUMNS => $ this ->changeColumns ,
155
175
self ::ADD_CONSTRAINTS => $ this ->addConstraints ,
156
176
self ::DROP_CONSTRAINTS => $ this ->dropConstraints ,
177
+ self ::DROP_INDEXES => $ this ->dropIndexes ,
157
178
];
158
179
159
180
return isset ($ key ) && array_key_exists ($ key , $ rawState ) ? $ rawState [$ key ] : $ rawState ;
@@ -222,4 +243,15 @@ protected function processDropConstraints(?PlatformInterface $adapterPlatform =
222
243
223
244
return [$ sqls ];
224
245
}
246
+
247
+ /** @return string[] */
248
+ protected function processDropIndexes (?PlatformInterface $ adapterPlatform = null )
249
+ {
250
+ $ sqls = [];
251
+ foreach ($ this ->dropIndexes as $ index ) {
252
+ $ sqls [] = $ adapterPlatform ->quoteIdentifier ($ index );
253
+ }
254
+
255
+ return [$ sqls ];
256
+ }
225
257
}
0 commit comments