forked from lix-project/hydra
Merge pull request #657 from nlewo/create-pg-trgm-in-module
Create `pg_trgm` extension in the NixOS module
This commit is contained in:
commit
5e9439e774
|
@ -273,6 +273,7 @@ in
|
|||
runuser -u ${config.services.postgresql.superUser} -- ${config.services.postgresql.package}/bin/createdb -O hydra hydra
|
||||
touch ${baseDir}/.db-created
|
||||
fi
|
||||
echo "create extension if not exists pg_trgm" | runuser -u ${config.services.postgresql.superUser} -- ${config.services.postgresql.package}/bin/psql hydra
|
||||
''}
|
||||
|
||||
if [ ! -e ${cfg.gcRootsDir} ]; then
|
||||
|
@ -415,6 +416,8 @@ in
|
|||
hydra-users hydra-queue-runner hydra
|
||||
hydra-users hydra-www hydra
|
||||
hydra-users root hydra
|
||||
# The postgres user is used to create the pg_trgm extension for the hydra database
|
||||
hydra-users postgres postgres
|
||||
'';
|
||||
|
||||
services.postgresql.authentication = optionalString haveLocalDB
|
||||
|
|
|
@ -690,7 +690,20 @@ create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, id desc)
|
|||
create index IndexBuildsOnNotificationPendingSince on Builds(notificationPendingSince) where notificationPendingSince is not null;
|
||||
|
||||
#ifdef POSTGRESQL
|
||||
-- The pg_trgm extension has to be created by a superuser. The NixOS
|
||||
-- module creates this extension in the systemd prestart script. We
|
||||
-- then ensure the extension has been created before creating the
|
||||
-- index. If it is not possible to create the extension, a warning
|
||||
-- message is emitted to inform the user the index creation is skipped
|
||||
-- (slower complex queries on builds.drvpath).
|
||||
do $$
|
||||
begin
|
||||
create extension if not exists pg_trgm;
|
||||
-- Provide an index used by LIKE operator on builds.drvpath (search query)
|
||||
CREATE EXTENSION pg_trgm;
|
||||
CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops);
|
||||
create index IndexTrgmBuildsOnDrvpath on builds using gin (drvpath gin_trgm_ops);
|
||||
exception when others then
|
||||
raise warning 'Can not create extension pg_trgm: %', SQLERRM;
|
||||
raise warning 'HINT: Temporary provide superuser role to your Hydra Postgresql user and run the script src/sql/upgrade-57.sql';
|
||||
raise warning 'The pg_trgm index on builds.drvpath has been skipped (slower complex queries on builds.drvpath)';
|
||||
end$$;
|
||||
#endif
|
||||
|
|
|
@ -1,2 +1,16 @@
|
|||
CREATE EXTENSION pg_trgm;
|
||||
CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops);
|
||||
-- The pg_trgm extension has to be created by a superuser. The NixOS
|
||||
-- module creates this extension in the systemd prestart script. We
|
||||
-- then ensure the extension has been created before creating the
|
||||
-- index. If it is not possible to create the extension, a warning
|
||||
-- message is emitted to inform the user the index creation is skipped
|
||||
-- (slower complex queries on builds.drvpath).
|
||||
do $$
|
||||
begin
|
||||
create extension if not exists pg_trgm;
|
||||
-- Provide an index used by LIKE operator on builds.drvpath (search query)
|
||||
create index IndexTrgmBuildsOnDrvpath on builds using gin (drvpath gin_trgm_ops);
|
||||
exception when others then
|
||||
raise warning 'Can not create extension pg_trgm: %', SQLERRM;
|
||||
raise warning 'HINT: Temporary provide superuser role to your Hydra Postgresql user and run the script src/sql/upgrade-57.sql';
|
||||
raise warning 'The pg_trgm index on builds.drvpath has been skipped (slower complex queries on builds.drvpath)';
|
||||
end$$;
|
||||
|
|
Loading…
Reference in a new issue