🗃️ Create and use a db dedicated user for backend

* Rename the db name (idfm_matrix_bot -> cer_db).
 * Remove unused bot database.
 * Create a dedicated user (cer_user/cer_password).
This commit is contained in:
2023-01-22 19:02:54 +01:00
parent 76d4c8a641
commit dea6b928e1
2 changed files with 6 additions and 6 deletions

View File

@@ -2,10 +2,10 @@
set -e set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER idfm_matrix_bot; CREATE USER cer_user WITH ENCRYPTED password 'cer_password';
CREATE DATABASE bot; CREATE DATABASE cer_db;
CREATE DATABASE idfm; \c cer_db;
GRANT ALL PRIVILEGES ON DATABASE bot TO idfm_matrix_bot; CREATE EXTENSION IF NOT EXISTS pg_trgm SCHEMA "public";
GRANT ALL PRIVILEGES ON DATABASE idfm TO idfm_matrix_bot; GRANT CREATE ON SCHEMA public to cer_user;
EOSQL EOSQL

View File

@@ -24,7 +24,7 @@ API_KEY = environ.get("API_KEY")
# TODO: Add error message if no key is given. # TODO: Add error message if no key is given.
# TODO: Remove postgresql+asyncpg from environ variable # TODO: Remove postgresql+asyncpg from environ variable
DB_PATH = "postgresql+asyncpg://postgres:postgres@127.0.0.1:5438/idfm" DB_PATH = "postgresql+asyncpg://cer_user:cer_password@127.0.0.1:5438/cer_db"
app = FastAPI() app = FastAPI()