From 2c9daedb14d05f21171c291e688446f991f6a741 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 30 Sep 2022 12:32:28 -0400 Subject: [PATCH] Add provision for soft deletion of subscriptions --- sql/MySQL/7.sql | 1 + sql/PostgreSQL/7.sql | 1 + sql/SQLite3/7.sql | 6 ++++-- tests/cases/Db/BaseUpdate.php | 8 ++++---- tests/lib/AbstractTest.php | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sql/MySQL/7.sql b/sql/MySQL/7.sql index 27a6b840..442b43c7 100644 --- a/sql/MySQL/7.sql +++ b/sql/MySQL/7.sql @@ -149,6 +149,7 @@ alter table arsse_subscriptions add column err_count bigint unsigned not null de alter table arsse_subscriptions add column err_msg longtext; alter table arsse_subscriptions add column size bigint unsigned not null default 0; alter table arsse_subscriptions add column icon bigint unsigned; +alter table arsse_subscriptions add column deleted boolean not null default 0; -- Populate the new columns update arsse_subscriptions as s, arsse_feeds as f set diff --git a/sql/PostgreSQL/7.sql b/sql/PostgreSQL/7.sql index e99a9ba4..67cc2f57 100644 --- a/sql/PostgreSQL/7.sql +++ b/sql/PostgreSQL/7.sql @@ -143,6 +143,7 @@ alter table arsse_subscriptions add column err_count bigint not null default 0; alter table arsse_subscriptions add column err_msg text collate "und-x-icu"; alter table arsse_subscriptions add column size bigint not null default 0; alter table arsse_subscriptions add column icon bigint references arsse_icons(id) on delete set null; +alter table arsse_subscriptions add column deleted smallint not null default 0; -- Populate the new columns update arsse_subscriptions as s set diff --git a/sql/SQLite3/7.sql b/sql/SQLite3/7.sql index fb0d027d..4e3e2573 100644 --- a/sql/SQLite3/7.sql +++ b/sql/SQLite3/7.sql @@ -136,9 +136,11 @@ create table arsse_subscriptions_new( id integer primary key, -- sequence number owner text not null references arsse_users(id) on delete cascade on update cascade, -- owner of subscription url text not null, -- URL of feed + deleted int not null default 0, -- soft-delete flag feed_title text collate nocase, -- feed title title text collate nocase, -- user-supplied title, which overrides the feed title when set folder integer references arsse_folders(id) on delete cascade, -- TT-RSS category (nestable); the first-level category (which acts as Nextcloud folder) is joined in when needed + modified text not null default CURRENT_TIMESTAMP, -- time at which subscription properties were last modified by the user last_mod text, -- time at which the feed last actually changed at the foreign host etag text not null default '', -- HTTP ETag hash used for cache validation, changes each time the content changes next_fetch text, -- time at which the feed should next be fetched @@ -149,7 +151,6 @@ create table arsse_subscriptions_new( err_msg text, -- last error message size integer not null default 0, -- number of articles in the feed at last fetch icon integer references arsse_icons(id) on delete set null, -- numeric identifier of any associated icon - modified text not null default CURRENT_TIMESTAMP, -- time at which subscription properties were last modified by the user order_type int not null default 0, -- Nextcloud sort order pinned int not null default 0, -- whether feed is pinned (always sorts at top) scrape int not null default 0, -- whether the user has requested scraping content from source articles @@ -162,9 +163,11 @@ insert into arsse_subscriptions_new s.id, s.owner, f.url, + 0, f.title, s.title, s.folder, + s.modified, f.modified, f.etag, f.next_fetch, @@ -175,7 +178,6 @@ insert into arsse_subscriptions_new f.err_msg, f.size, f.icon, - s.modified, s.order_type, s.pinned, s.scrape, diff --git a/tests/cases/Db/BaseUpdate.php b/tests/cases/Db/BaseUpdate.php index a75099a6..96b6a718 100644 --- a/tests/cases/Db/BaseUpdate.php +++ b/tests/cases/Db/BaseUpdate.php @@ -287,11 +287,11 @@ QUERY_TEXT ] ], 'arsse_subscriptions' => [ - 'columns' => ["id", "owner", "url", "feed_title", "title", "folder", "last_mod", "etag", "next_fetch", "added", "source", "updated", "err_count", "err_msg", "size", "icon", "modified", "order_type", "pinned", "scrape", "keep_rule", "block_rule"], + 'columns' => ["id", "owner", "url", "feed_title", "title", "folder", "last_mod", "etag", "next_fetch", "added", "source", "updated", "err_count", "err_msg", "size", "icon", "modified", "order_type", "pinned", "scrape", "keep_rule", "block_rule", "deleted"], 'rows' => [ - [1, "a", "https://example.com/rss", "Title 1", "User Title", null, "2001-06-13 06:56:23", '"ook"', "2001-06-13 06:57:23", "2002-02-02 00:02:03", "https://example.com/", "2001-06-13 06:55:23", 42, "Some error", 47, null, "2002-02-02 00:05:03", 2, 1, 0, "keep", "block"], - [4, "a", "https://example.net/rss", "Title 3", "Rosy Title", 1337, "2001-06-15 06:56:23", '"ack"', "2001-06-15 06:57:23", "2002-02-03 00:02:03", "https://example.net/", "2001-06-15 06:55:23", 44, "This error", 3, 12, "2002-02-03 00:05:03", 1, 0, 0, "meep", "bloop"], - [6, "c", "https://example.net/rss", "Title 3", null, 4400, "2001-06-15 06:56:23", '"ack"', "2001-06-15 06:57:23", "2002-02-04 00:02:03", "https://example.net/", "2001-06-15 06:55:23", 44, "This error", 3, 12, "2002-02-04 00:05:03", 2, 0, 1, null, null], + [1, "a", "https://example.com/rss", "Title 1", "User Title", null, "2001-06-13 06:56:23", '"ook"', "2001-06-13 06:57:23", "2002-02-02 00:02:03", "https://example.com/", "2001-06-13 06:55:23", 42, "Some error", 47, null, "2002-02-02 00:05:03", 2, 1, 0, "keep", "block", 0], + [4, "a", "https://example.net/rss", "Title 3", "Rosy Title", 1337, "2001-06-15 06:56:23", '"ack"', "2001-06-15 06:57:23", "2002-02-03 00:02:03", "https://example.net/", "2001-06-15 06:55:23", 44, "This error", 3, 12, "2002-02-03 00:05:03", 1, 0, 0, "meep", "bloop", 0], + [6, "c", "https://example.net/rss", "Title 3", null, 4400, "2001-06-15 06:56:23", '"ack"', "2001-06-15 06:57:23", "2002-02-04 00:02:03", "https://example.net/", "2001-06-15 06:55:23", 44, "This error", 3, 12, "2002-02-04 00:05:03", 2, 0, 1, null, null, 0], ] ], 'arsse_articles' => [ diff --git a/tests/lib/AbstractTest.php b/tests/lib/AbstractTest.php index 0fb49a2d..0e3ab3a8 100644 --- a/tests/lib/AbstractTest.php +++ b/tests/lib/AbstractTest.php @@ -130,6 +130,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase { 'scrape' => "bool", 'keep_rule' => "str", 'block_rule' => "str", + 'deleted' => "bool", ], 'arsse_folders' => [ 'id' => "int",