Ignore:
Timestamp:
Sep 9, 2015, 10:03:34 PM (11 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
master
Children:
915dc18
Parents:
d83a844
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/webservice/htdocs/SiWeather/Webservice/Setup.php

    rd83a844 re498070  
    251251                }
    252252
     253                // prepare status table
     254                $table = "status";
     255                if(!$this->databaseTableExists($table)){
     256                        $sql  = "CREATE TABLE ". $table ." (";
     257                        $sql .= "  id INTEGER NOT NULL PRIMARY KEY,";
     258                        $sql .= "  name TEXT NOT NULL";
     259                        $sql .= ")";
     260                        if(!$this->databaseTableCreate($table, $sql, $errorMessage)){
     261                                return false;
     262                        }
     263                        $status = array("confirming", "active", "deletionrequested");
     264                        $sql  = "INSERT INTO ". $table ." (name) VALUES(:name)";
     265                        $sqlStatement = $this->_databaseHandler->prepare($sql);
     266                        foreach ($status as $name){
     267                                $sqlStatement->clear();
     268                                $sqlStatement->bindValue(":name", $name);
     269                                if(!$sqlStatement->execute()){
     270                                        $errorMessage = Translation::swGettext("Could not add status %s to the database", $name);
     271                                        error_log($errorMessage);
     272                                        return false;
     273                                }
     274                                $sqlStatement->reset();
     275                        }
     276                }
     277
    253278                // prepare stations table
    254279                $table = "stations";
    … …  
    257282                        $sql .= "  id INTEGER NOT NULL PRIMARY KEY,";
    258283                        $sql .= "  name TEXT NOT NULL,";
    259                         $sql .= "  city INTEGER,";
     284                        $sql .= "  city INTEGER NOT NULL,";
    260285                        $sql .= "  uuid TEXT NOT NULL,";
    261286                        $sql .= "  ownerMail TEXT NOT NULL,";
     287                        $sql .= "  type TEXT NOT NULL,";
     288                        $sql .= "  typeUrl TEXT,";
     289                        $sql .= "  status INTEGER NOT NULL,";
    262290                        $sql .= "  FOREIGN KEY(city) REFERENCES cities(id)";
     291                        $sql .= "  FOREIGN KEY(status) REFERENCES status(id)";
    263292                        $sql .= ")";
    264293                        if(!$this->databaseTableCreate($table, $sql, $errorMessage)){
Note: See TracChangeset for help on using the changeset viewer.