mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Correct PostgreSQL data format and other tweaks
This commit is contained in:
parent
8dfedd30ef
commit
10b228224d
4 changed files with 24 additions and 21 deletions
|
@ -31,7 +31,7 @@ create table arsse_folders(
|
||||||
owner text not null references arsse_users(id) on delete cascade on update cascade,
|
owner text not null references arsse_users(id) on delete cascade on update cascade,
|
||||||
parent bigint references arsse_folders(id) on delete cascade,
|
parent bigint references arsse_folders(id) on delete cascade,
|
||||||
name text not null,
|
name text not null,
|
||||||
modified timestamp(0) with time zone not null default CURRENT_TIMESTAMP, --
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP, --
|
||||||
unique(owner,name,parent)
|
unique(owner,name,parent)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -41,10 +41,10 @@ create table arsse_feeds(
|
||||||
title text,
|
title text,
|
||||||
favicon text,
|
favicon text,
|
||||||
source text,
|
source text,
|
||||||
updated timestamp(0) with time zone,
|
updated timestamp(0) without time zone,
|
||||||
modified timestamp(0) with time zone,
|
modified timestamp(0) without time zone,
|
||||||
next_fetch timestamp(0) with time zone,
|
next_fetch timestamp(0) without time zone,
|
||||||
orphaned timestamp(0) with time zone,
|
orphaned timestamp(0) without time zone,
|
||||||
etag text not null default '',
|
etag text not null default '',
|
||||||
err_count bigint not null default 0,
|
err_count bigint not null default 0,
|
||||||
err_msg text,
|
err_msg text,
|
||||||
|
@ -59,8 +59,8 @@ create table arsse_subscriptions(
|
||||||
id bigserial primary key,
|
id bigserial primary key,
|
||||||
owner text not null references arsse_users(id) on delete cascade on update cascade,
|
owner text not null references arsse_users(id) on delete cascade on update cascade,
|
||||||
feed bigint not null references arsse_feeds(id) on delete cascade,
|
feed bigint not null references arsse_feeds(id) on delete cascade,
|
||||||
added timestamp(0) with time zone not null default CURRENT_TIMESTAMP,
|
added timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
modified timestamp(0) with time zone not null default CURRENT_TIMESTAMP,
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
title text,
|
title text,
|
||||||
order_type smallint not null default 0,
|
order_type smallint not null default 0,
|
||||||
pinned smallint not null default 0,
|
pinned smallint not null default 0,
|
||||||
|
@ -74,9 +74,9 @@ create table arsse_articles(
|
||||||
url text,
|
url text,
|
||||||
title text,
|
title text,
|
||||||
author text,
|
author text,
|
||||||
published timestamp(0) with time zone,
|
published timestamp(0) without time zone,
|
||||||
edited timestamp(0) with time zone,
|
edited timestamp(0) without time zone,
|
||||||
modified timestamp(0) with time zone not null default CURRENT_TIMESTAMP,
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
content text,
|
content text,
|
||||||
guid text,
|
guid text,
|
||||||
url_title_hash text not null,
|
url_title_hash text not null,
|
||||||
|
@ -95,14 +95,14 @@ create table arsse_marks(
|
||||||
subscription bigint not null references arsse_subscriptions(id) on delete cascade on update cascade,
|
subscription bigint not null references arsse_subscriptions(id) on delete cascade on update cascade,
|
||||||
read smallint not null default 0,
|
read smallint not null default 0,
|
||||||
starred smallint not null default 0,
|
starred smallint not null default 0,
|
||||||
modified timestamp(0) with time zone not null default CURRENT_TIMESTAMP,
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
primary key(article,subscription)
|
primary key(article,subscription)
|
||||||
);
|
);
|
||||||
|
|
||||||
create table arsse_editions(
|
create table arsse_editions(
|
||||||
id bigserial primary key,
|
id bigserial primary key,
|
||||||
article bigint not null references arsse_articles(id) on delete cascade,
|
article bigint not null references arsse_articles(id) on delete cascade,
|
||||||
modified timestamp(0) with time zone not null default CURRENT_TIMESTAMP
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
create table arsse_categories(
|
create table arsse_categories(
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
create table arsse_sessions (
|
create table arsse_sessions (
|
||||||
id text primary key,
|
id text primary key,
|
||||||
created timestamp(0) with time zone not null default CURRENT_TIMESTAMP,
|
created timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
expires timestamp(0) with time zone not null,
|
expires timestamp(0) without time zone not null,
|
||||||
"user" text not null references arsse_users(id) on delete cascade on update cascade
|
"user" text not null references arsse_users(id) on delete cascade on update cascade
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ create table arsse_labels (
|
||||||
id bigserial primary key,
|
id bigserial primary key,
|
||||||
owner text not null references arsse_users(id) on delete cascade on update cascade,
|
owner text not null references arsse_users(id) on delete cascade on update cascade,
|
||||||
name text not null,
|
name text not null,
|
||||||
modified timestamp(0) with time zone not null default CURRENT_TIMESTAMP,
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
unique(owner,name)
|
unique(owner,name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ create table arsse_label_members (
|
||||||
article bigint not null references arsse_articles(id) on delete cascade,
|
article bigint not null references arsse_articles(id) on delete cascade,
|
||||||
subscription bigint not null references arsse_subscriptions(id) on delete cascade,
|
subscription bigint not null references arsse_subscriptions(id) on delete cascade,
|
||||||
assigned smallint not null default 1,
|
assigned smallint not null default 1,
|
||||||
modified timestamp(0) with time zone not null default CURRENT_TIMESTAMP,
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
primary key(label,article)
|
primary key(label,article)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ abstract class Base extends \JKingWeb\Arsse\Test\AbstractTest{
|
||||||
$this->markTestSkipped(static::$failureReason);
|
$this->markTestSkipped(static::$failureReason);
|
||||||
}
|
}
|
||||||
Arsse::$db = new Database(static::$drv);
|
Arsse::$db = new Database(static::$drv);
|
||||||
|
Arsse::$db->driverSchemaUpdate();
|
||||||
// create a mock user manager
|
// create a mock user manager
|
||||||
Arsse::$user = Phake::mock(User::class);
|
Arsse::$user = Phake::mock(User::class);
|
||||||
Phake::when(Arsse::$user)->authorize->thenReturn(true);
|
Phake::when(Arsse::$user)->authorize->thenReturn(true);
|
||||||
|
@ -115,7 +116,10 @@ abstract class Base extends \JKingWeb\Arsse\Test\AbstractTest{
|
||||||
$drv = static::$drv;
|
$drv = static::$drv;
|
||||||
$tr = $drv->begin();
|
$tr = $drv->begin();
|
||||||
foreach ($data as $table => $info) {
|
foreach ($data as $table => $info) {
|
||||||
$cols = implode(",", array_keys($info['columns']));
|
$cols = array_map(function($v) {
|
||||||
|
return '"'.str_replace('"', '""', $v).'"';
|
||||||
|
}, array_keys($info['columns']));
|
||||||
|
$cols = implode(",", $cols);
|
||||||
$bindings = array_values($info['columns']);
|
$bindings = array_values($info['columns']);
|
||||||
$params = implode(",", array_fill(0, sizeof($info['columns']), "?"));
|
$params = implode(",", array_fill(0, sizeof($info['columns']), "?"));
|
||||||
$s = $drv->prepareArray("INSERT INTO $table($cols) values($params)", $bindings);
|
$s = $drv->prepareArray("INSERT INTO $table($cols) values($params)", $bindings);
|
||||||
|
|
|
@ -27,11 +27,11 @@ trait SeriesMiscellany {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInitializeDatabase() {
|
public function testInitializeDatabase() {
|
||||||
$d = new Database();
|
$this->assertSame(Database::SCHEMA_VERSION, Arsse::$db->driverSchemaVersion());
|
||||||
$this->assertSame(Database::SCHEMA_VERSION, $d->driverSchemaVersion());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testManuallyInitializeDatabase() {
|
public function testManuallyInitializeDatabase() {
|
||||||
|
(static::$dbInfo->razeFunction)(static::$drv);
|
||||||
$d = new Database(false);
|
$d = new Database(false);
|
||||||
$this->assertSame(0, $d->driverSchemaVersion());
|
$this->assertSame(0, $d->driverSchemaVersion());
|
||||||
$this->assertTrue($d->driverSchemaUpdate());
|
$this->assertTrue($d->driverSchemaUpdate());
|
||||||
|
@ -40,7 +40,6 @@ trait SeriesMiscellany {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCheckCharacterSetAcceptability() {
|
public function testCheckCharacterSetAcceptability() {
|
||||||
$d = new Database();
|
$this->assertInternalType("bool", Arsse::$db->driverCharsetAcceptable());
|
||||||
$this->assertInternalType("bool", $d->driverCharsetAcceptable());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue