-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.psqlrc
More file actions
19 lines (17 loc) · 819 Bytes
/
Copy path.psqlrc
File metadata and controls
19 lines (17 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Set a variable for your production database connection string
\set PROD_DBNAME detail
\set PROD_HOST 'ep-long-math-08342696.us-west-2.aws.neon.tech'
\set POOLED_PROD_HOST 'ep-long-math-08342696-pooler.us-west-2.aws.neon.tech'
-- Define a function to check if we're in production
SELECT current_database() = :'PROD_DBNAME' AND (:'HOST' = :'PROD_HOST' OR :'HOST' = :'POOLED_PROD_HOST') AS is_prod \gset
-- Use the result of the function to set the prompt
\if :is_prod
-- Set red bold prompt for production
\set PROMPT1 '%[%033[1;31m%][THIS IS PROD!] %/%R%[%033[0m%]%# '
\set PROMPT2 '%[%033[1;31m%][THIS IS PROD!] %/%R%[%033[0m%]%# '
\echo '\033[1;31mWARNING: Connected to PRODUCTION database!\033[0m'
\else
-- Set default prompt for non-production
\set PROMPT1 '%/%R%# '
\set PROMPT2 '%/%R%# '
\endif