File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed
Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,9 @@ public function null(): FluidColumnOptions
5858 *
5959 * @return FluidColumnOptions
6060 */
61- public function unique (): FluidColumnOptions
61+ public function unique (? string $ indexName = null ): FluidColumnOptions
6262 {
63- $ this ->column ->setCustomSchemaOption ( ' unique ' , true );
63+ $ this ->fluidTable -> unique ([ $ this -> namingStrategy -> quoteIdentifier ( $ this -> column ->getName ())], $ indexName );
6464 return $ this ;
6565 }
6666
@@ -69,9 +69,9 @@ public function unique(): FluidColumnOptions
6969 *
7070 * @return FluidColumnOptions
7171 */
72- public function index (): FluidColumnOptions
72+ public function index (? string $ indexName = null ): FluidColumnOptions
7373 {
74- $ this ->fluidTable ->index ([$ this ->namingStrategy ->quoteIdentifier ($ this ->column ->getName ())]);
74+ $ this ->fluidTable ->index ([$ this ->namingStrategy ->quoteIdentifier ($ this ->column ->getName ())], $ indexName );
7575 return $ this ;
7676 }
7777 public function comment (string $ comment ): FluidColumnOptions
Original file line number Diff line number Diff line change @@ -53,15 +53,15 @@ public function column(string $name): FluidColumn
5353 return $ this ->fluidColumns [$ name ];
5454 }
5555
56- public function index (array $ columnNames ): FluidTable
56+ public function index (array $ columnNames, ? string $ indexName = null ): FluidTable
5757 {
58- $ this ->table ->addIndex ($ this ->quoteArray ($ columnNames ));
58+ $ this ->table ->addIndex ($ this ->quoteArray ($ columnNames ), $ indexName );
5959 return $ this ;
6060 }
6161
62- public function unique (array $ columnNames ): FluidTable
62+ public function unique (array $ columnNames, ? string $ indexName = null ): FluidTable
6363 {
64- $ this ->table ->addUniqueIndex ($ this ->quoteArray ($ columnNames ));
64+ $ this ->table ->addUniqueIndex ($ this ->quoteArray ($ columnNames ), $ indexName );
6565 return $ this ;
6666 }
6767
Original file line number Diff line number Diff line change @@ -26,8 +26,8 @@ public function testOptions()
2626 $ columnOptions ->notNull ();
2727 $ this ->assertSame (true , $ dbalColumn ->getNotnull ());
2828
29- $ columnOptions ->unique ();
30- $ this ->assertSame (true , $ dbalColumn -> getCustomSchemaOption ( ' unique ' ));
29+ $ columnOptions ->unique (' unique_foo ' );
30+ $ this ->assertSame (true , $ posts -> getDbalTable ()-> getIndex ( ' unique_foo ' )-> isUnique ( ));
3131
3232 $ columnOptions ->comment ('foo ' );
3333 $ this ->assertSame ('foo ' , $ dbalColumn ->getComment ());
You can’t perform that action at this time.
0 commit comments