1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 17:00:59 +01:00
phorge-phorge/resources/sql/autopatches/20161213.diff.01.hunks.php
epriestley 11f3a8cfca Force 'changes' to a string in hunk migration
Summary: Fixes T12090. In obscure situations lost to the mists of time, the `changes` column could be `null`. Force a string cast so the migration finishes, even though these changesets are likely meaningless.

Test Plan:
I did a force-reapply as a sanity check:

```
$ ./bin/storage upgrade -f --apply phabricator:20161213.diff.01.hunks.php
```

That went cleanly; it would only have caught dramatic errors, but I didn't completely butcher things.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12090

Differential Revision: https://secure.phabricator.com/D17168
2017-01-10 12:28:09 -08:00

39 lines
950 B
PHP

<?php
$conn = id(new DifferentialRevision())->establishConnection('w');
$src_table = 'differential_hunk';
$dst_table = 'differential_hunk_modern';
echo tsprintf(
"%s\n",
pht('Migrating old hunks...'));
foreach (new LiskRawMigrationIterator($conn, $src_table) as $row) {
queryfx(
$conn,
'INSERT INTO %T
(changesetID, oldOffset, oldLen, newOffset, newLen,
dataType, dataEncoding, dataFormat, data,
dateCreated, dateModified)
VALUES
(%d, %d, %d, %d, %d,
%s, %s, %s, %s,
%d, %d)',
$dst_table,
$row['changesetID'],
$row['oldOffset'],
$row['oldLen'],
$row['newOffset'],
$row['newLen'],
DifferentialModernHunk::DATATYPE_TEXT,
'utf8',
DifferentialModernHunk::DATAFORMAT_RAW,
// In rare cases, this could be NULL. See T12090.
(string)$row['changes'],
$row['dateCreated'],
$row['dateModified']);
}
echo tsprintf(
"%s\n",
pht('Done.'));