Scripting with subdirectories - how to specify script locations.

Поиск
Список
Период
Сортировка
От Pól Ua Laoínecháin
Тема Scripting with subdirectories - how to specify script locations.
Дата
Msg-id CAF4RT5TvCEO8yj8dxsz2yNO8RZ3-WWGB6CpUxS=0y3tBRd6nyw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Scripting with subdirectories - how to specify script locations.  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список 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@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...



В списке pgsql-novice по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: New to postgres
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Scripting with subdirectories - how to specify script locations.