Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion init.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function initDatabase() {
clientData TEXT NOT NULL
)',
'CREATE TABLE IF NOT EXISTS allowedClients (
userId VARCHAR(255) NOT NULL PRIMARY KEY,
userId VARCHAR(255) NOT NULL,
clientId VARCHAR(255) NOT NULL
)',
'CREATE TABLE IF NOT EXISTS userStorage (
Expand Down
28 changes: 28 additions & 0 deletions upgrade/0.4.1/upgrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
require_once(__DIR__ . "/../../config.php");
require_once(__DIR__ . "/../../vendor/autoload.php");

use Pdsinterop\PhpSolid\Server;

function upgradeDatabase() {
$statements = [
'BEGIN TRANSACTION',
'CREATE TABLE allowedClients_new (userId VARCHAR(255) NOT NULL, clientId VARCHAR(255) NOT NULL)',
'INSERT INTO allowedClients_new (userId, clientId) SELECT userId, clientId FROM allowedClients',
'DROP TABLE allowedClients',
'ALTER TABLE allowedClients_new RENAME TO allowedClients',
'COMMIT'
];

try {
$pdo = new \PDO("sqlite:" . DBPATH);

// create tables
foreach($statements as $statement){
$pdo->exec($statement);
}
} catch(\PDOException $e) {
echo $e->getMessage();
}
}
upgradeDatabase();
Loading