mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Add a safeguard against multiple patches with the same version
Summary: I accidentally added two "104" patches. This actually works OK for the most part but is fundamentally bad and wrong. Merge the patches (installs applied both as "104", so we can't move one to "105") and add a safeguard. Test Plan: Ran upgrade_schema.php with two "104" patches, got error'd. Ran without, got successs. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1614
This commit is contained in:
parent
6a11d8d0d1
commit
35c5852d3f
3 changed files with 12 additions and 3 deletions
|
@ -1 +0,0 @@
|
|||
UPDATE phabricator_project.project SET status = IF(status = 5, 100, 0);
|
|
@ -10,3 +10,6 @@ UPDATE phabricator_search.search_query
|
|||
|
||||
ALTER TABLE phabricator_search.search_query
|
||||
ADD UNIQUE KEY (queryKey);
|
||||
|
||||
/* NOTE: Accidentally added this as 104, merging. */
|
||||
UPDATE phabricator_project.project SET status = IF(status = 5, 100, 0);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,16 +26,23 @@ final class PhabricatorSQLPatchList {
|
|||
$finder = new FileFinder($patches_dir);
|
||||
$results = $finder->find();
|
||||
|
||||
$versions = array();
|
||||
$patches = array();
|
||||
foreach ($results as $path) {
|
||||
$matches = array();
|
||||
if (!preg_match('/(\d+)\..*\.(sql|php)$/', $path, $matches)) {
|
||||
continue;
|
||||
}
|
||||
$version = (int)$matches[1];
|
||||
$patches[] = array(
|
||||
'version' => (int)$matches[1],
|
||||
'version' => $version,
|
||||
'path' => $patches_dir.$path,
|
||||
);
|
||||
if (empty($versions[$version])) {
|
||||
$versions[$version] = true;
|
||||
} else {
|
||||
throw new Exception("Two patches have version {$version}!");
|
||||
}
|
||||
}
|
||||
|
||||
// Files are in some 'random' order returned by the operating system
|
||||
|
|
Loading…
Reference in a new issue