· 9 years ago · Jan 05, 2017, 03:52 AM
1diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php
2index 76daa16..f6b0649 100644
3--- a/core/lib/Drupal/Core/Database/Schema.php
4+++ b/core/lib/Drupal/Core/Database/Schema.php
5@@ -312,7 +312,7 @@ public function fieldExists($table, $column) {
6 * table along with adding the field. The format is the same as a
7 * table specification but without the 'fields' element. If you are
8 * adding a type 'serial' field, you MUST specify at least one key
9- * or index including it in this array. See Schema::changeField() for more
10+ * or index including it in this array. See db_change_field() for more
11 * explanation why.
12 *
13 * @throws \Drupal\Core\Database\SchemaObjectDoesNotExistException
14@@ -518,9 +518,10 @@ public function fieldExists($table, $column) {
15 * recreate all indices and primary keys that are using the changed field.
16 *
17 * That means that you have to drop all affected keys and indexes with
18- * Schema::drop{PrimaryKey,UniqueKey,Index}() before calling Schema::changeField().
19+ * Schema::dropPrimaryKey(), Schema::dropUniqueKey() or Schema::dropIndex()
20+ * before calling db_change_field().
21 * To recreate the keys and indices, pass the key definitions as the
22- * optional $keys_new argument directly to Schema::changeField().
23+ * optional $keys_new argument directly to db_change_field().
24 *
25 * For example, suppose you have:
26 * @code
27@@ -534,8 +535,8 @@ public function fieldExists($table, $column) {
28 * and you want to change foo.bar to be type serial, leaving it as the
29 * primary key. The correct sequence is:
30 * @code
31- * $schema->dropPrimaryKey('foo');
32- * $schema->changeField('foo', 'bar', 'bar',
33+ * $injected_database->schema()->dropPrimaryKey('foo');
34+ * db_change_field('foo', 'bar', 'bar',
35 * array('type' => 'serial', 'not null' => TRUE),
36 * array('primary key' => array('bar')));
37 * @endcode
38@@ -548,14 +549,14 @@ public function fieldExists($table, $column) {
39 *
40 * On MySQL, all type 'serial' fields must be part of at least one key
41 * or index as soon as they are created. You cannot use
42- * Schema::add{PrimaryKey,UniqueKey,Index}() for this purpose because
43- * the ALTER TABLE command will fail to add the column without a key
44- * or index specification. The solution is to use the optional
45- * $keys_new argument to create the key or index at the same time as
46- * field.
47- *
48- * You could use Schema::add{PrimaryKey,UniqueKey,Index}() in all cases
49- * unless you are converting a field to be type serial. You can use
50+ * Schema::addPrimaryKey, Schema::addUniqueKey() or Schema::addIndex()
51+ * for this purpose because the ALTER TABLE command will fail to add
52+ * the column without a key or index specification.
53+ * The solution is to use the optional $keys_new argument to create the key
54+ * or index at the same time as field.
55+ *
56+ * You could use Schema::addPrimaryKey, Schema::addUniqueKey() or Schema::addIndex()
57+ * in all cases unless you are converting a field to be type serial. You can use
58 * the $keys_new argument in all cases.
59 *
60 * @param $table
61diff --git a/core/modules/system/tests/modules/update_test_schema/update_test_schema.install b/core/modules/system/tests/modules/update_test_schema/update_test_schema.install
62index 972f901..81ed1a6 100644
63--- a/core/modules/system/tests/modules/update_test_schema/update_test_schema.install
64+++ b/core/modules/system/tests/modules/update_test_schema/update_test_schema.install
65@@ -43,6 +43,6 @@ function update_test_schema_update_8001() {
66 ];
67
68 // Add a column.
69- db_add_index('update_test_schema_table', 'test', ['a'], $table);
70+ \Drupal::database()->schema()->addIndex('update_test_schema_table', 'test', ['a'], $table);
71 }
72 }
73diff --git a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
74index 8641fd3..f5b9f8e 100644
75--- a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
76+++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
77@@ -95,7 +95,7 @@ function testSchema() {
78 $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
79 $this->assertIdentical($index_exists, FALSE, 'Fake index does not exists');
80 // Add index.
81- db_add_index('test_table', 'test_field', array('test_field'), $table_specification);
82+ Database::getConnection()->schema()->addIndex('test_table', 'test_field', array('test_field'), $table_specification);
83 // Test for created index and test for the boolean result of indexExists().
84 $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
85 $this->assertIdentical($index_exists, TRUE, 'Index created.');