]> git.wh0rd.org Git - tt-rss.git/commitdiff
schema_version handling in backend.php
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 10 Nov 2005 04:35:39 +0000 (05:35 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 10 Nov 2005 04:35:39 +0000 (05:35 +0100)
backend.php

index 611b67b38805b611a45ff33e891cf13708a9e490..2a8657474f67da6b63c5df31b4efbe8f690d2b67 100644 (file)
@@ -1,4 +1,6 @@
 <?
+       define(SCHEMA_VERSION, 2);
+
        $op = $_GET["op"];
 
        if ($op == "rpc") {
        if (DB_TYPE == "pgsql") {
                pg_query("set client_encoding = 'utf-8'");
        }
+
+       $result = db_query($link, "SELECT schema_version FROM ttrss_version");
+
+       $schema_version = db_fetch_result($result, 0, "schema_version");
+
+       if ($schema_version != SCHEMA_VERSION) {
+               print "Error: database schema is invalid
+                       (got version $schema_version; expected ".SCHEMA_VERSION.")";
+               return;
+       }
        
        $fetch = $_GET["fetch"];