Invidious is an alternative front-end to YouTube
Make migrations (mostly) idempotent.
Andre Borieffa9e5dfab7a
diff --git a/config/sql/annotations.sql b/config/sql/annotations.sqlindex 4ea077e7..3705829d 100644--- a/config/sql/annotations.sql+++ b/config/sql/annotations.sql@@ -2,11 +2,11 @@-- DROP TABLE public.annotations;-CREATE TABLE public.annotations+CREATE TABLE IF NOT EXISTS public.annotations(id text NOT NULL,annotations xml,CONSTRAINT annotations_id_key UNIQUE (id));-GRANT ALL ON TABLE public.annotations TO kemal;+GRANT ALL ON TABLE public.annotations TO current_user;diff --git a/config/sql/channel_videos.sql b/config/sql/channel_videos.sqlindex cec57cd4..cd4e0ffd 100644--- a/config/sql/channel_videos.sql+++ b/config/sql/channel_videos.sql@@ -2,7 +2,7 @@-- DROP TABLE public.channel_videos;-CREATE TABLE public.channel_videos+CREATE TABLE IF NOT EXISTS public.channel_videos(id text NOT NULL,title text,@@ -17,13 +17,13 @@ CREATE TABLE public.channel_videosCONSTRAINT channel_videos_id_key UNIQUE (id));-GRANT ALL ON TABLE public.channel_videos TO kemal;+GRANT ALL ON TABLE public.channel_videos TO current_user;-- Index: public.channel_videos_ucid_idx-- DROP INDEX public.channel_videos_ucid_idx;-CREATE INDEX channel_videos_ucid_idx+CREATE INDEX IF NOT EXISTS channel_videos_ucid_idxON public.channel_videosUSING btree(ucid COLLATE pg_catalog."default");diff --git a/config/sql/channels.sql b/config/sql/channels.sqlindex b5a29b8f..55772da6 100644--- a/config/sql/channels.sql+++ b/config/sql/channels.sql@@ -2,7 +2,7 @@-- DROP TABLE public.channels;-CREATE TABLE public.channels+CREATE TABLE IF NOT EXISTS public.channels(id text NOT NULL,author text,@@ -12,13 +12,13 @@ CREATE TABLE public.channelsCONSTRAINT channels_id_key UNIQUE (id));-GRANT ALL ON TABLE public.channels TO kemal;+GRANT ALL ON TABLE public.channels TO current_user;-- Index: public.channels_id_idx-- DROP INDEX public.channels_id_idx;-CREATE INDEX channels_id_idx+CREATE INDEX IF NOT EXISTS channels_id_idxON public.channelsUSING btree(id COLLATE pg_catalog."default");diff --git a/config/sql/nonces.sql b/config/sql/nonces.sqlindex 7b8ce9f2..644ac32a 100644--- a/config/sql/nonces.sql+++ b/config/sql/nonces.sql@@ -2,20 +2,20 @@-- DROP TABLE public.nonces;-CREATE TABLE public.nonces+CREATE TABLE IF NOT EXISTS public.nonces(nonce text,expire timestamp with time zone,CONSTRAINT nonces_id_key UNIQUE (nonce));-GRANT ALL ON TABLE public.nonces TO kemal;+GRANT ALL ON TABLE public.nonces TO current_user;-- Index: public.nonces_nonce_idx-- DROP INDEX public.nonces_nonce_idx;-CREATE INDEX nonces_nonce_idx+CREATE INDEX IF NOT EXISTS nonces_nonce_idxON public.noncesUSING btree(nonce COLLATE pg_catalog."default");diff --git a/config/sql/playlist_videos.sql b/config/sql/playlist_videos.sqlindex b2b8d5c4..eedccbad 100644--- a/config/sql/playlist_videos.sql+++ b/config/sql/playlist_videos.sql@@ -2,7 +2,7 @@-- DROP TABLE public.playlist_videos;-CREATE TABLE playlist_videos+CREATE TABLE IF NOT EXISTS playlist_videos(title text,id text,@@ -16,4 +16,4 @@ CREATE TABLE playlist_videosPRIMARY KEY (index,plid));-GRANT ALL ON TABLE public.playlist_videos TO kemal;+GRANT ALL ON TABLE public.playlist_videos TO current_user;diff --git a/config/sql/playlists.sql b/config/sql/playlists.sqlindex 468496cb..83efce48 100644--- a/config/sql/playlists.sql+++ b/config/sql/playlists.sql@@ -13,7 +13,7 @@ CREATE TYPE public.privacy AS ENUM-- DROP TABLE public.playlists;-CREATE TABLE public.playlists+CREATE TABLE IF NOT EXISTS public.playlists(title text,id text primary key,@@ -26,4 +26,4 @@ CREATE TABLE public.playlistsindex int8[]);-GRANT ALL ON public.playlists TO kemal;+GRANT ALL ON public.playlists TO current_user;diff --git a/config/sql/session_ids.sql b/config/sql/session_ids.sqlindex afbabb67..c493769a 100644--- a/config/sql/session_ids.sql+++ b/config/sql/session_ids.sql@@ -2,7 +2,7 @@-- DROP TABLE public.session_ids;-CREATE TABLE public.session_ids+CREATE TABLE IF NOT EXISTS public.session_ids(id text NOT NULL,email text,@@ -10,13 +10,13 @@ CREATE TABLE public.session_idsCONSTRAINT session_ids_pkey PRIMARY KEY (id));-GRANT ALL ON TABLE public.session_ids TO kemal;+GRANT ALL ON TABLE public.session_ids TO current_user;-- Index: public.session_ids_id_idx-- DROP INDEX public.session_ids_id_idx;-CREATE INDEX session_ids_id_idx+CREATE INDEX IF NOT EXISTS session_ids_id_idxON public.session_idsUSING btree(id COLLATE pg_catalog."default");diff --git a/config/sql/users.sql b/config/sql/users.sqlindex 0f2cdba2..ad002ec2 100644--- a/config/sql/users.sql+++ b/config/sql/users.sql@@ -2,7 +2,7 @@-- DROP TABLE public.users;-CREATE TABLE public.users+CREATE TABLE IF NOT EXISTS public.users(updated timestamp with time zone,notifications text[],@@ -16,13 +16,13 @@ CREATE TABLE public.usersCONSTRAINT users_email_key UNIQUE (email));-GRANT ALL ON TABLE public.users TO kemal;+GRANT ALL ON TABLE public.users TO current_user;-- Index: public.email_unique_idx-- DROP INDEX public.email_unique_idx;-CREATE UNIQUE INDEX email_unique_idx+CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idxON public.usersUSING btree(lower(email) COLLATE pg_catalog."default");diff --git a/config/sql/videos.sql b/config/sql/videos.sqlindex 8def2f83..7040703c 100644--- a/config/sql/videos.sql+++ b/config/sql/videos.sql@@ -2,7 +2,7 @@-- DROP TABLE public.videos;-CREATE TABLE public.videos+CREATE TABLE IF NOT EXISTS public.videos(id text NOT NULL,info text,@@ -10,13 +10,13 @@ CREATE TABLE public.videosCONSTRAINT videos_pkey PRIMARY KEY (id));-GRANT ALL ON TABLE public.videos TO kemal;+GRANT ALL ON TABLE public.videos TO current_user;-- Index: public.id_idx-- DROP INDEX public.id_idx;-CREATE UNIQUE INDEX id_idx+CREATE UNIQUE INDEX IF NOT EXISTS id_idxON public.videosUSING btree(id COLLATE pg_catalog."default");diff --git a/docker/init-invidious-db.sh b/docker/init-invidious-db.shindex 3808e673..cc0e1c3f 100755--- a/docker/init-invidious-db.sh+++ b/docker/init-invidious-db.sh@@ -5,12 +5,12 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-ECREATE USER postgres;EOSQL-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/channels.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/videos.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/channel_videos.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/users.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/session_ids.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/nonces.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/annotations.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlists.sql-psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlist_videos.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/channels.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/videos.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/channel_videos.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/users.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/session_ids.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/nonces.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/annotations.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlists.sql+psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlist_videos.sql