Issue #3365945: Errors: The following table(s) do not have a primary key: forum_index
6 unresolved threads
Merge request reports
Activity
added 18 commits
-
78b73735...e370dbe9 - 12 commits from branch
project:10.1.x
- ec601d00 - Issue#3365945: Resolve primary key issue.
- 4a67fff6 - Update fields for primary key and for new installs.
- 238a46fd - Remove exception for sqllite.
- bd77fe75 - Add kernel test
- 5e4fadbd - Update test
- d6c0d5cd - Make test work on all engines
Toggle commit list-
78b73735...e370dbe9 - 12 commits from branch
added 40 commits
-
25b39e02...37dd50f5 - 32 commits from branch
project:10.1.x
- bf9a334f - Issue#3365945: Resolve primary key issue.
- aa729d42 - Update fields for primary key and for new installs.
- 93f234b0 - Remove exception for sqllite.
- 5f577fb9 - Add kernel test
- ff991123 - Update test
- d01b9c4d - Make test work on all engines
- 2bf53ef3 - Add missing tag
- 2ebd0585 - Fix test
Toggle commit list-
25b39e02...37dd50f5 - 32 commits from branch
204 205 $connection->schema()->changeField('forum_index', 'last_comment_timestamp', 'last_comment_timestamp', $new); 205 206 } 206 207 } 208 209 /** 210 * Add a primary key to forum_index. 211 */ 212 function forum_update_10101(&$sandbox = NULL) { 213 $connection = \Drupal::database(); 214 if ($connection->schema()->tableExists('forum_index')) { 215 $connection->schema()->addPrimaryKey('forum_index', ['nid', 'tid']); 19 protected function setDatabaseDumpFiles() { 20 $this->databaseDumpFiles = [ 21 dirname(__DIR__, 2) . '/fixtures/update/drupal-10.1.0.empty.testing.forum.gz', 22 ]; 23 } 24 25 /** 26 * Tests the update path to add the new primary key. 27 */ 28 public function testUpdatePath(): void { 29 $schema = \Drupal::database()->schema(); 30 // We can't reliably call ::indexExists for each database driver as sqlite 31 // doesn't have named indexes for primary keys like mysql (PRIMARY) and 32 // pgsql (pkey). 33 $find_primary_key_columns = new \ReflectionMethod(get_class($schema), 'findPrimaryKeyColumns'); 34 $find_primary_key_columns->setAccessible(TRUE); changed this line in version 8 of the diff
38 $this->installEntitySchema('comment'); 39 $this->installEntitySchema('taxonomy_term'); 40 $this->installSchema('forum', ['forum_index']); 41 } 42 43 /** 44 * Tests there's a primary key on the forum_index table. 45 */ 46 public function testForumIndexIndex(): void { 47 $schema = \Drupal::database()->schema(); 48 $this->assertTrue($schema->tableExists('forum_index')); 49 // We can't reliably call ::indexExists for each database driver as sqlite 50 // doesn't have named indexes for primary keys like mysql (PRIMARY) and 51 // pgsql (pkey). 52 $find_primary_key_columns = new \ReflectionMethod(get_class($schema), 'findPrimaryKeyColumns'); 53 $find_primary_key_columns->setAccessible(TRUE); changed this line in version 8 of the diff
204 205 $connection->schema()->changeField('forum_index', 'last_comment_timestamp', 'last_comment_timestamp', $new); 205 206 } 206 207 } 208 209 /** 210 * Add a primary key to forum_index. 211 */ 212 function forum_update_10101(&$sandbox = NULL) { 213 $connection = \Drupal::database(); 214 if ($connection->schema()->tableExists('forum_index')) { 215 // Identify duplicate records. 216 $query = $connection->select('forum_index') 217 ->fields('forum_index', ['nid', 'tid']) 218 ->having('COUNT(*) > 1'); 225 ->condition('tid', $record->'tid'); 226 227 // Get the duplicate records. 228 $duplicateRecords = $duplicateQuery->execute()->fetchAll(); 229 230 // Keep the first record and delete the rest. 231 $firstRecord = true; 232 foreach ($duplicateRecords as $duplicateRecord) { 233 if ($firstRecord) { 234 $firstRecord = false; 235 continue; 236 } 237 // Delete the duplicate record. 238 $connection->delete('forum_index') 239 ->condition('nid', $record->'nid') 240 ->condition('tid', $record->'tid'); 18 */ 19 protected function setDatabaseDumpFiles() { 20 $this->databaseDumpFiles = [ 21 dirname(__DIR__, 2) . '/fixtures/update/drupal-10.1.0.empty.testing.forum.gz', 22 ]; 23 } 24 25 /** 26 * Tests the update path to add the new primary key. 27 */ 28 public function testUpdatePath(): void { 29 $schema = \Drupal::database()->schema(); 30 // We can't reliably call ::indexExists for each database driver as sqlite 31 // doesn't have named indexes for primary keys like mysql (PRIMARY) and 32 // pgsql (pkey). 33 $find_primary_key_columns = new \ReflectionMethod(get_class($schema), 'findPrimaryKeyColumns');
Please register or sign in to reply