simplify postgres and sqlite database initialization, remove psqlinit.sh (#331)

Before this change, uninitialized databases would be initialized with the old
schema and then migrated to the latest version. After this change, unintialized
databases are initizialized with the latest database schema immediately, without
having to run any of the migrations. This change has no effect on existing
databases.

Before this change, Postgres database initialization was done manually using
utils/psqlinit.sh. This is inconsistent with SQLite, which the bot initializes
itself. It also requires shell access to the server running the Postgres
instance, which means it cannot be used on managed Postgres instances. After
this change, the bot initializes Postgres databases as it does with SQLite, and
utils/psqlinit.sh has been removed as it is now unecessary.
This commit is contained in:
samhza 2022-11-26 16:31:00 -05:00 committed by GitHub
parent 1830db6282
commit c00d518f6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 62 deletions

View file

@ -49,11 +49,7 @@ Once you're inside the shell, you'll need to make sure the bot owns the database
```sql
ALTER DATABASE esmbot OWNER TO esmbot;
```
The database is now accessible by the bot, but the bot may not function yet as the tables to add/get data are still missing. To fix that, you'll need to add them. Luckily, the bot comes with a script to automate this. First, exit the PostgreSQL shell by typing `\q`, then make the script executable and run it by entering the following commands:
```sh
chmod +x utils/psqlinit.sh
POSTGRES_USER=esmbot POSTGRES_DB=esmbot utils/psqlinit.sh
```
You're done!
***