mirror of
https://we.phorge.it/source/phorge.git
synced 2024-10-19 15:18:51 +02:00
7d4b323da2
Summary: Ref T10449. Currently, we store classes (like "AlmanacClusterRepositoryServiceType") in the database. Instead, store types (like "cluster.repository"). This is a small change, but types are a little more flexible (they let us freely reanme classes), a little cleaner (fewer magic strings in the codebase), and a little better for API usage (they're more human readable). Make this minor usability change now, before we unprototype. Also make services searchable by type. Also remove old Almanac API endpoints. Test Plan: - Ran migration, verified all data migrated properly. - Created, edited, rebound, and changed properties of services. - Searched for services by service type. - Reviewed available Conduit methods. Reviewers: chad Reviewed By: chad Subscribers: yelirekim Maniphest Tasks: T10449 Differential Revision: https://secure.phabricator.com/D15346
30 lines
640 B
PHP
30 lines
640 B
PHP
<?php
|
|
|
|
// Previously, Almanac services stored a "serviceClass". Migrate these to
|
|
// new "serviceType" values.
|
|
|
|
$table = new AlmanacService();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
foreach (new LiskMigrationIterator($table) as $service) {
|
|
|
|
$new_type = null;
|
|
try {
|
|
$old_type = $service->getServiceType();
|
|
$object = newv($old_type, array());
|
|
$new_type = $object->getServiceTypeConstant();
|
|
} catch (Exception $ex) {
|
|
continue;
|
|
}
|
|
|
|
if (!$new_type) {
|
|
continue;
|
|
}
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'UPDATE %T SET serviceType = %s WHERE id = %d',
|
|
$table->getTableName(),
|
|
$new_type,
|
|
$service->getID());
|
|
}
|