-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Postgres role hardcoded in initial tables #1772
Comments
The user is also hardcoded in the migration scripts, #976 |
Funnily enough, I just had this same issue when setting this up a couple days ago. Fixing this is probably not the number one priority, but at least some documentation (for instance, a comment in |
So I was able to get the However, since the .sql scripts are being run via shell scripts, I just used sed!
Essentially, I used sed to replace kemal with #!/bin/bash
set -eou pipefail
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER postgres;
EOSQL
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/channels.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/videos.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/channel_videos.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/users.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/session_ids.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/nonces.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/annotations.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/playlists.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB"
sed -r 's/kemal/'"$POSTGRES_USER"'/' config/sql/playlist_videos.sql | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" Now, the reason I'm posting this instead of just doing a pull request with the changes is the migrate-db-*.sh files. If those are being generated as part of development then they might cause issues down the line. Should this be something that the devs do for us or should this just be documented? |
There could be a proper pgsql initialisation script which is inside the Something like "if I can authenticate with the creds you gave me in the environment, but the tables don't exist, create them". |
This would be a much better solution than adding the db init scripts as a volume mount to the postgres container. Also, this would allow running Invidious in Docker using the prebuilt images without a local copy of the repo. |
@stranger-danger-zamu how about your PR? |
bump |
Those files are maintained manually. They are here to help database migrations. We are aware that this is not the best solution, and that in the future, this should be done automatically, from the code, and not from the shell. |
Describe the bug
Postgres role/username seems to be hardcoded as
kemal
even if set to another name in compose/config.Steps to Reproduce
Logs
The text was updated successfully, but these errors were encountered: