-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathspock--4.0.1--4.0.2.sql
106 lines (95 loc) · 2.82 KB
/
spock--4.0.1--4.0.2.sql
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* spock--4.0.1--4.0.2.sql */
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION spock UPDATE TO '4.0.2'" to load this file. \quit
-- ----
-- Change the layout and primary key of the exception_log* tables
-- ----
CREATE TABLE spock.exception_log_temp (
remote_origin oid NOT NULL,
remote_commit_ts timestamptz NOT NULL,
command_counter integer NOT NULL,
retry_errored_at timestamptz NOT NULL,
remote_xid bigint NOT NULL,
local_origin oid,
local_commit_ts timestamptz,
table_schema text,
table_name text,
operation text,
local_tup jsonb,
remote_old_tup jsonb,
remote_new_tup jsonb,
ddl_statement text,
ddl_user text,
error_message text NOT NULL,
PRIMARY KEY(remote_origin, remote_commit_ts,
command_counter, retry_errored_at)
) WITH (user_catalog_table=true);
INSERT INTO spock.exception_log_temp
SELECT remote_origin,
remote_commit_ts,
command_counter,
retry_errored_at,
remote_xid,
local_origin,
local_commit_ts,
table_schema,
table_name,
operation,
local_tup,
remote_old_tup,
remote_new_tup,
ddl_statement,
ddl_user,
error_message
FROM spock.exception_log;
DROP TABLE spock.exception_log;
ALTER TABLE spock.exception_log_temp RENAME TO exception_log;
CREATE TABLE spock.exception_status_temp (
remote_origin oid NOT NULL,
remote_commit_ts timestamptz NOT NULL,
retry_errored_at timestamptz NOT NULL,
remote_xid bigint NOT NULL,
status text NOT NULL,
resolved_at timestamptz,
resolution_details jsonb,
PRIMARY KEY(remote_origin, remote_commit_ts, retry_errored_at)
) WITH (user_catalog_table=true);
INSERT INTO spock.exception_status_temp
SELECT remote_origin,
remote_commit_ts,
'epoch'::timestamptz,
remote_xid,
status,
resolved_at,
resolution_details
FROM spock.exception_status;
CREATE TABLE spock.exception_status_detail_temp (
remote_origin oid NOT NULL,
remote_commit_ts timestamptz NOT NULL,
command_counter integer NOT NULL,
retry_errored_at timestamptz NOT NULL,
remote_xid bigint NOT NULL,
status text NOT NULL,
resolved_at timestamptz,
resolution_details jsonb,
PRIMARY KEY(remote_origin, remote_commit_ts,
command_counter, retry_errored_at),
FOREIGN KEY(remote_origin, remote_commit_ts, retry_errored_at)
REFERENCES spock.exception_status_temp
) WITH (user_catalog_table=true);
INSERT INTO spock.exception_status_detail_temp
SELECT remote_origin,
remote_commit_ts,
command_counter,
'epoch'::timestamptz,
remote_xid,
status,
resolved_at,
resolution_details
FROM spock.exception_status_detail;
DROP TABLE spock.exception_status_detail;
ALTER TABLE spock.exception_status_detail_temp
RENAME TO exception_status_detail;
DROP TABLE spock.exception_status;
ALTER TABLE spock.exception_status_temp
RENAME TO exception_status;