Browse Source

Actually-last tests for schema upgrade

redup
J. King 2 years ago
parent
commit
15a2e7fe0f
  1. 8
      sql/MySQL/7.sql
  2. 10
      sql/PostgreSQL/7.sql
  3. 10
      sql/SQLite3/7.sql
  4. 30
      tests/cases/Db/BaseUpdate.php
  5. 24
      tests/lib/AbstractTest.php

8
sql/MySQL/7.sql

@ -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)

10
sql/PostgreSQL/7.sql

@ -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)

10
sql/SQLite3/7.sql

@ -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)

30
tests/cases/Db/BaseUpdate.php

@ -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' => [

24
tests/lib/AbstractTest.php

@ -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…
Cancel
Save