1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Use define() instead of PHP 5.3-only global 'const' in upgrade_schema.php

Summary:
This global 'const' syntax was introduced in PHP 5.3:

http://www.php.net/manual/en/language.constants.syntax.php

We're PHP 5.2.x elsewhere so just use define(). Made the constant a little more
specific too.

Test Plan:
Ran upgrade_schema.php script.

Reviewed By: Girish
Reviewers: tuomaspelkonen, Girish, davidrecordon
CC: jungejason, aran, epriestley, Girish
Differential Revision: 190
This commit is contained in:
epriestley 2011-04-29 23:13:50 -07:00
parent b3397030e6
commit 3e2f648175

View file

@ -23,7 +23,7 @@ require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console'); phutil_require_module('phutil', 'console');
const TABLE_NAME = 'schema_version'; define('SCHEMA_VERSION_TABLE_NAME', 'schema_version');
if (isset($argv[1]) && !is_numeric($argv[1])) { if (isset($argv[1]) && !is_numeric($argv[1])) {
print print
@ -82,7 +82,7 @@ if ($next_version === null) {
$version = queryfx_one( $version = queryfx_one(
$conn, $conn,
'SELECT * FROM %T', 'SELECT * FROM %T',
TABLE_NAME); SCHEMA_VERSION_TABLE_NAME);
if (!$version) { if (!$version) {
print "*** No version information in the database ***\n"; print "*** No version information in the database ***\n";
@ -142,12 +142,16 @@ foreach ($patches as $patch) {
// Patch was successful, update the db with the latest applied patch version // Patch was successful, update the db with the latest applied patch version
// 'DELETE' and 'INSERT' instead of update, because the table might be empty // 'DELETE' and 'INSERT' instead of update, because the table might be empty
queryfx($conn, 'DELETE FROM %T', TABLE_NAME); queryfx($conn, 'DELETE FROM %T', SCHEMA_VERSION_TABLE_NAME);
queryfx($conn, 'INSERT INTO %T values (%d)', TABLE_NAME, $patch['version']); queryfx(
$conn,
'INSERT INTO %T values (%d)',
SCHEMA_VERSION_TABLE_NAME,
$patch['version']);
$patch_applied = true; $patch_applied = true;
} }
if (!$patch_applied) { if (!$patch_applied) {
print "Your database is already up-to-date\n"; print "Your database is already up-to-date.\n";
} }