Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/111.commitauditmigration.php
| <?php | <?php | ||||
| echo "Updating old commit authors...\n"; | echo pht('Updating old commit authors...')."\n"; | ||||
| $table = new PhabricatorRepositoryCommit(); | $table = new PhabricatorRepositoryCommit(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| $conn = $table->establishConnection('w'); | $conn = $table->establishConnection('w'); | ||||
| $data = new PhabricatorRepositoryCommitData(); | $data = new PhabricatorRepositoryCommitData(); | ||||
| $commits = queryfx_all( | $commits = queryfx_all( | ||||
| $conn, | $conn, | ||||
| 'SELECT c.id id, c.authorPHID authorPHID, d.commitDetails details | 'SELECT c.id id, c.authorPHID authorPHID, d.commitDetails details | ||||
| Show All 14 Lines | queryfx( | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $author_phid, | $author_phid, | ||||
| $id); | $id); | ||||
| echo "#{$id}\n"; | echo "#{$id}\n"; | ||||
| } | } | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||
| echo "Updating old commit mailKeys...\n"; | echo pht('Updating old commit %s...', 'mailKeys')."\n"; | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| $commits = queryfx_all( | $commits = queryfx_all( | ||||
| $conn, | $conn, | ||||
| 'SELECT id FROM %T WHERE mailKey = %s FOR UPDATE', | 'SELECT id FROM %T WHERE mailKey = %s FOR UPDATE', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| ''); | ''); | ||||
| foreach ($commits as $commit) { | foreach ($commits as $commit) { | ||||
| $id = $commit['id']; | $id = $commit['id']; | ||||
| queryfx( | queryfx( | ||||
| $conn, | $conn, | ||||
| 'UPDATE %T SET mailKey = %s WHERE id = %d', | 'UPDATE %T SET mailKey = %s WHERE id = %d', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| Filesystem::readRandomCharacters(20), | Filesystem::readRandomCharacters(20), | ||||
| $id); | $id); | ||||
| echo "#{$id}\n"; | echo "#{$id}\n"; | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||