2013-02-18 03:48:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Schema;
|
|
|
|
|
2013-06-11 04:09:51 +02:00
|
|
|
|
2013-08-10 04:23:57 +02:00
|
|
|
function version_14($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec('ALTER TABLE config ADD COLUMN feed_token TEXT DEFAULT "'.\Model\generate_api_token().'"');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-04 21:15:12 +02:00
|
|
|
function version_13($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec('ALTER TABLE feeds ADD COLUMN enabled INTEGER DEFAULT 1');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-28 21:44:51 +02:00
|
|
|
function version_12($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec('ALTER TABLE config ADD COLUMN api_token TEXT DEFAULT "'.\Model\generate_api_token().'"');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-27 03:00:39 +02:00
|
|
|
function version_11($pdo)
|
|
|
|
{
|
|
|
|
$rq = $pdo->prepare('
|
|
|
|
SELECT
|
|
|
|
items.id, items.url AS item_url, feeds.site_url
|
|
|
|
FROM items
|
|
|
|
LEFT JOIN feeds ON feeds.id=items.feed_id
|
|
|
|
');
|
|
|
|
|
|
|
|
$rq->execute();
|
|
|
|
|
|
|
|
$items = $rq->fetchAll(\PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
foreach ($items as $item) {
|
|
|
|
|
|
|
|
if ($item['id'] !== $item['item_url']) {
|
|
|
|
|
|
|
|
$id = hash('crc32b', $item['id'].$item['site_url']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
$id = hash('crc32b', $item['item_url'].$item['site_url']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$rq = $pdo->prepare('UPDATE items SET id=? WHERE id=?');
|
|
|
|
$rq->execute(array($id, $item['id']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-17 03:58:11 +02:00
|
|
|
function version_10($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec('ALTER TABLE config ADD COLUMN theme TEXT DEFAULT "original"');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-06 16:50:37 +02:00
|
|
|
function version_9($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec('ALTER TABLE config ADD COLUMN items_per_page INTEGER DEFAULT 100');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-15 05:12:08 +02:00
|
|
|
function version_8($pdo)
|
2013-06-04 13:38:54 +02:00
|
|
|
{
|
2013-06-15 05:12:08 +02:00
|
|
|
$pdo->exec('ALTER TABLE items ADD COLUMN bookmark INTEGER DEFAULT 0');
|
2013-06-04 13:38:54 +02:00
|
|
|
}
|
|
|
|
|
2013-06-11 04:09:51 +02:00
|
|
|
|
2013-06-06 17:54:22 +02:00
|
|
|
function version_7($pdo)
|
|
|
|
{
|
2013-06-11 04:09:51 +02:00
|
|
|
$pdo->exec('ALTER TABLE config ADD COLUMN nocontent INTEGER DEFAULT 0');
|
2013-06-06 17:54:22 +02:00
|
|
|
}
|
2013-05-26 19:09:34 +02:00
|
|
|
|
2013-06-11 04:09:51 +02:00
|
|
|
|
2013-05-23 13:44:45 +02:00
|
|
|
function version_6($pdo)
|
|
|
|
{
|
2013-05-26 19:09:34 +02:00
|
|
|
$pdo->exec('ALTER TABLE config ADD COLUMN autoflush INTEGER DEFAULT 0');
|
2013-05-23 13:44:45 +02:00
|
|
|
}
|
|
|
|
|
2013-05-21 12:25:13 +02:00
|
|
|
|
2013-05-18 20:35:16 +02:00
|
|
|
function version_5($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec('ALTER TABLE feeds ADD COLUMN last_checked INTEGER');
|
|
|
|
}
|
2013-04-07 03:15:42 +02:00
|
|
|
|
2013-05-21 12:25:13 +02:00
|
|
|
|
2013-04-23 04:41:20 +02:00
|
|
|
function version_4($pdo)
|
|
|
|
{
|
2013-06-15 05:12:08 +02:00
|
|
|
$pdo->exec('CREATE INDEX idx_status ON items(status)');
|
2013-04-23 04:41:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-13 03:08:55 +02:00
|
|
|
function version_3($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec("ALTER TABLE config ADD COLUMN language TEXT DEFAULT 'en_US'");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-07 03:15:42 +02:00
|
|
|
function version_2($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec('ALTER TABLE feeds ADD COLUMN last_modified TEXT');
|
|
|
|
$pdo->exec('ALTER TABLE feeds ADD COLUMN etag TEXT');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-18 03:48:21 +01:00
|
|
|
function version_1($pdo)
|
|
|
|
{
|
|
|
|
$pdo->exec("
|
|
|
|
CREATE TABLE config (
|
|
|
|
username TEXT DEFAULT 'admin',
|
2013-04-07 03:15:42 +02:00
|
|
|
password TEXT
|
2013-02-18 03:48:21 +01:00
|
|
|
)
|
|
|
|
");
|
|
|
|
|
|
|
|
$pdo->exec("
|
|
|
|
INSERT INTO config
|
|
|
|
(password)
|
2013-03-20 05:20:52 +01:00
|
|
|
VALUES ('".\password_hash('admin', PASSWORD_BCRYPT)."')
|
2013-02-18 03:48:21 +01:00
|
|
|
");
|
|
|
|
|
|
|
|
$pdo->exec('
|
|
|
|
CREATE TABLE feeds (
|
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
site_url TEXT,
|
|
|
|
feed_url TEXT UNIQUE,
|
2013-07-10 03:31:46 +02:00
|
|
|
title TEXT COLLATE NOCASE
|
2013-02-18 03:48:21 +01:00
|
|
|
)
|
|
|
|
');
|
|
|
|
|
|
|
|
$pdo->exec('
|
|
|
|
CREATE TABLE items (
|
|
|
|
id TEXT PRIMARY KEY,
|
|
|
|
url TEXT,
|
|
|
|
title TEXT,
|
|
|
|
author TEXT,
|
|
|
|
content TEXT,
|
2013-07-06 16:50:37 +02:00
|
|
|
updated INTEGER,
|
2013-02-18 03:48:21 +01:00
|
|
|
status TEXT,
|
|
|
|
feed_id INTEGER,
|
|
|
|
FOREIGN KEY(feed_id) REFERENCES feeds(id) ON DELETE CASCADE
|
|
|
|
)
|
|
|
|
');
|
2013-05-23 13:44:45 +02:00
|
|
|
}
|