File inc/fixes.inc.php changed (mode: 100644) (index 1823204..dccca60) |
... |
... |
$rg_fixes[4] = array("rg_fixes_repos_last_bug_id"); |
19 |
19 |
$rg_fixes[5] = array("rg_fixes_wh_ver2"); |
$rg_fixes[5] = array("rg_fixes_wh_ver2"); |
20 |
20 |
$rg_fixes[6] = array("rg_fixes_wh_ver3"); |
$rg_fixes[6] = array("rg_fixes_wh_ver3"); |
21 |
21 |
$rg_fixes[7] = array("rg_fixes_wh_ver4"); |
$rg_fixes[7] = array("rg_fixes_wh_ver4"); |
|
22 |
|
$rg_fixes[8] = array("rg_fixes_wh_ver5"); |
22 |
23 |
|
|
23 |
24 |
// This must be the last line |
// This must be the last line |
24 |
25 |
$rg_fixes_ver = count($rg_fixes); |
$rg_fixes_ver = count($rg_fixes); |
|
... |
... |
function rg_fixes_wh_ver4($db) |
499 |
500 |
return $ret; |
return $ret; |
500 |
501 |
} |
} |
501 |
502 |
|
|
|
503 |
|
/* |
|
504 |
|
* Move to the more generic webhooks structure |
|
505 |
|
*/ |
|
506 |
|
function rg_fixes_wh_ver5($db) |
|
507 |
|
{ |
|
508 |
|
global $rg_repos; |
|
509 |
|
|
|
510 |
|
rg_prof_start("fixes_wh_ver5"); |
|
511 |
|
rg_log_enter("fixes_wh_ver5"); |
|
512 |
|
|
|
513 |
|
$ret = FALSE; |
|
514 |
|
while (1) { |
|
515 |
|
$f = rg_sql_fields($db, 'webhooks'); |
|
516 |
|
if ($f === FALSE) { |
|
517 |
|
rg_log('Could not load filed names...'); |
|
518 |
|
break; |
|
519 |
|
} |
|
520 |
|
|
|
521 |
|
// Remove old fields, if present |
|
522 |
|
$all_good = TRUE; |
|
523 |
|
$a = array('url', 'key', 'opaque', 'events'); |
|
524 |
|
foreach ($a as $t) { |
|
525 |
|
if (!isset($f[$t])) |
|
526 |
|
continue; |
|
527 |
|
|
|
528 |
|
$sql = 'ALTER TABLE webhooks DROP ' . $t; |
|
529 |
|
$res = rg_sql_query($db, $sql); |
|
530 |
|
if ($res === FALSE) { |
|
531 |
|
rg_log('Could not drop ' . $t . '!'); |
|
532 |
|
$all_good = FALSE; |
|
533 |
|
break; |
|
534 |
|
} |
|
535 |
|
rg_sql_free_result($res); |
|
536 |
|
} |
|
537 |
|
if (!$all_good) |
|
538 |
|
break; |
|
539 |
|
|
|
540 |
|
$ret = TRUE; |
|
541 |
|
break; |
|
542 |
|
} |
|
543 |
|
|
|
544 |
|
rg_log_exit(); |
|
545 |
|
rg_prof_end("fixes_wh_ver5"); |
|
546 |
|
return $ret; |
|
547 |
|
} |
|
548 |
|
|
502 |
549 |
|
|
503 |
550 |
/* |
/* |
504 |
551 |
* Apply fixes |
* Apply fixes |
File inc/sql.inc.php changed (mode: 100644) (index f1fd0ee..669fcd8) |
... |
... |
function rg_sql_table_exists($db, $table) |
355 |
355 |
return $rows; |
return $rows; |
356 |
356 |
} |
} |
357 |
357 |
|
|
|
358 |
|
/* |
|
359 |
|
* Returns the fileds names of a table |
|
360 |
|
*/ |
|
361 |
|
function rg_sql_fields($db, $table) |
|
362 |
|
{ |
|
363 |
|
$params = array('table' => $table); |
|
364 |
|
$sql = 'SELECT column_name FROM information_schema.columns' |
|
365 |
|
. ' WHERE table_name = @@table@@'; |
|
366 |
|
$res = rg_sql_query_params($db, $sql, $params); |
|
367 |
|
if ($res === FALSE) |
|
368 |
|
return FALSE; |
|
369 |
|
|
|
370 |
|
$ret = array(); |
|
371 |
|
while (($row = rg_sql_fetch_array($res))) { |
|
372 |
|
$f = $row['column_name']; |
|
373 |
|
$ret[$f] = 1; |
|
374 |
|
} |
|
375 |
|
rg_sql_free_result($res); |
|
376 |
|
|
|
377 |
|
return $ret; |
|
378 |
|
} |
|
379 |
|
|
358 |
380 |
?> |
?> |
File inc/struct.inc.php changed (mode: 100644) (index 4f0ca7c..7c011e1) |
... |
... |
$rg_sql_struct[36]['other'] = array( |
507 |
507 |
); |
); |
508 |
508 |
|
|
509 |
509 |
$rg_sql_struct[37]['other'] = array( |
$rg_sql_struct[37]['other'] = array( |
510 |
|
'webhooks - flags is back' => |
|
511 |
|
"ALTER TABLE webhooks ADD flags TEXT NOT NULL DEFAULT ''", |
|
512 |
510 |
'webhooks - add refname match' => |
'webhooks - add refname match' => |
513 |
511 |
"ALTER TABLE webhooks ADD refname TEXT NOT NULL DEFAULT ''", |
"ALTER TABLE webhooks ADD refname TEXT NOT NULL DEFAULT ''", |
514 |
512 |
'webhooks - repo_id not needed' => |
'webhooks - repo_id not needed' => |
|
... |
... |
$rg_sql_struct[37]['other'] = array( |
517 |
515 |
"ALTER TABLE webhooks ADD repo TEXT NOT NULL DEFAULT '';" |
"ALTER TABLE webhooks ADD repo TEXT NOT NULL DEFAULT '';" |
518 |
516 |
); |
); |
519 |
517 |
|
|
|
518 |
|
|
520 |
519 |
// This must be the last line |
// This must be the last line |
521 |
520 |
$rg_sql_schema_ver = count($rg_sql_struct); |
$rg_sql_schema_ver = count($rg_sql_struct); |
522 |
521 |
|
|
File tests/sql.php changed (mode: 100644) (index 5c85652..b7c5c9f) |
... |
... |
if (strcmp($row['f1'], "value") != 0) { |
69 |
69 |
exit(1); |
exit(1); |
70 |
70 |
} |
} |
71 |
71 |
|
|
|
72 |
|
|
|
73 |
|
rg_log(''); |
|
74 |
|
rg_log_enter('Testing rg_sql_fields...'); |
|
75 |
|
$r = rg_sql_fields($db, 'test'); |
|
76 |
|
if (($r === FALSE) || (count($r) != 3) || !isset($r['id'])) { |
|
77 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
78 |
|
rg_log('We do not have correct file names!'); |
|
79 |
|
exit(1); |
|
80 |
|
} |
|
81 |
|
rg_log_exit(); |
|
82 |
|
|
72 |
83 |
// TODO: test rg_sql_last_id |
// TODO: test rg_sql_last_id |
73 |
84 |
|
|
74 |
85 |
rg_sql_close($db); |
rg_sql_close($db); |