File: 04_deploy.sql

package info (click to toggle)
pgl-ddl-deploy 2.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,780 kB
  • sloc: sql: 47,586; ansic: 364; python: 282; sh: 72; makefile: 63
file content (48 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (3)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--These will show different warnings depending on version 
SET client_min_messages = error;
\set VERBOSITY TERSE
/***
No deploy allowed if table would be added to replication
***/
SET ROLE test_pgl_ddl_deploy;
CREATE TABLE foo(id serial primary key);
SET ROLE postgres;
SELECT pgl_ddl_deploy.deploy('test1');
SET ROLE test_pgl_ddl_deploy;
DROP TABLE foo;
SET ROLE postgres;

--This should work now
SELECT pgl_ddl_deploy.deploy('test1');
--This should work
SELECT pgl_ddl_deploy.disable('test1');

--This should not work
SET ROLE test_pgl_ddl_deploy;
CREATE TABLE foo(id serial primary key);
SET ROLE postgres;
SELECT pgl_ddl_deploy.enable('test1');
SET ROLE test_pgl_ddl_deploy;
DROP TABLE foo;
SET ROLE postgres;

--This should work now
SELECT pgl_ddl_deploy.enable('test1');

--Enable all the rest
DO $$
DECLARE v_rec RECORD;
BEGIN

FOR v_rec IN
    SELECT DISTINCT set_name
    FROM pgl_ddl_deploy.set_configs
    WHERE set_name LIKE 'test%' AND set_name <> 'test1'
    ORDER BY set_name
LOOP

PERFORM pgl_ddl_deploy.deploy(v_rec.set_name);

END LOOP;

END$$;