Skip to content

Commit 8599839

Browse files
authored
Merge pull request #1571 from constructive-io/feat/pgpm-import
feat(pgpm): pgpm import — pgpm-itize an arbitrary SQL dump (Part A of #1340)
2 parents 45b9191 + 87e8c9d commit 8599839

12 files changed

Lines changed: 2059 additions & 58 deletions

File tree

Lines changed: 363 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,363 @@
1+
--
2+
-- PostgreSQL database dump
3+
--
4+
5+
\restrict Rhcdwy2WGDhj9Q1hKGNyv7beFEsbwg6bGgxjVYIVY9511ICWws8BXfu2kIXtqFa
6+
7+
-- Dumped from database version 18.4
8+
-- Dumped by pg_dump version 18.4
9+
10+
SET statement_timeout = 0;
11+
SET lock_timeout = 0;
12+
SET idle_in_transaction_session_timeout = 0;
13+
SET transaction_timeout = 0;
14+
SET client_encoding = 'UTF8';
15+
SET standard_conforming_strings = on;
16+
SELECT pg_catalog.set_config('search_path', '', false);
17+
SET check_function_bodies = false;
18+
SET xmloption = content;
19+
SET client_min_messages = warning;
20+
SET row_security = off;
21+
22+
--
23+
-- Name: imp_app; Type: SCHEMA; Schema: -; Owner: postgres
24+
--
25+
26+
CREATE SCHEMA imp_app;
27+
28+
29+
ALTER SCHEMA imp_app OWNER TO postgres;
30+
31+
--
32+
-- Name: SCHEMA imp_app; Type: COMMENT; Schema: -; Owner: postgres
33+
--
34+
35+
COMMENT ON SCHEMA imp_app IS 'Application schema';
36+
37+
38+
--
39+
-- Name: imp_audit; Type: SCHEMA; Schema: -; Owner: postgres
40+
--
41+
42+
CREATE SCHEMA imp_audit;
43+
44+
45+
ALTER SCHEMA imp_audit OWNER TO postgres;
46+
47+
--
48+
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
49+
--
50+
51+
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
52+
53+
54+
--
55+
-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner:
56+
--
57+
58+
COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
59+
60+
61+
--
62+
-- Name: touch(); Type: FUNCTION; Schema: imp_app; Owner: postgres
63+
--
64+
65+
CREATE FUNCTION imp_app.touch() RETURNS trigger
66+
LANGUAGE plpgsql
67+
AS $$
68+
BEGIN
69+
NEW.created_at := now();
70+
RETURN NEW;
71+
END;
72+
$$;
73+
74+
75+
ALTER FUNCTION imp_app.touch() OWNER TO postgres;
76+
77+
--
78+
-- Name: FUNCTION touch(); Type: COMMENT; Schema: imp_app; Owner: postgres
79+
--
80+
81+
COMMENT ON FUNCTION imp_app.touch() IS 'touch trigger fn';
82+
83+
84+
--
85+
-- Name: order_seq; Type: SEQUENCE; Schema: imp_app; Owner: postgres
86+
--
87+
88+
CREATE SEQUENCE imp_app.order_seq
89+
START WITH 100
90+
INCREMENT BY 1
91+
NO MINVALUE
92+
NO MAXVALUE
93+
CACHE 1;
94+
95+
96+
ALTER SEQUENCE imp_app.order_seq OWNER TO postgres;
97+
98+
SET default_tablespace = '';
99+
100+
SET default_table_access_method = heap;
101+
102+
--
103+
-- Name: orders; Type: TABLE; Schema: imp_app; Owner: postgres
104+
--
105+
106+
CREATE TABLE imp_app.orders (
107+
id integer DEFAULT nextval('imp_app.order_seq'::regclass) NOT NULL,
108+
user_id integer NOT NULL,
109+
note text
110+
);
111+
112+
113+
ALTER TABLE imp_app.orders OWNER TO postgres;
114+
115+
--
116+
-- Name: users; Type: TABLE; Schema: imp_app; Owner: postgres
117+
--
118+
119+
CREATE TABLE imp_app.users (
120+
id integer NOT NULL,
121+
email text NOT NULL,
122+
created_at timestamp with time zone DEFAULT now()
123+
);
124+
125+
126+
ALTER TABLE imp_app.users OWNER TO postgres;
127+
128+
--
129+
-- Name: TABLE users; Type: COMMENT; Schema: imp_app; Owner: postgres
130+
--
131+
132+
COMMENT ON TABLE imp_app.users IS 'App users';
133+
134+
135+
--
136+
-- Name: COLUMN users.email; Type: COMMENT; Schema: imp_app; Owner: postgres
137+
--
138+
139+
COMMENT ON COLUMN imp_app.users.email IS 'Login email';
140+
141+
142+
--
143+
-- Name: users_id_seq; Type: SEQUENCE; Schema: imp_app; Owner: postgres
144+
--
145+
146+
CREATE SEQUENCE imp_app.users_id_seq
147+
AS integer
148+
START WITH 1
149+
INCREMENT BY 1
150+
NO MINVALUE
151+
NO MAXVALUE
152+
CACHE 1;
153+
154+
155+
ALTER SEQUENCE imp_app.users_id_seq OWNER TO postgres;
156+
157+
--
158+
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: imp_app; Owner: postgres
159+
--
160+
161+
ALTER SEQUENCE imp_app.users_id_seq OWNED BY imp_app.users.id;
162+
163+
164+
--
165+
-- Name: events; Type: TABLE; Schema: imp_audit; Owner: postgres
166+
--
167+
168+
CREATE TABLE imp_audit.events (
169+
id integer NOT NULL,
170+
user_id integer,
171+
detail text
172+
);
173+
174+
175+
ALTER TABLE imp_audit.events OWNER TO postgres;
176+
177+
--
178+
-- Name: events_id_seq; Type: SEQUENCE; Schema: imp_audit; Owner: postgres
179+
--
180+
181+
CREATE SEQUENCE imp_audit.events_id_seq
182+
AS integer
183+
START WITH 1
184+
INCREMENT BY 1
185+
NO MINVALUE
186+
NO MAXVALUE
187+
CACHE 1;
188+
189+
190+
ALTER SEQUENCE imp_audit.events_id_seq OWNER TO postgres;
191+
192+
--
193+
-- Name: events_id_seq; Type: SEQUENCE OWNED BY; Schema: imp_audit; Owner: postgres
194+
--
195+
196+
ALTER SEQUENCE imp_audit.events_id_seq OWNED BY imp_audit.events.id;
197+
198+
199+
--
200+
-- Name: users id; Type: DEFAULT; Schema: imp_app; Owner: postgres
201+
--
202+
203+
ALTER TABLE ONLY imp_app.users ALTER COLUMN id SET DEFAULT nextval('imp_app.users_id_seq'::regclass);
204+
205+
206+
--
207+
-- Name: events id; Type: DEFAULT; Schema: imp_audit; Owner: postgres
208+
--
209+
210+
ALTER TABLE ONLY imp_audit.events ALTER COLUMN id SET DEFAULT nextval('imp_audit.events_id_seq'::regclass);
211+
212+
213+
--
214+
-- Data for Name: orders; Type: TABLE DATA; Schema: imp_app; Owner: postgres
215+
--
216+
217+
COPY imp_app.orders (id, user_id, note) FROM stdin;
218+
100 1 first\torder
219+
101 2 \N
220+
\.
221+
222+
223+
--
224+
-- Data for Name: users; Type: TABLE DATA; Schema: imp_app; Owner: postgres
225+
--
226+
227+
COPY imp_app.users (id, email, created_at) FROM stdin;
228+
1 a@example.com 2026-07-31 22:53:49.879981+00
229+
2 b@example.com 2026-07-31 22:53:49.879981+00
230+
\.
231+
232+
233+
--
234+
-- Data for Name: events; Type: TABLE DATA; Schema: imp_audit; Owner: postgres
235+
--
236+
237+
COPY imp_audit.events (id, user_id, detail) FROM stdin;
238+
\.
239+
240+
241+
--
242+
-- Name: order_seq; Type: SEQUENCE SET; Schema: imp_app; Owner: postgres
243+
--
244+
245+
SELECT pg_catalog.setval('imp_app.order_seq', 101, true);
246+
247+
248+
--
249+
-- Name: users_id_seq; Type: SEQUENCE SET; Schema: imp_app; Owner: postgres
250+
--
251+
252+
SELECT pg_catalog.setval('imp_app.users_id_seq', 2, true);
253+
254+
255+
--
256+
-- Name: events_id_seq; Type: SEQUENCE SET; Schema: imp_audit; Owner: postgres
257+
--
258+
259+
SELECT pg_catalog.setval('imp_audit.events_id_seq', 1, false);
260+
261+
262+
--
263+
-- Name: orders orders_pkey; Type: CONSTRAINT; Schema: imp_app; Owner: postgres
264+
--
265+
266+
ALTER TABLE ONLY imp_app.orders
267+
ADD CONSTRAINT orders_pkey PRIMARY KEY (id);
268+
269+
270+
--
271+
-- Name: users users_email_key; Type: CONSTRAINT; Schema: imp_app; Owner: postgres
272+
--
273+
274+
ALTER TABLE ONLY imp_app.users
275+
ADD CONSTRAINT users_email_key UNIQUE (email);
276+
277+
278+
--
279+
-- Name: users users_pkey; Type: CONSTRAINT; Schema: imp_app; Owner: postgres
280+
--
281+
282+
ALTER TABLE ONLY imp_app.users
283+
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
284+
285+
286+
--
287+
-- Name: events events_pkey; Type: CONSTRAINT; Schema: imp_audit; Owner: postgres
288+
--
289+
290+
ALTER TABLE ONLY imp_audit.events
291+
ADD CONSTRAINT events_pkey PRIMARY KEY (id);
292+
293+
294+
--
295+
-- Name: orders_user_idx; Type: INDEX; Schema: imp_app; Owner: postgres
296+
--
297+
298+
CREATE INDEX orders_user_idx ON imp_app.orders USING btree (user_id);
299+
300+
301+
--
302+
-- Name: users users_touch; Type: TRIGGER; Schema: imp_app; Owner: postgres
303+
--
304+
305+
CREATE TRIGGER users_touch BEFORE UPDATE ON imp_app.users FOR EACH ROW EXECUTE FUNCTION imp_app.touch();
306+
307+
308+
--
309+
-- Name: orders orders_user_fk; Type: FK CONSTRAINT; Schema: imp_app; Owner: postgres
310+
--
311+
312+
ALTER TABLE ONLY imp_app.orders
313+
ADD CONSTRAINT orders_user_fk FOREIGN KEY (user_id) REFERENCES imp_app.users(id);
314+
315+
316+
--
317+
-- Name: events events_user_id_fkey; Type: FK CONSTRAINT; Schema: imp_audit; Owner: postgres
318+
--
319+
320+
ALTER TABLE ONLY imp_audit.events
321+
ADD CONSTRAINT events_user_id_fkey FOREIGN KEY (user_id) REFERENCES imp_app.users(id);
322+
323+
324+
--
325+
-- Name: users; Type: ROW SECURITY; Schema: imp_app; Owner: postgres
326+
--
327+
328+
ALTER TABLE imp_app.users ENABLE ROW LEVEL SECURITY;
329+
330+
--
331+
-- Name: users users_select; Type: POLICY; Schema: imp_app; Owner: postgres
332+
--
333+
334+
CREATE POLICY users_select ON imp_app.users FOR SELECT USING (true);
335+
336+
337+
--
338+
-- Name: SCHEMA imp_app; Type: ACL; Schema: -; Owner: postgres
339+
--
340+
341+
GRANT USAGE ON SCHEMA imp_app TO PUBLIC;
342+
343+
344+
--
345+
-- Name: TABLE orders; Type: ACL; Schema: imp_app; Owner: postgres
346+
--
347+
348+
GRANT SELECT,INSERT ON TABLE imp_app.orders TO PUBLIC;
349+
350+
351+
--
352+
-- Name: TABLE users; Type: ACL; Schema: imp_app; Owner: postgres
353+
--
354+
355+
GRANT SELECT ON TABLE imp_app.users TO PUBLIC;
356+
357+
358+
--
359+
-- PostgreSQL database dump complete
360+
--
361+
362+
\unrestrict Rhcdwy2WGDhj9Q1hKGNyv7beFEsbwg6bGgxjVYIVY9511ICWws8BXfu2kIXtqFa
363+

0 commit comments

Comments
 (0)