mirror of
https://git.nerdvpn.de/NerdVPN.de/invidious
synced 2026-02-14 22:51:42 +01:00
Improve database init script
This commit is contained in:
@@ -59,3 +59,12 @@ if [ "$interactive" = "true" ]; then
|
|||||||
echo "host invidious invidious 192.42.6.0/24 md5"
|
echo "host invidious invidious 192.42.6.0/24 md5"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
set -eou pipefail
|
||||||
|
|
||||||
|
#
|
||||||
|
# Restore database schema
|
||||||
|
#
|
||||||
|
|
||||||
|
sudo -u postgres psql --username invidious --dbname invidious < sql/schema.sql
|
||||||
|
|||||||
@@ -0,0 +1,328 @@
|
|||||||
|
--
|
||||||
|
-- PostgreSQL database dump
|
||||||
|
--
|
||||||
|
|
||||||
|
-- Dumped from database version 16.9 (Debian 16.9-1.pgdg120+1)
|
||||||
|
-- Dumped by pg_dump version 16.9 (Debian 16.9-1.pgdg120+1)
|
||||||
|
|
||||||
|
SET statement_timeout = 0;
|
||||||
|
SET lock_timeout = 0;
|
||||||
|
SET idle_in_transaction_session_timeout = 0;
|
||||||
|
SET client_encoding = 'UTF8';
|
||||||
|
SET standard_conforming_strings = on;
|
||||||
|
SELECT pg_catalog.set_config('search_path', '', false);
|
||||||
|
SET check_function_bodies = false;
|
||||||
|
SET xmloption = content;
|
||||||
|
SET client_min_messages = warning;
|
||||||
|
SET row_security = off;
|
||||||
|
|
||||||
|
DROP SCHEMA IF EXISTS public;
|
||||||
|
--
|
||||||
|
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SCHEMA public;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER SCHEMA public OWNER TO postgres;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
COMMENT ON SCHEMA public IS 'standard public schema';
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: privacy; Type: TYPE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TYPE public.privacy AS ENUM (
|
||||||
|
'Public',
|
||||||
|
'Unlisted',
|
||||||
|
'Private'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TYPE public.privacy OWNER TO invidious;
|
||||||
|
|
||||||
|
SET default_tablespace = '';
|
||||||
|
|
||||||
|
SET default_table_access_method = heap;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: annotations; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.annotations (
|
||||||
|
id text NOT NULL,
|
||||||
|
annotations xml
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.annotations OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: channel_videos; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.channel_videos (
|
||||||
|
id text NOT NULL,
|
||||||
|
title text,
|
||||||
|
published timestamp with time zone,
|
||||||
|
updated timestamp with time zone,
|
||||||
|
ucid text,
|
||||||
|
author text,
|
||||||
|
length_seconds integer,
|
||||||
|
live_now boolean,
|
||||||
|
premiere_timestamp timestamp with time zone,
|
||||||
|
views bigint
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.channel_videos OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: channels; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.channels (
|
||||||
|
id text NOT NULL,
|
||||||
|
author text,
|
||||||
|
updated timestamp with time zone,
|
||||||
|
deleted boolean,
|
||||||
|
subscribed timestamp with time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.channels OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: nonces; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.nonces (
|
||||||
|
nonce text,
|
||||||
|
expire timestamp with time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.nonces OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: playlist_videos; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.playlist_videos (
|
||||||
|
title text,
|
||||||
|
id text,
|
||||||
|
author text,
|
||||||
|
ucid text,
|
||||||
|
length_seconds integer,
|
||||||
|
published timestamp with time zone,
|
||||||
|
plid text NOT NULL,
|
||||||
|
index bigint NOT NULL,
|
||||||
|
live_now boolean
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.playlist_videos OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: playlists; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.playlists (
|
||||||
|
title text,
|
||||||
|
id text NOT NULL,
|
||||||
|
author text,
|
||||||
|
description text,
|
||||||
|
video_count integer,
|
||||||
|
created timestamp with time zone,
|
||||||
|
updated timestamp with time zone,
|
||||||
|
privacy public.privacy,
|
||||||
|
index bigint[]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.playlists OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: session_ids; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.session_ids (
|
||||||
|
id text NOT NULL,
|
||||||
|
email text,
|
||||||
|
issued timestamp with time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.session_ids OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: users; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.users (
|
||||||
|
updated timestamp with time zone,
|
||||||
|
notifications text[],
|
||||||
|
subscriptions text[],
|
||||||
|
email text NOT NULL,
|
||||||
|
preferences text,
|
||||||
|
password text,
|
||||||
|
token text,
|
||||||
|
watched text[],
|
||||||
|
feed_needs_update boolean
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.users OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: videos; Type: TABLE; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE UNLOGGED TABLE public.videos (
|
||||||
|
id text NOT NULL,
|
||||||
|
info text,
|
||||||
|
updated timestamp with time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.videos OWNER TO invidious;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: annotations annotations_id_key; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.annotations
|
||||||
|
ADD CONSTRAINT annotations_id_key UNIQUE (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: channel_videos channel_videos_id_key; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.channel_videos
|
||||||
|
ADD CONSTRAINT channel_videos_id_key UNIQUE (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: channels channels_id_key; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.channels
|
||||||
|
ADD CONSTRAINT channels_id_key UNIQUE (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: nonces nonces_id_key; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.nonces
|
||||||
|
ADD CONSTRAINT nonces_id_key UNIQUE (nonce);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: playlist_videos playlist_videos_pkey; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.playlist_videos
|
||||||
|
ADD CONSTRAINT playlist_videos_pkey PRIMARY KEY (index, plid);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: playlists playlists_pkey; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.playlists
|
||||||
|
ADD CONSTRAINT playlists_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: session_ids session_ids_pkey; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.session_ids
|
||||||
|
ADD CONSTRAINT session_ids_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.users
|
||||||
|
ADD CONSTRAINT users_email_key UNIQUE (email);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: videos videos_pkey; Type: CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.videos
|
||||||
|
ADD CONSTRAINT videos_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: channel_videos_ucid_published_idx; Type: INDEX; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX channel_videos_ucid_published_idx ON public.channel_videos USING btree (ucid, published);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: channels_id_idx; Type: INDEX; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX channels_id_idx ON public.channels USING btree (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_unique_idx; Type: INDEX; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX email_unique_idx ON public.users USING btree (lower(email));
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: id_idx; Type: INDEX; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX id_idx ON public.videos USING btree (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: nonces_nonce_idx; Type: INDEX; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX nonces_nonce_idx ON public.nonces USING btree (nonce);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: session_ids_id_idx; Type: INDEX; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX session_ids_id_idx ON public.session_ids USING btree (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: playlist_videos playlist_videos_plid_fkey; Type: FK CONSTRAINT; Schema: public; Owner: invidious
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.playlist_videos
|
||||||
|
ADD CONSTRAINT playlist_videos_plid_fkey FOREIGN KEY (plid) REFERENCES public.playlists(id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
REVOKE USAGE ON SCHEMA public FROM PUBLIC;
|
||||||
|
GRANT ALL ON SCHEMA public TO PUBLIC;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- PostgreSQL database dump complete
|
||||||
|
--
|
||||||
|
|
||||||
Reference in New Issue
Block a user