uboslinux / ubos-admin

UBOS administration tools
Other
15 stars 3 forks source link

If Postgres tables are owned by user foo, upon ubos-admin update, make sure bar now owns them #526

Closed jernst closed 5 years ago

jernst commented 5 years ago

By default, we create all Postgresql database tables as user postgres, which then owns them. This is a good idea because that way, the AppConfig's provisioned database user cannot acccidentally modify the schema of the database.

However, some application frameworks (like what's used by Mastodon), like to perform database migrations from scripts (like bundle exec rails db:migrate) that want to use the AppConfig's provisioned database user. Which they can't if the tables are owned by postgres.

Second problem: upon ubos-admin update, or during restore, the AppConfig's old provisioned database user does not exist upon restore.

Ergo: for those apps that need this, we need to change database table ownership (and perhaps the ownership of some other things, too) after restore of the database content, but before any migration scripts are run.

jernst commented 5 years ago

This is the same as https://github.com/uboslinux/ubos-mastodon/issues/7, but the analysis was wrong: we need to change ownership, not grant permissions.