with '#' will be ignored, and an empty message aborts the commit. On branch main Initial commit Changes to be committed: new file: .DS_Store new file: .env new file: .gitignore new file: ai-worker/Dockerfile new file: ai-worker/requirements.txt new file: ai-worker/worker.py new file: background-worker/Dockerfile new file: background-worker/go.mod new file: background-worker/go.sum new file: background-worker/main.go new file: background-worker/market.go new file: background-worker/rmv.go new file: background-worker/rss.go new file: background-worker/sql_work.go new file: db/Dockerfile new file: db/init.sql new file: docker-compose.yml new file: server-app/dockerfile new file: server-app/go.mod new file: server-app/go.sum new file: server-app/main.go new file: volumes/.DS_Store new file: volumes/db-init/.DS_Store new file: volumes/db-init/data/news_rss_feeds.csv new file: volumes/web/.DS_Store new file: volumes/web/static/css/blog.css new file: volumes/web/static/css/index-lite.css new file: volumes/web/static/css/index.css new file: volumes/web/static/css/mandelbrot.css new file: volumes/web/static/img/minecraft.png new file: volumes/web/static/js/blog.js new file: volumes/web/static/js/index-lite.js new file: volumes/web/static/js/index.js new file: volumes/web/static/js/mandelbrot.js new file: volumes/web/static/media/cantina.mp3 new file: volumes/web/static/media/countdowns.json new file: volumes/web/static/media/gong.mp4 new file: volumes/web/template/blog.html new file: volumes/web/template/index-lite.html new file: volumes/web/template/index.html new file: volumes/web/template/mandelbrot.html
95 lines
2.9 KiB
SQL
95 lines
2.9 KiB
SQL
DO $$
|
|
BEGIN
|
|
RAISE NOTICE 'Init gestartet';
|
|
END $$;
|
|
|
|
CREATE TABLE IF NOT EXISTS jobs (
|
|
id SERIAL PRIMARY KEY,
|
|
type TEXT NOT NULL,
|
|
payload JSONB,
|
|
status TEXT NOT NULL DEFAULT 'queued',
|
|
result JSONB,
|
|
error TEXT,
|
|
created_at TIMESTAMP DEFAULT now(),
|
|
updated_at TIMESTAMP DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS rmv_data (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
trip_index INT NOT NULL,
|
|
leg_index INT NOT NULL,
|
|
linie TEXT,
|
|
abfahrt TEXT,
|
|
ankunft TEXT,
|
|
von TEXT,
|
|
nach TEXT
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS feeds (
|
|
id SERIAL PRIMARY KEY,
|
|
url TEXT NOT NULL,
|
|
access BOOLEAN NOT NULL DEFAULT TRUE,
|
|
last_checked TIMESTAMPTZ,
|
|
created_at TIMESTAMP DEFAULT now()
|
|
);
|
|
|
|
-- Ensure last_checked exists when rerunning against an existing DB
|
|
ALTER TABLE IF EXISTS feeds ADD COLUMN IF NOT EXISTS last_checked TIMESTAMPTZ;
|
|
|
|
CREATE TABLE IF NOT EXISTS articles (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
article_id TEXT NOT NULL,
|
|
feed_id INT NOT NULL REFERENCES feeds(id) ON DELETE CASCADE,
|
|
title TEXT NOT NULL,
|
|
link TEXT NOT NULL,
|
|
summary TEXT,
|
|
image TEXT,
|
|
image_claimed_at TIMESTAMPTZ,
|
|
image_claimed_by TEXT,
|
|
published_at TIMESTAMPTZ,
|
|
created_at TIMESTAMP DEFAULT now(),
|
|
CONSTRAINT articles_feed_link_uniq UNIQUE(feed_id, link),
|
|
CONSTRAINT articles_article_id_uniq UNIQUE(article_id)
|
|
);
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (SELECT 1 FROM pg_attribute WHERE attrelid = 'articles'::regclass AND attname = 'article_id') THEN
|
|
ALTER TABLE articles ADD COLUMN article_id TEXT;
|
|
END IF;
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM pg_attribute WHERE attrelid = 'articles'::regclass AND attname = 'image') THEN
|
|
ALTER TABLE articles ADD COLUMN image TEXT;
|
|
END IF;
|
|
IF NOT EXISTS (SELECT 1 FROM pg_attribute WHERE attrelid = 'articles'::regclass AND attname = 'image_claimed_at') THEN
|
|
ALTER TABLE articles ADD COLUMN image_claimed_at TIMESTAMPTZ;
|
|
END IF;
|
|
IF NOT EXISTS (SELECT 1 FROM pg_attribute WHERE attrelid = 'articles'::regclass AND attname = 'image_claimed_by') THEN
|
|
ALTER TABLE articles ADD COLUMN image_claimed_by TEXT;
|
|
END IF;
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'articles_article_id_uniq') THEN
|
|
ALTER TABLE articles ADD CONSTRAINT articles_article_id_uniq UNIQUE(article_id);
|
|
END IF;
|
|
END $$;
|
|
|
|
CREATE TABLE IF NOT EXISTS market_quotes (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
instrument TEXT NOT NULL,
|
|
bid NUMERIC NOT NULL,
|
|
quoted_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
created_at TIMESTAMP DEFAULT now()
|
|
);
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'market_quotes_instrument_uniq') THEN
|
|
ALTER TABLE market_quotes ADD CONSTRAINT market_quotes_instrument_uniq UNIQUE (instrument);
|
|
END IF;
|
|
END $$;
|
|
|
|
-- Seed feeds from CSV (expects file at /docker-entrypoint-initdb.d/data/news_rss_feeds.csv)
|
|
COPY feeds (url)
|
|
FROM '/docker-entrypoint-initdb.d/data/news_rss_feeds.csv'
|
|
WITH (FORMAT csv, HEADER true);
|