You can now add feeds to the database
This commit is contained in:
parent
1fa8351d11
commit
a5b6352a4c
24 changed files with 1049 additions and 20 deletions
53
sql/queries/feeds.sql
Normal file
53
sql/queries/feeds.sql
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
-- name: CreateFeed :one
|
||||
INSERT INTO
|
||||
feeds (
|
||||
"url",
|
||||
created_at,
|
||||
updated_at,
|
||||
deleted_at,
|
||||
title,
|
||||
"description",
|
||||
link,
|
||||
feed_link,
|
||||
links,
|
||||
updated,
|
||||
updated_parsed,
|
||||
published,
|
||||
published_parsed,
|
||||
"language",
|
||||
copyright,
|
||||
generator,
|
||||
categories,
|
||||
custom,
|
||||
feed_type,
|
||||
feed_version
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9,
|
||||
$10,
|
||||
$11,
|
||||
$12,
|
||||
$13,
|
||||
$14,
|
||||
$15,
|
||||
$16,
|
||||
$17,
|
||||
$18,
|
||||
$19,
|
||||
$20
|
||||
) RETURNING *;
|
||||
|
||||
-- name: CountFeeds :one
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
feeds;
|
||||
73
sql/schema/20240214043229_feeds.sql
Normal file
73
sql/schema/20240214043229_feeds.sql
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- Create table feeds if not exists
|
||||
CREATE TABLE IF NOT EXISTS feeds (
|
||||
id SERIAL PRIMARY KEY,
|
||||
"url" TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed: https://github.com/mmcdole/gofeed/blob/master/feed.go
|
||||
title TEXT,
|
||||
"description" TEXT,
|
||||
link TEXT,
|
||||
feed_link TEXT,
|
||||
links TEXT [],
|
||||
updated TEXT,
|
||||
updated_parsed TIMESTAMP,
|
||||
published TEXT,
|
||||
published_parsed TIMESTAMP,
|
||||
-- Authors - See feed_authors
|
||||
"language" TEXT,
|
||||
-- Image - See feed_images
|
||||
copyright TEXT,
|
||||
generator TEXT,
|
||||
categories TEXT [],
|
||||
-- Dublin Core - See feed_dublin_cores
|
||||
-- Itunes - See feed_itunes
|
||||
-- Extensions - See feed_extensions
|
||||
custom JSONB,
|
||||
-- Items - See items
|
||||
feed_type TEXT,
|
||||
feed_version TEXT
|
||||
);
|
||||
|
||||
-- Feed item
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/feed.go#L49
|
||||
CREATE TABLE IF NOT EXISTS items (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
title TEXT,
|
||||
"description" TEXT,
|
||||
content TEXT,
|
||||
link TEXT,
|
||||
links TEXT [],
|
||||
updated TEXT,
|
||||
updated_parsed TIMESTAMP,
|
||||
published TEXT,
|
||||
published_parsed TIMESTAMP,
|
||||
-- Authors - See item_authors
|
||||
"guid" TEXT,
|
||||
-- Image - See item_images
|
||||
categories TEXT [],
|
||||
-- Enclosures - See enclosures
|
||||
-- Dublin Core - See item_dublin_cores
|
||||
-- Itunes - See item_itunes
|
||||
-- Extensions - See item_extensions
|
||||
custom JSONB,
|
||||
-- Link to feed
|
||||
feed_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_feed_id FOREIGN KEY (feed_id) REFERENCES feeds (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS feeds;
|
||||
|
||||
DROP TABLE IF EXISTS items;
|
||||
|
||||
-- +goose StatementEnd
|
||||
44
sql/schema/20240215232236_extensions.sql
Normal file
44
sql/schema/20240215232236_extensions.sql
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- Extensions for feeds
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/extensions.go#L3
|
||||
CREATE TABLE IF NOT EXISTS feed_extensions (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"name" TEXT,
|
||||
"value" TEXT,
|
||||
attrs JSONB,
|
||||
children JSONB,
|
||||
-- Link to feed
|
||||
feed_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_feed_id FOREIGN KEY (feed_id) REFERENCES feeds (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Extensions for items
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/extensions.go#L3
|
||||
CREATE TABLE IF NOT EXISTS item_extensions (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"name" TEXT,
|
||||
"value" TEXT,
|
||||
attrs JSONB,
|
||||
children JSONB,
|
||||
-- Link to feed item (Also called feed entry)
|
||||
item_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_item_id FOREIGN KEY (item_id) REFERENCES items (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS feed_extensions;
|
||||
|
||||
DROP TABLE IF EXISTS item_extensions;
|
||||
|
||||
-- +goose StatementEnd
|
||||
42
sql/schema/20240215232245_authors.sql
Normal file
42
sql/schema/20240215232245_authors.sql
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- Person for feeds
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/feed.go#L73
|
||||
CREATE TABLE IF NOT EXISTS feed_authors (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"name" TEXT,
|
||||
email TEXT,
|
||||
uri TEXT,
|
||||
-- Link to feed
|
||||
feed_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_feed_id FOREIGN KEY (feed_id) REFERENCES feeds (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Person for items
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/feed.go#L73
|
||||
CREATE TABLE IF NOT EXISTS item_authors (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"name" TEXT,
|
||||
email TEXT,
|
||||
uri TEXT,
|
||||
-- Link to feed item (Also called feed entry)
|
||||
item_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_item_id FOREIGN KEY (item_id) REFERENCES items (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS feed_authors;
|
||||
|
||||
DROP TABLE IF EXISTS item_authors;
|
||||
|
||||
-- +goose StatementEnd
|
||||
40
sql/schema/20240215232251_images.sql
Normal file
40
sql/schema/20240215232251_images.sql
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- Image for feeds
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/feed.go#L80
|
||||
CREATE TABLE IF NOT EXISTS feed_images (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"url" TEXT,
|
||||
title TEXT,
|
||||
-- Link to feed
|
||||
feed_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_feed_id FOREIGN KEY (feed_id) REFERENCES feeds (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Image for items
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/feed.go#L80
|
||||
CREATE TABLE IF NOT EXISTS item_images (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"url" TEXT,
|
||||
title TEXT,
|
||||
-- Link to feed item (Also called feed entry)
|
||||
item_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_item_id FOREIGN KEY (item_id) REFERENCES items (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS feed_images;
|
||||
|
||||
DROP TABLE IF EXISTS item_images;
|
||||
|
||||
-- +goose StatementEnd
|
||||
68
sql/schema/20240215232259_dublin_cores.sql
Normal file
68
sql/schema/20240215232259_dublin_cores.sql
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- Dublin Core for feeds
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/dublincore.go#L5
|
||||
CREATE TABLE IF NOT EXISTS feed_dublin_cores (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
title TEXT [],
|
||||
creator TEXT [],
|
||||
author TEXT [],
|
||||
"subject" TEXT [],
|
||||
"description" TEXT [],
|
||||
publisher TEXT [],
|
||||
contributor TEXT [],
|
||||
"date" TEXT [],
|
||||
"type" TEXT [],
|
||||
format TEXT [],
|
||||
identifier TEXT [],
|
||||
source TEXT [],
|
||||
"language" TEXT [],
|
||||
relation TEXT [],
|
||||
coverage TEXT [],
|
||||
rights TEXT [],
|
||||
-- Link to feed
|
||||
feed_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_feed_id FOREIGN KEY (feed_id) REFERENCES feeds (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Dublin Core for items
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/dublincore.go#L5
|
||||
CREATE TABLE IF NOT EXISTS item_dublin_cores (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
title TEXT [],
|
||||
creator TEXT [],
|
||||
author TEXT [],
|
||||
"subject" TEXT [],
|
||||
"description" TEXT [],
|
||||
publisher TEXT [],
|
||||
contributor TEXT [],
|
||||
"date" TEXT [],
|
||||
"type" TEXT [],
|
||||
format TEXT [],
|
||||
identifier TEXT [],
|
||||
source TEXT [],
|
||||
"language" TEXT [],
|
||||
relation TEXT [],
|
||||
coverage TEXT [],
|
||||
rights TEXT [],
|
||||
-- Link to feed item (Also called feed entry)
|
||||
item_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_item_id FOREIGN KEY (item_id) REFERENCES items (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS feed_dublin_cores;
|
||||
|
||||
DROP TABLE IF EXISTS item_dublin_cores;
|
||||
|
||||
-- +goose StatementEnd
|
||||
94
sql/schema/20240215232318_itunes.sql
Normal file
94
sql/schema/20240215232318_itunes.sql
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- Itunes for feeds
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/itunes.go#L5
|
||||
CREATE TABLE IF NOT EXISTS feed_itunes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
author TEXT,
|
||||
"block" TEXT,
|
||||
"explicit" TEXT,
|
||||
keywords TEXT,
|
||||
-- Owner
|
||||
subtitle TEXT,
|
||||
summary TEXT,
|
||||
"image" TEXT,
|
||||
complete TEXT,
|
||||
new_feed_url TEXT,
|
||||
"type" TEXT,
|
||||
-- Link to feed
|
||||
feed_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_feed_id FOREIGN KEY (feed_id) REFERENCES feeds (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Itunes for items
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/itunes.go#L22
|
||||
CREATE TABLE IF NOT EXISTS item_itunes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
author TEXT,
|
||||
"block" TEXT,
|
||||
duration TEXT,
|
||||
"explicit" TEXT,
|
||||
keywords TEXT,
|
||||
subtitle TEXT,
|
||||
summary TEXT,
|
||||
"image" TEXT,
|
||||
is_closed_captioned TEXT,
|
||||
episode TEXT,
|
||||
season TEXT,
|
||||
"order" TEXT,
|
||||
episode_type TEXT,
|
||||
-- Link to feed item (Also called feed entry)
|
||||
item_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_item_id FOREIGN KEY (item_id) REFERENCES items (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Itunes categories
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/itunes.go#L39
|
||||
CREATE TABLE IF NOT EXISTS itunes_categories (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"text" TEXT,
|
||||
subcategory TEXT,
|
||||
-- Link to itunes
|
||||
itunes_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_itunes_id FOREIGN KEY (itunes_id) REFERENCES feed_itunes (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- Itunes owners
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/extensions/itunes.go#L45
|
||||
CREATE TABLE IF NOT EXISTS itunes_owners (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
email TEXT,
|
||||
"name" TEXT,
|
||||
-- Link to itunes
|
||||
itunes_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_itunes_id FOREIGN KEY (itunes_id) REFERENCES feed_itunes (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS feed_itunes;
|
||||
|
||||
DROP TABLE IF EXISTS item_itunes;
|
||||
|
||||
DROP TABLE IF EXISTS itunes_categories;
|
||||
|
||||
DROP TABLE IF EXISTS itunes_owners;
|
||||
|
||||
-- +goose StatementEnd
|
||||
24
sql/schema/20240215232334_enclousures.sql
Normal file
24
sql/schema/20240215232334_enclousures.sql
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
-- Enclosures
|
||||
-- https://github.com/mmcdole/gofeed/blob/master/feed.go#L86
|
||||
CREATE TABLE IF NOT EXISTS enclosures (
|
||||
id SERIAL PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP DEFAULT NULL,
|
||||
-- From gofeed:
|
||||
"url" TEXT,
|
||||
"length" TEXT,
|
||||
"type" TEXT,
|
||||
-- Link to feed item (Also called feed entry)
|
||||
item_id INTEGER NOT NULL,
|
||||
CONSTRAINT fk_item_id FOREIGN KEY (item_id) REFERENCES items (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS enclosures;
|
||||
|
||||
-- +goose StatementEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue