c0c0n3 / odoo.box

All of Martel's Odoo stack on just one NixOS machine.
MIT License
3 stars 0 forks source link

Possibly simpler PgAdmin bootstrap procedure? #15

Open c0c0n3 opened 4 months ago

c0c0n3 commented 4 months ago

At the moment we're using a procedure similar to that in the NixOS PgAdmin module to create and populate PgAdmin tables. We basically call the pgadmin4-setup Python script from the pgadmin4 Nix package to do the job.

It turns out the PgAdmin UI process actually runs DB migrations on startup. It tries connecting to the DB given in CONFIG_DATABASE_URI and fetch the current DB config version from the version table. If that table isn't there (empty DB) or the version is older then the current one, the UI process triggers the same setup procedure that pgadmin4-setup does, eventually calling user_info_server in pgadmin.setup.user_info. Here's the call trace for the case when the DB is empty:

Now user_info_server tries reading the initial user and password from the PGADMIN_SETUP_EMAIL and PGADMIN_SETUP_PASSWORD env vars, respectively.

So in principle we don't need pgadmin4-setup, which would simplify our bootstrap procedure. We could have just a single PgAdmin service with an

If we do this, we could easily implement #14 too.