diff --git a/resources/sql/patches/104.projectstatuses.sql b/resources/sql/patches/104.projectstatuses.sql deleted file mode 100644 index ead6c4bacb..0000000000 --- a/resources/sql/patches/104.projectstatuses.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE phabricator_project.project SET status = IF(status = 5, 100, 0); diff --git a/resources/sql/patches/104.searchkey.sql b/resources/sql/patches/104.searchkey.sql index 6c1961489f..d1bc2d5a7f 100644 --- a/resources/sql/patches/104.searchkey.sql +++ b/resources/sql/patches/104.searchkey.sql @@ -1,12 +1,15 @@ ALTER TABLE phabricator_search.search_query DROP authorPHID; ALTER TABLE phabricator_search.search_query ADD queryKey VARCHAR(12) NOT NULL; /* Preserve URIs for old queries in case anyone has them bookmarked. */ UPDATE phabricator_search.search_query SET queryKey = id; 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); diff --git a/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php b/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php index 5487267040..6200bf45ae 100644 --- a/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php +++ b/src/infrastructure/setup/sql/PhabricatorSQLPatchList.php @@ -1,55 +1,62 @@ <?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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ final class PhabricatorSQLPatchList { public static function getPatchList() { $root = dirname(phutil_get_library_root('phabricator')); // Find the patch files $patches_dir = $root.'/resources/sql/patches/'; $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 // We need to apply them in proper order $patches = isort($patches, 'version'); return $patches; } public static function getExpectedSchemaVersion() { $patches = self::getPatchList(); $versions = ipull($patches, 'version'); $max_version = max($versions); return $max_version; } }