migrate-db-3646395.sh 398 B

123456789
  1. #!/bin/sh
  2. [ -z "$POSTGRES_USER" ] && POSTGRES_USER=kemal
  3. [ -z "$POSTGRES_DB" ] && POSTGRES_DB=invidious
  4. psql "$POSTGRES_DB" "$POSTGRES_USER" < config/sql/session_ids.sql
  5. psql "$POSTGRES_DB" "$POSTGRES_USER" -c "INSERT INTO session_ids (SELECT unnest(id), email, CURRENT_TIMESTAMP FROM users) ON CONFLICT (id) DO NOTHING"
  6. psql "$POSTGRES_DB" "$POSTGRES_USER" -c "ALTER TABLE users DROP COLUMN id"