Create extension pg_trgm in the NixOS module

The creation of the pg_trgm extension needs superuser power. So, this patch makes the extension creation in the Hydra NixOS module when a local database is used.

If it is not possible to create this extension (remote database for instance with nosuperuser), the creation of the pg_trgm index is skipped (this index speedup queries on builds.drvpath) and warnings are emitted:

initialising the Hydra database schema...
WARNING:  Can not create extension pg_trgm: permission denied to create extension "pg_trgm"
WARNING:  HINT: Temporary provide superuser role to your Hydra Postgresql user and run the script src/sql/upgrade-57.sql
WARNING:  The pg_trgm index on builds.drvpath has been skipped (slower complex queries on builds.drvpath)

This allows to keep smooth migrations: the migration process doesn't require a manual step (but this manual step is recommended on big remote databases).

Created by  Antoine Eiche  on June 20, 2019
TOLUNFACYKO3KHNZBULYO37LYJB7DB7JEY7NMCZCCDJF3EU6TVFQC
Change contents