File: create-schema.sql

package info (click to toggle)
python-stetl 1.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 89,988 kB
  • sloc: python: 5,007; xml: 707; sql: 430; makefile: 155; sh: 50
file content (28 lines) | stat: -rw-r--r-- 550 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Maak schema aan indien deze nog niet bestaat.
-- Doe niets voor schema 'public'
CREATE OR REPLACE FUNCTION _nlx_createschema(schemaname VARCHAR)
RETURNS void AS
$$
BEGIN

    IF schemaname = 'public' THEN
        RETURN;
    END IF;

    IF NOT EXISTS(
        SELECT schema_name
        FROM information_schema.schemata
        WHERE schema_name = $1
    )
    THEN
        EXECUTE 'CREATE SCHEMA ' || $1 || ';';
    END IF;

END;
$$
LANGUAGE plpgsql;

SELECT _nlx_createschema('{schema}');

DROP FUNCTION _nlx_createschema(schemaname VARCHAR);