feat(sources): add managed RSS feeds (#41)
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
-- Configuration only: preserve source IDs, settings, credentials and history.
|
||||
DO $migration$
|
||||
BEGIN
|
||||
LOCK TABLE sources IN ACCESS EXCLUSIVE MODE;
|
||||
ALTER TABLE sources DROP CONSTRAINT sources_type_check;
|
||||
ALTER TABLE sources ADD CONSTRAINT sources_type_check
|
||||
CHECK(type IN ('bloomberg','stocktwits','reuters','watcherguru','cnbc_business','investing_com'));
|
||||
ALTER TABLE sources DROP CONSTRAINT sources_source_key_check;
|
||||
ALTER TABLE sources ADD CONSTRAINT sources_source_key_check
|
||||
CHECK(source_key IN ('yahoo_finance','bloomberg','watcher_guru','cnbc_business','investing_com'));
|
||||
INSERT INTO sources(id,name,type,enabled,article_limit,source_key)
|
||||
VALUES(gen_random_uuid(),'Investing.com','investing_com',true,20,'investing_com');
|
||||
CREATE TABLE source_feeds (
|
||||
source_id UUID NOT NULL REFERENCES sources(id),
|
||||
position INTEGER NOT NULL CHECK(position >= 0 AND position < 5),
|
||||
url TEXT NOT NULL CHECK(url IN (
|
||||
'https://feed.quanwenrss.com/feed/bloomberg-latest.xml',
|
||||
'https://feed.quanwenrss.com/feed/bloomberg-economics.xml',
|
||||
'https://feed.quanwenrss.com/feed/bloomberg-technology.xml',
|
||||
'https://feed.quanwenrss.com/feed/bloomberg-politics.xml',
|
||||
'https://feed.quanwenrss.com/feed/bloomberg-technology-ai.xml',
|
||||
'https://feed.quanwenrss.com/feed/investing-news.xml')),
|
||||
PRIMARY KEY(source_id,position), UNIQUE(source_id,url)
|
||||
);
|
||||
INSERT INTO source_feeds(source_id,position,url)
|
||||
SELECT s.id,f.position,f.url FROM sources s CROSS JOIN (VALUES
|
||||
(0,'https://feed.quanwenrss.com/feed/bloomberg-latest.xml'),
|
||||
(1,'https://feed.quanwenrss.com/feed/bloomberg-economics.xml'),
|
||||
(2,'https://feed.quanwenrss.com/feed/bloomberg-technology.xml'),
|
||||
(3,'https://feed.quanwenrss.com/feed/bloomberg-politics.xml'),
|
||||
(4,'https://feed.quanwenrss.com/feed/bloomberg-technology-ai.xml')
|
||||
) AS f(position,url) WHERE s.source_key='bloomberg';
|
||||
INSERT INTO source_feeds(source_id,position,url)
|
||||
SELECT id,0,'https://feed.quanwenrss.com/feed/investing-news.xml' FROM sources WHERE source_key='investing_com';
|
||||
END
|
||||
$migration$;
|
||||
Reference in New Issue
Block a user