Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20140521.projectslug.2.mig.php
| <?php | <?php | ||||
| $project_table = new PhabricatorProject(); | $project_table = new PhabricatorProject(); | ||||
| $table_name = $project_table->getTableName(); | $table_name = $project_table->getTableName(); | ||||
| $conn_w = $project_table->establishConnection('w'); | $conn_w = $project_table->establishConnection('w'); | ||||
| $slug_table_name = id(new PhabricatorProjectSlug())->getTableName(); | $slug_table_name = id(new PhabricatorProjectSlug())->getTableName(); | ||||
| $time = time(); | $time = time(); | ||||
| echo "Migrating project phriction slugs...\n"; | echo pht('Migrating project phriction slugs...')."\n"; | ||||
| foreach (new LiskMigrationIterator($project_table) as $project) { | foreach (new LiskMigrationIterator($project_table) as $project) { | ||||
| $id = $project->getID(); | $id = $project->getID(); | ||||
| echo "Migrating project {$id}...\n"; | echo pht('Migrating project %d...', $id)."\n"; | ||||
| $phriction_slug = rtrim($project->getPhrictionSlug(), '/'); | $phriction_slug = rtrim($project->getPhrictionSlug(), '/'); | ||||
| $slug = id(new PhabricatorProjectSlug()) | $slug = id(new PhabricatorProjectSlug()) | ||||
| ->loadOneWhere('slug = %s', $phriction_slug); | ->loadOneWhere('slug = %s', $phriction_slug); | ||||
| if ($slug) { | if ($slug) { | ||||
| echo "Already migrated {$id}... Continuing.\n"; | echo pht('Already migrated %d... Continuing.', $id)."\n"; | ||||
| continue; | continue; | ||||
| } | } | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'INSERT INTO %T (projectPHID, slug, dateCreated, dateModified) '. | 'INSERT INTO %T (projectPHID, slug, dateCreated, dateModified) '. | ||||
| 'VALUES (%s, %s, %d, %d)', | 'VALUES (%s, %s, %d, %d)', | ||||
| $slug_table_name, | $slug_table_name, | ||||
| $project->getPHID(), | $project->getPHID(), | ||||
| $phriction_slug, | $phriction_slug, | ||||
| $time, | $time, | ||||
| $time); | $time); | ||||
| echo "Migrated {$id}.\n"; | echo pht('Migrated %d.', $id)."\n"; | ||||
| } | } | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||