Commit e3587aae authored by catch's avatar catch

Issue #2772295 by ieguskiza, Adita, Adameue, Munavijayalakshmi: Replace...

Issue #2772295 by ieguskiza, Adita, Adameue, Munavijayalakshmi: Replace confusing references to db_add_* and db_drop_* with clearer references to the current API
parent 74ba0f68
...@@ -552,7 +552,8 @@ protected function findPrimaryKeyColumns($table) { ...@@ -552,7 +552,8 @@ protected function findPrimaryKeyColumns($table) {
* recreate all indices and primary keys that are using the changed field. * recreate all indices and primary keys that are using the changed field.
* *
* That means that you have to drop all affected keys and indexes with * That means that you have to drop all affected keys and indexes with
* db_drop_{primary_key,unique_key,index}() before calling ::changeField(). * Schema::dropPrimaryKey(), Schema::dropUniqueKey(), or Schema::dropIndex()
* before calling ::changeField().
* To recreate the keys and indices, pass the key definitions as the * To recreate the keys and indices, pass the key definitions as the
* optional $keys_new argument directly to ::changeField(). * optional $keys_new argument directly to ::changeField().
* *
...@@ -568,9 +569,8 @@ protected function findPrimaryKeyColumns($table) { ...@@ -568,9 +569,8 @@ protected function findPrimaryKeyColumns($table) {
* and you want to change foo.bar to be type serial, leaving it as the * and you want to change foo.bar to be type serial, leaving it as the
* primary key. The correct sequence is: * primary key. The correct sequence is:
* @code * @code
* $schema = \Drupal::database()->schema(); * $injected_database->schema()->dropPrimaryKey('foo');
* $schema->dropPrimaryKey('foo'); * $injected_database->schema()->changeField('foo', 'bar', 'bar',
* $schema->changeField('foo', 'bar', 'bar',
* array('type' => 'serial', 'not null' => TRUE), * array('type' => 'serial', 'not null' => TRUE),
* array('primary key' => array('bar'))); * array('primary key' => array('bar')));
* @endcode * @endcode
...@@ -583,15 +583,15 @@ protected function findPrimaryKeyColumns($table) { ...@@ -583,15 +583,15 @@ protected function findPrimaryKeyColumns($table) {
* *
* On MySQL, all type 'serial' fields must be part of at least one key * On MySQL, all type 'serial' fields must be part of at least one key
* or index as soon as they are created. You cannot use * or index as soon as they are created. You cannot use
* db_add_{primary_key,unique_key,index}() for this purpose because * Schema::addPrimaryKey, Schema::addUniqueKey(), or Schema::addIndex()
* the ALTER TABLE command will fail to add the column without a key * for this purpose because the ALTER TABLE command will fail to add
* or index specification. The solution is to use the optional * the column without a key or index specification.
* $keys_new argument to create the key or index at the same time as * The solution is to use the optional $keys_new argument to create the key
* field. * or index at the same time as field.
* *
* You could use db_add_{primary_key,unique_key,index}() in all cases * You could use Schema::addPrimaryKey, Schema::addUniqueKey(), or
* unless you are converting a field to be type serial. You can use * Schema::addIndex() in all cases unless you are converting a field to
* the $keys_new argument in all cases. * be type serial. You can use the $keys_new argument in all cases.
* *
* @param $table * @param $table
* Name of the table. * Name of the table.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment