3 require_once(DOCROOT . 'inc/wfpl/persistent.php');
7 # 1. Write the next db_upgrade_to_XX() at the bottom of this file
9 # 2. curl -H "X-UPGRADE-DB-NOW: y" http://this-site.com/
11 function db_upgrade() {
12 header("Content-Type: text/plain");
13 ini_set('display_errors', '1');
14 ini_set('html_errors', '0');
16 # initialize where we store the current db schema version
17 db_send_query('create table if not exists persistent ( k varchar(30) binary not null default "", v varchar(255) binary not null default "", primary key (k)) CHARSET=utf8;');
19 # now we can just do the needed upgrades
20 $cur = persistent_get('db_schema_version');
25 echo "db schema at version $cur\n\n";
28 for ($next = $cur + 1; function_exists("db_upgrade_$next"); $next += 1) {
29 echo "upgrading DB to version $next...\n";
31 call_user_func("db_upgrade_$next");
32 persistent_set('db_schema_version', $next);
39 echo "Upgrades complete\n";
41 echo "No upgrades needed\n";
47 #function db_upgrade_1() {
48 # db_send_query("alter table foo add bar int(11) not null default 0");