Give Drydock leases a resourcePHID instead of a resourceID

Summary:
Ref T9252. Leases currently have a `resourceID`, but this is a bit nonstandard and generally less flexible than giving them a `resourcePHID`.

In particular, a `resourcePHID` is easier to use when rendering interfaces, since you can get handles out of a PHID.

Add a PHID column, copy over all the PHIDs that correspond to existing IDs, then drop the ID column.

Test Plan:
  - Browsed web UIs.
  - Inspected database during/after migration.
  - Grepped for `resourceID`.
  - Allocated a new lease with `bin/drydock lease`.

Reviewers: chad, hach-que

Reviewed By: hach-que

Maniphest Tasks: T9252

Differential Revision: https://secure.phabricator.com/D14151
This commit is contained in:
epriestley
2015-09-24 04:19:27 -07:00
parent 309aadc595
commit c6aade4392
10 changed files with 39 additions and 44 deletions

View File

@@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_drydock.drydock_lease
ADD resourcePHID VARBINARY(64);

View File

@@ -0,0 +1,5 @@
UPDATE
{$NAMESPACE}_drydock.drydock_lease l,
{$NAMESPACE}_drydock.drydock_resource r
SET l.resourcePHID = r.phid
WHERE l.resourceID = r.id;

View File

@@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_drydock.drydock_lease
DROP resourceID;