Add migrate script and update README

This commit is contained in:
Omar Roth 2019-02-10 12:46:58 -06:00
parent 3646395f1d
commit a384f6e5fd
4 changed files with 8 additions and 1 deletions

View File

@ -98,6 +98,7 @@ $ psql invidious < /home/invidious/invidious/config/sql/channels.sql
$ psql invidious < /home/invidious/invidious/config/sql/videos.sql $ psql invidious < /home/invidious/invidious/config/sql/videos.sql
$ psql invidious < /home/invidious/invidious/config/sql/channel_videos.sql $ psql invidious < /home/invidious/invidious/config/sql/channel_videos.sql
$ psql invidious < /home/invidious/invidious/config/sql/users.sql $ psql invidious < /home/invidious/invidious/config/sql/users.sql
$ psql invidious < /home/invidious/invidious/config/sql/session_ids.sql
$ psql invidious < /home/invidious/invidious/config/sql/nonces.sql $ psql invidious < /home/invidious/invidious/config/sql/nonces.sql
$ exit $ exit
``` ```
@ -138,6 +139,7 @@ $ psql invidious < config/sql/channels.sql
$ psql invidious < config/sql/videos.sql $ psql invidious < config/sql/videos.sql
$ psql invidious < config/sql/channel_videos.sql $ psql invidious < config/sql/channel_videos.sql
$ psql invidious < config/sql/users.sql $ psql invidious < config/sql/users.sql
$ psql invidious < config/sql/session_ids.sql
$ psql invidious < config/sql/nonces.sql $ psql invidious < config/sql/nonces.sql
# Setup Invidious # Setup Invidious

View File

@ -0,0 +1,5 @@
#!/bin/sh
psql invidious < config/sql/session_ids.sql
psql invidious -c "INSERT INTO session_ids (SELECT unnest(id), email, CURRENT_TIMESTAMP FROM users) ON CONFLICT (id) DO NOTHING"
psql invidious -c "ALTER TABLE users DROP COLUMN id"

View File

@ -21,4 +21,3 @@ CREATE INDEX session_ids_id_idx
USING btree USING btree
(id COLLATE pg_catalog."default"); (id COLLATE pg_catalog."default");

View File

@ -16,6 +16,7 @@ if [ ! -f /var/lib/postgresql/data/setupFinished ]; then
su postgres -c 'psql invidious < config/sql/videos.sql' su postgres -c 'psql invidious < config/sql/videos.sql'
su postgres -c 'psql invidious < config/sql/channel_videos.sql' su postgres -c 'psql invidious < config/sql/channel_videos.sql'
su postgres -c 'psql invidious < config/sql/users.sql' su postgres -c 'psql invidious < config/sql/users.sql'
su postgres -c 'psql invidious < config/sql/session_ids.sql'
su postgres -c 'psql invidious < config/sql/nonces.sql' su postgres -c 'psql invidious < config/sql/nonces.sql'
touch /var/lib/postgresql/data/setupFinished touch /var/lib/postgresql/data/setupFinished
echo "### invidious database setup finished" echo "### invidious database setup finished"