mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-31 21:12:41 +00:00
Actually-last tests for schema upgrade
This commit is contained in:
parent
95d20f33c7
commit
15a2e7fe0f
5 changed files with 64 additions and 18 deletions
|
@ -93,7 +93,13 @@ alter table arsse_articles drop column content;
|
|||
alter table arsse_articles drop column content_scraped;
|
||||
|
||||
-- Create one edition for each renumbered article
|
||||
insert into arsse_editions(article) select id from arsse_articles_map where id <> article;
|
||||
insert into arsse_editions(article, modified)
|
||||
select
|
||||
m.id, e.modified
|
||||
from arsse_editions as e
|
||||
join arsse_articles_map as m using(article)
|
||||
where m.id <> article
|
||||
order by m.id, modified;
|
||||
|
||||
-- Create enclures for renumbered articles
|
||||
insert into arsse_enclosures(article, url, type)
|
||||
|
|
|
@ -68,6 +68,8 @@ insert into arsse_articles(id,feed,subscription,read,starred,hidden,published,ed
|
|||
on conflict (id) do update set (subscription,read,starred,hidden,marked,note) = (
|
||||
select subscription, read, starred, hidden, marked, note from new_data where id = excluded.id
|
||||
);
|
||||
-- set the sequence number appropriately
|
||||
select setval('arsse_articles_id_seq', (select max(id) from arsse_articles));
|
||||
|
||||
-- Next create the subsidiary table to hold article contents
|
||||
create table arsse_article_contents(
|
||||
|
@ -88,7 +90,13 @@ alter table arsse_articles drop column content_scraped;
|
|||
alter table arsse_articles drop column content;
|
||||
|
||||
-- Create one edition for each renumbered article
|
||||
insert into arsse_editions(article) select id from arsse_articles_map where id <> article;
|
||||
insert into arsse_editions(article, modified)
|
||||
select
|
||||
m.id, e.modified
|
||||
from arsse_editions as e
|
||||
join arsse_articles_map as m using(article)
|
||||
where m.id <> article
|
||||
order by m.id, modified;
|
||||
|
||||
-- Create enclures for renumbered articles
|
||||
insert into arsse_enclosures(article, url, type)
|
||||
|
|
|
@ -88,8 +88,14 @@ insert into arsse_article_contents
|
|||
left join arsse_subscriptions as s on s.id = m.subscription;
|
||||
|
||||
-- Create one edition for each renumbered article, and delete any editions for obsolete articles
|
||||
insert into arsse_editions(article) select id from arsse_articles_map where id <> article;
|
||||
delete from arsse_editions where article in (select article from arsse_articles_map where id <> article);
|
||||
insert into arsse_editions(article, modified)
|
||||
select
|
||||
m.id, e.modified
|
||||
from arsse_editions as e
|
||||
join arsse_articles_map as m using(article)
|
||||
where m.id <> article
|
||||
order by m.id, modified;
|
||||
delete from arsse_editions where article in (select article from arsse_articles_map where id <> article) or article not in (select id from arsse_articles_map);
|
||||
|
||||
-- Create enclures for renumbered articles and delete obsolete enclosures
|
||||
insert into arsse_enclosures(article, url, type)
|
||||
|
|
|
@ -238,6 +238,19 @@ QUERY_TEXT
|
|||
(5, 4, 1, 0, '2002-11-12 00:37:22', 'Note 5', 0),
|
||||
(5, 6, 0, 1, '2002-12-12 00:37:22', '', 0),
|
||||
(6, 6, 0, 0, '2002-12-13 00:37:22', 'Note 6', 1);
|
||||
insert into arsse_editions(article, modified) values
|
||||
(1, '2000-01-01 00:00:00'),
|
||||
(1, '2000-02-01 00:00:00'),
|
||||
(2, '2000-01-02 00:00:00'),
|
||||
(2, '2000-02-02 00:00:00'),
|
||||
(3, '2000-01-03 00:00:00'),
|
||||
(3, '2000-02-03 00:00:00'),
|
||||
(4, '2000-01-04 00:00:00'),
|
||||
(4, '2000-02-04 00:00:00'),
|
||||
(5, '2000-01-05 00:00:00'),
|
||||
(5, '2000-02-05 00:00:00'),
|
||||
(6, '2000-01-06 00:00:00'),
|
||||
(6, '2000-02-06 00:00:00');
|
||||
insert into arsse_enclosures(article, url, type) values
|
||||
(2, 'http://example.com/2/enclosure', 'image/png'),
|
||||
(3, 'http://example.org/3/enclosure', 'image/jpg'),
|
||||
|
@ -303,6 +316,23 @@ QUERY_TEXT
|
|||
[10, "Scraped 6"],
|
||||
]
|
||||
],
|
||||
'arsse_editions' => [
|
||||
'columns' => ["id", "article", "modified"],
|
||||
'rows' => [
|
||||
[1, 1, "2000-01-01 00:00:00"],
|
||||
[2, 1, "2000-02-01 00:00:00"],
|
||||
[3, 2, "2000-01-02 00:00:00"],
|
||||
[4, 2, "2000-02-02 00:00:00"],
|
||||
[13, 7, "2000-01-05 00:00:00"],
|
||||
[14, 7, "2000-02-05 00:00:00"],
|
||||
[15, 8, "2000-01-05 00:00:00"],
|
||||
[16, 8, "2000-02-05 00:00:00"],
|
||||
[17, 9, "2000-01-06 00:00:00"],
|
||||
[18, 9, "2000-02-06 00:00:00"],
|
||||
[19, 10, "2000-01-06 00:00:00"],
|
||||
[20, 10, "2000-02-06 00:00:00"],
|
||||
]
|
||||
],
|
||||
'arsse_enclosures' => [
|
||||
'columns' => ["article", "url", "type"],
|
||||
'rows' => [
|
||||
|
|
|
@ -72,19 +72,26 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
|||
],
|
||||
'arsse_articles' => [
|
||||
'id' => "int",
|
||||
'feed' => "int",
|
||||
'subscription' => "int",
|
||||
'read' => "bool",
|
||||
'starred' => "bool",
|
||||
'hidden' => "bool",
|
||||
'url' => "str",
|
||||
'title' => "str",
|
||||
'author' => "str",
|
||||
'published' => "datetime",
|
||||
'edited' => "datetime",
|
||||
'modified' => "datetime",
|
||||
'marked' => "datetime",
|
||||
'guid' => "str",
|
||||
'url_title_hash' => "str",
|
||||
'url_content_hash' => "str",
|
||||
'title_content_hash' => "str",
|
||||
'content_scraped' => "str",
|
||||
'content' => "str",
|
||||
'note' => "str",
|
||||
],
|
||||
'arsse_article_contents' => [
|
||||
'id' => "int",
|
||||
'content' => "str",
|
||||
],
|
||||
'arsse_editions' => [
|
||||
'id' => "int",
|
||||
|
@ -100,16 +107,6 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
|||
'article' => "int",
|
||||
'name' => "str",
|
||||
],
|
||||
'arsse_marks' => [
|
||||
'article' => "int",
|
||||
'subscription' => "int",
|
||||
'read' => "bool",
|
||||
'starred' => "bool",
|
||||
'modified' => "datetime",
|
||||
'note' => "str",
|
||||
'touched' => "bool",
|
||||
'hidden' => "bool",
|
||||
],
|
||||
'arsse_subscriptions' => [
|
||||
'id' => "int",
|
||||
'owner' => "str",
|
||||
|
@ -162,7 +159,6 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
|||
'arsse_label_members' => [
|
||||
'label' => "int",
|
||||
'article' => "int",
|
||||
'subscription' => "int",
|
||||
'assigned' => "bool",
|
||||
'modified' => "datetime",
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue