From: | Pól Ua Laoínecháin <linehanp(at)tcd(dot)ie> |
---|---|
To: | pgsql-novice(at)lists(dot)postgresql(dot)org |
Subject: | Scripting with subdirectories - how to specify script locations. |
Date: | 2021-06-02 11:48:56 |
Message-ID: | CAF4RT5TvCEO8yj8dxsz2yNO8RZ3-WWGB6CpUxS=0y3tBRd6nyw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi all,
I like splitting scripts up into sub-units - painful at first, but I
find that it pays off in the long run - modularity &c.
I have a series of scripts for a relatively simple system as follows:
├── 01_create_database.sql
├── 02_create_schemas.sql
├── tab_create
│ ├── 01_create_tables.sql
│ ├── create.hr.employees.sql
│ └── create.production.suppliers.sql
└── tab_data
├── 01_populate_tables.sql
├── populate.hr.employees.sql
└── populate.production.suppliers.sql
So, I have my "master" script - 01_create_database.sql - as follows:
===========================
CREATE DATABASE w_test;
\c w_test;
\i 02_create_schemas.sql; -- the schemas are created no problem...
\i ./tab_create/01_create_tables.sql;
\i tab_data/populate_tables.sql;
================================
Now, in the tab_create directory, I have 01_create_tables.sql as follows:
[pol(at)fedora tab_create]$ more 01_create_tables.sql
===========================
\i ./create.hr.employees.sql;
\i ./create.production.suppliers.sql;
==============================
But, when running \i 01_create_database.sql I get:
===============================
test=# \i 01_create_database.sql
CREATE DATABASE
You are now connected to database "w_test" as user "pol".
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
CREATE SCHEMA
psql:./tab_create/01_create_tables.sql:2: error:
./create.hr.employees.sql: No such file or directory
psql:./tab_create/01_create_tables.sql:4: error:
./create.production.suppliers.sql: No such file or directory
psql:01_create_database.sql:17: error: tab_data/populate_tables.sql:
No such file or directory
w_test=#
==================================
So, my schemas are created and my script goes to 01_create_tables.sql
- *_BUT_* then it can't find my create.hr.employees.sql script or the
other one.
I have tried with just putting create.hr.employees.sql instead of ./create...
I know I'm probably missing something basic - could some kind soul
point me in the right direction?
TIA and rgs,
Pól...
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2021-06-02 13:33:32 | Re: Scripting with subdirectories - how to specify script locations. |
Previous Message | hubert depesz lubaczewski | 2021-06-02 07:07:59 | Re: New to postgres |