mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Move directory SQL patch construction to abstract base class
Summary: Ref T6238. I'm building the instance management application now, but not putting it in the upstream -- I think the only use case for it is to build SAAS. If someone comes up with a use case (maybe a college course that wants to create an instance per-class or something?) we could open it up eventually, but it seems cleaner to keep it out of the upstream until we have such a use case. I need to add schema patches. Make it easier for a subclass to just "add all the patches in this directory", like "autopatches/" works. Test Plan: - Ran `bin/storage status`, saw all normal patches still valid. - In some future diff, the instances application will use this to apply patches. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6238 Differential Revision: https://secure.phabricator.com/D10848
This commit is contained in:
parent
84f741f408
commit
a1f5fc2231
3 changed files with 33 additions and 19 deletions
|
@ -527,7 +527,7 @@ abstract class PhabricatorController extends AphrontController {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildTransactionTimeline(
|
protected function buildTransactionTimeline(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorApplicationTransactionInterface $object,
|
||||||
PhabricatorApplicationTransactionQuery $query,
|
PhabricatorApplicationTransactionQuery $query,
|
||||||
PhabricatorMarkupEngine $engine = null) {
|
PhabricatorMarkupEngine $engine = null) {
|
||||||
|
|
||||||
|
|
|
@ -39,24 +39,7 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
||||||
|
|
||||||
$root = dirname(phutil_get_library_root('phabricator'));
|
$root = dirname(phutil_get_library_root('phabricator'));
|
||||||
$auto_root = $root.'/resources/sql/autopatches/';
|
$auto_root = $root.'/resources/sql/autopatches/';
|
||||||
$auto_list = Filesystem::listDirectory($auto_root, $include_hidden = false);
|
$patches += $this->buildPatchesFromDirectory($auto_root);
|
||||||
sort($auto_list);
|
|
||||||
|
|
||||||
foreach ($auto_list as $auto_patch) {
|
|
||||||
$matches = null;
|
|
||||||
if (!preg_match('/\.(sql|php)$/', $auto_patch, $matches)) {
|
|
||||||
throw new Exception(
|
|
||||||
pht(
|
|
||||||
'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.',
|
|
||||||
$auto_patch,
|
|
||||||
$auto_root));
|
|
||||||
}
|
|
||||||
|
|
||||||
$patches[$auto_patch] = array(
|
|
||||||
'type' => $matches[1],
|
|
||||||
'name' => $auto_root.$auto_patch,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $patches;
|
return $patches;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,37 @@ abstract class PhabricatorSQLPatchList {
|
||||||
abstract function getNamespace();
|
abstract function getNamespace();
|
||||||
abstract function getPatches();
|
abstract function getPatches();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Examine a directory for `.php` and `.sql` files and build patch
|
||||||
|
* specifications for them.
|
||||||
|
*/
|
||||||
|
protected function buildPatchesFromDirectory($directory) {
|
||||||
|
$patch_list = Filesystem::listDirectory(
|
||||||
|
$directory,
|
||||||
|
$include_hidden = false);
|
||||||
|
|
||||||
|
sort($patch_list);
|
||||||
|
$patches = array();
|
||||||
|
|
||||||
|
foreach ($patch_list as $patch) {
|
||||||
|
$matches = null;
|
||||||
|
if (!preg_match('/\.(sql|php)$/', $patch, $matches)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.',
|
||||||
|
$patch,
|
||||||
|
$directory));
|
||||||
|
}
|
||||||
|
|
||||||
|
$patches[$patch] = array(
|
||||||
|
'type' => $matches[1],
|
||||||
|
'name' => rtrim($directory, '/').'/'.$patch,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $patches;
|
||||||
|
}
|
||||||
|
|
||||||
final public static function buildAllPatches() {
|
final public static function buildAllPatches() {
|
||||||
$patch_lists = id(new PhutilSymbolLoader())
|
$patch_lists = id(new PhutilSymbolLoader())
|
||||||
->setAncestorClass('PhabricatorSQLPatchList')
|
->setAncestorClass('PhabricatorSQLPatchList')
|
||||||
|
|
Loading…
Reference in a new issue