Create kngil DB in init shell script
This commit is contained in:
12
docker/initdb/00_create_db.sh
Executable file
12
docker/initdb/00_create_db.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "postgres" <<'EOSQL'
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'kngil') THEN
|
||||||
|
CREATE DATABASE kngil;
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
EOSQL
|
||||||
@@ -20,14 +20,6 @@ SET xmloption = content;
|
|||||||
SET client_min_messages = warning;
|
SET client_min_messages = warning;
|
||||||
SET row_security = off;
|
SET row_security = off;
|
||||||
|
|
||||||
--
|
|
||||||
-- Ensure target database exists (idempotent for init scripts)
|
|
||||||
--
|
|
||||||
\connect postgres
|
|
||||||
SELECT 'CREATE DATABASE kngil'
|
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'kngil')\gexec
|
|
||||||
\connect kngil
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- TOC entry 6 (class 2615 OID 16413)
|
-- TOC entry 6 (class 2615 OID 16413)
|
||||||
-- Name: kngil; Type: SCHEMA; Schema: -; Owner: postgres
|
-- Name: kngil; Type: SCHEMA; Schema: -; Owner: postgres
|
||||||
|
|||||||
Reference in New Issue
Block a user