By default, Tines requires that the Postgres user (DATABASE_USERNAME
) has permissions to create a database and enable extensions. This is typically achieved by using a superuser. This way, Tines itself can a) create and own the database (DATABASE_NAME
) during setup, and b) enable Postgres Extensions during initial setup and upgrades.
Using an existing database
If you would like to run Tines using a less privileged Postgres user (DATABASE_USERNAME
), you must make sure that a) a database called DATABASE_NAME
exists and can be used by this used, and b) you install required Postgres extensions by hand on initial setup and any time new extensions become required by a new version per our release notes.
To achieve this, you can either use an existing database (e.g., a database created by default by a cloud service), or you can create one specifically for Tines. In both of these cases, the DATABASE_USER
must have the necessary permissions to create, use and drop objects (e.g., tables, sequences, indexes) in it. The following is an example SQL script for creating a new database and a new user with all necessariy permissions:
-- Enable required extensions
-- Note: Please review release notes for new extensions when upgrading Tines
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE EXTENSION IF NOT EXISTS plpgsql;
-- Create a non-superuser user to use with the app.
-- This should match `DATABASE_USERNAME` and `DATABASE_PASSWORD`
CREATE USER tines_user WITH PASSWORD '<password-here>';
-- Create a database for Tines. It should match `DATABASE_NAME`
CREATE DATABASE tines_db;
-- Make the user the database owner so they get all required privileges
ALTER DATABASE tines_db OWNER TO tines_user;
Using a schema other than public
By default, Tines will create all objects in the public schema of the database, and assumes that the search_path
is left on its default setting of "public". If you need to run Tines on a different schema, please make sure that tines_user owns this schema or otherwise has been granted all privileges on it, and, that the DATABASE_SCHEMA
envionment variable is set and that the search_path
is configured correctly on that user or the DATABASE_SCHEMA_SEARCH_PATH
is set.