postgres-hhvm.sql 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. --
  2. -- PostgreSQL database dump
  3. --
  4. SET statement_timeout = 0;
  5. SET client_encoding = 'UTF8';
  6. SET standard_conforming_strings = off;
  7. SET check_function_bodies = false;
  8. SET client_min_messages = warning;
  9. SET escape_string_warning = off;
  10. --
  11. -- Name: anotherschema; Type: SCHEMA; Schema: -; Owner: -
  12. --
  13. DROP SCHEMA IF EXISTS anotherschema CASCADE;
  14. CREATE SCHEMA anotherschema;
  15. SET search_path = anotherschema, pg_catalog;
  16. SET default_tablespace = '';
  17. SET default_with_oids = false;
  18. --
  19. -- Name: users; Type: TABLE; Schema: anotherschema; Owner: -; Tablespace:
  20. --
  21. DROP TABLE IF EXISTS users CASCADE;
  22. CREATE TABLE users (
  23. name character varying(30),
  24. email character varying(50),
  25. created_at timestamp without time zone DEFAULT now(),
  26. id integer NOT NULL
  27. );
  28. --
  29. -- Name: users_id_seq; Type: SEQUENCE; Schema: anotherschema; Owner: -
  30. --
  31. CREATE SEQUENCE users_id_seq
  32. START WITH 1
  33. INCREMENT BY 1
  34. NO MINVALUE
  35. NO MAXVALUE
  36. CACHE 1;
  37. --
  38. -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: anotherschema; Owner: -
  39. --
  40. ALTER SEQUENCE users_id_seq OWNED BY users.id;
  41. SET search_path = public, pg_catalog;
  42. --
  43. -- Name: seqnames; Type: TABLE; Schema: public; Owner: -; Tablespace:
  44. --
  45. DROP TABLE IF EXISTS seqnames CASCADE;
  46. CREATE TABLE seqnames (
  47. name character varying(30),
  48. pk_id integer NOT NULL
  49. );
  50. --
  51. -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  52. --
  53. CREATE SEQUENCE seqnames_pk_id_seq
  54. START WITH 1
  55. INCREMENT BY 1
  56. NO MINVALUE
  57. NO MAXVALUE
  58. CACHE 1;
  59. --
  60. -- Name: seqnames_pk_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  61. --
  62. ALTER SEQUENCE seqnames_pk_id_seq OWNED BY seqnames.pk_id;
  63. --
  64. -- Name: empty_table; Type: TABLE; Schema: public; Owner: -; Tablespace:
  65. --
  66. DROP TABLE IF EXISTS empty_table CASCADE;
  67. CREATE TABLE empty_table (
  68. id integer NOT NULL,
  69. field character varying
  70. );
  71. --
  72. -- Name: empty_table_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  73. --
  74. CREATE SEQUENCE empty_table_id_seq
  75. START WITH 1
  76. INCREMENT BY 1
  77. NO MINVALUE
  78. NO MAXVALUE
  79. CACHE 1;
  80. --
  81. -- Name: empty_table_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  82. --
  83. ALTER SEQUENCE empty_table_id_seq OWNED BY empty_table.id;
  84. --
  85. -- Name: groups; Type: TABLE; Schema: public; Owner: -; Tablespace:
  86. --
  87. DROP TABLE IF EXISTS groups CASCADE;
  88. CREATE TABLE groups (
  89. name character varying(50),
  90. enabled boolean,
  91. created_at timestamp without time zone DEFAULT now(),
  92. id integer NOT NULL
  93. );
  94. --
  95. -- Name: groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  96. --
  97. CREATE SEQUENCE groups_id_seq
  98. START WITH 1
  99. INCREMENT BY 1
  100. NO MAXVALUE
  101. NO MINVALUE
  102. CACHE 1;
  103. --
  104. -- Name: groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  105. --
  106. ALTER SEQUENCE groups_id_seq OWNED BY groups.id;
  107. --
  108. -- Name: permissions; Type: TABLE; Schema: public; Owner: -; Tablespace:
  109. --
  110. DROP TABLE IF EXISTS permissions CASCADE;
  111. CREATE TABLE permissions (
  112. user_id integer,
  113. group_id integer,
  114. role character varying(10),
  115. id integer NOT NULL
  116. );
  117. --
  118. -- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  119. --
  120. CREATE SEQUENCE permissions_id_seq
  121. START WITH 1
  122. INCREMENT BY 1
  123. NO MAXVALUE
  124. NO MINVALUE
  125. CACHE 1;
  126. --
  127. -- Name: permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  128. --
  129. ALTER SEQUENCE permissions_id_seq OWNED BY permissions.id;
  130. --
  131. -- Name: users; Type: TABLE; Schema: public; Owner: -; Tablespace:
  132. --
  133. DROP TABLE IF EXISTS users CASCADE;
  134. CREATE TABLE users (
  135. name character varying(30),
  136. email character varying(50),
  137. created_at timestamp without time zone DEFAULT now(),
  138. id integer NOT NULL
  139. );
  140. --
  141. -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
  142. --
  143. CREATE SEQUENCE users_id_seq
  144. START WITH 1
  145. INCREMENT BY 1
  146. NO MAXVALUE
  147. NO MINVALUE
  148. CACHE 1;
  149. --
  150. -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
  151. --
  152. ALTER SEQUENCE users_id_seq OWNED BY users.id;
  153. SET search_path = anotherschema, pg_catalog;
  154. --
  155. -- Name: id; Type: DEFAULT; Schema: anotherschema; Owner: -
  156. --
  157. ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
  158. SET search_path = public, pg_catalog;
  159. --
  160. -- Name:pk_id; Type: DEFAULT; Schema: public; Owner: -
  161. --
  162. ALTER TABLE ONLY seqnames ALTER COLUMN pk_id SET DEFAULT nextval('seqnames_pk_id_seq'::regclass);
  163. --
  164. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  165. --
  166. ALTER TABLE ONLY empty_table ALTER COLUMN id SET DEFAULT nextval('empty_table_id_seq'::regclass);
  167. --
  168. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  169. --
  170. ALTER TABLE ONLY groups ALTER COLUMN id SET DEFAULT nextval('groups_id_seq'::regclass);
  171. --
  172. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  173. --
  174. ALTER TABLE ONLY permissions ALTER COLUMN id SET DEFAULT nextval('permissions_id_seq'::regclass);
  175. --
  176. -- Name: id; Type: DEFAULT; Schema: public; Owner: -
  177. --
  178. ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
  179. SET search_path = anotherschema, pg_catalog;
  180. --
  181. -- Data for Name: users; Type: TABLE DATA; Schema: anotherschema; Owner: -
  182. --
  183. INSERT INTO users (name, email, created_at, id) VALUES('andrew', 'schemauser@example.org', '2015-10-13 07:26:51.398693', 1);
  184. --
  185. -- Name: users_id_seq; Type: SEQUENCE SET; Schema: anotherschema; Owner: -
  186. --
  187. SELECT pg_catalog.setval('users_id_seq', 1, true);
  188. SET search_path = public, pg_catalog;
  189. --
  190. -- Name: seqnames_pk_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
  191. --
  192. SELECT pg_catalog.setval('seqnames_pk_id_seq', 1, false);
  193. --
  194. -- Name: empty_table_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
  195. --
  196. SELECT pg_catalog.setval('empty_table_id_seq', 1, false);
  197. --
  198. -- Data for Name: groups; Type: TABLE DATA; Schema: public; Owner: -
  199. --
  200. INSERT INTO groups (name, enabled, created_at, id) VALUES
  201. ('coders', 't', '2012-02-02 22:33:30.807', 1),
  202. ('jazzman', 'f', '2012-02-02 22:33:35.271', 2);
  203. --
  204. -- Name: groups_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
  205. --
  206. SELECT pg_catalog.setval('groups_id_seq', 2, true);
  207. --
  208. -- Data for Name: permissions; Type: TABLE DATA; Schema: public; Owner: -
  209. --
  210. INSERT INTO permissions (user_id, group_id, role, id) VALUES
  211. ('1', '1', 'member', '1'),
  212. ('2', '1', 'member', '2'),
  213. ('3', '2', 'member', '9'),
  214. ('4', '2', 'admin', '10');
  215. --
  216. -- Name: permissions_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
  217. --
  218. SELECT pg_catalog.setval('permissions_id_seq', 10, true);
  219. --
  220. -- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: -
  221. --
  222. INSERT INTO users (name, email, created_at, id) VALUES
  223. ('davert', 'davert@mail.ua', NULL, '1'),
  224. ('nick', 'nick@mail.ua', '2012-02-02 22:30:31.748', '2'),
  225. ('miles', 'miles@davis.com', '2012-02-02 22:30:52.166', '3'),
  226. ('bird', 'charlie@parker.com', '2012-02-02 22:32:13.107', '4');
  227. --
  228. -- Name: users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
  229. --
  230. SELECT pg_catalog.setval('users_id_seq', 4, true);
  231. SET search_path = anotherschema, pg_catalog;
  232. --
  233. -- Name: u1; Type: CONSTRAINT; Schema: anotherschema; Owner: -; Tablespace:
  234. --
  235. ALTER TABLE ONLY users
  236. ADD CONSTRAINT u1 PRIMARY KEY (id);
  237. SET search_path = public, pg_catalog;
  238. --
  239. -- Name: g1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  240. --
  241. ALTER TABLE ONLY seqnames
  242. ADD CONSTRAINT s1 PRIMARY KEY (pk_id);
  243. --
  244. -- Name: g1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  245. --
  246. ALTER TABLE ONLY groups
  247. ADD CONSTRAINT g1 PRIMARY KEY (id);
  248. --
  249. -- Name: p1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  250. --
  251. ALTER TABLE ONLY permissions
  252. ADD CONSTRAINT p1 PRIMARY KEY (id);
  253. --
  254. -- Name: u1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
  255. --
  256. ALTER TABLE ONLY users
  257. ADD CONSTRAINT u1 PRIMARY KEY (id);
  258. --
  259. -- Name: pf1; Type: FK CONSTRAINT; Schema: public; Owner: -
  260. --
  261. ALTER TABLE ONLY permissions
  262. ADD CONSTRAINT pf1 FOREIGN KEY (user_id) REFERENCES users(id);
  263. --
  264. -- Name: pg1; Type: FK CONSTRAINT; Schema: public; Owner: -
  265. --
  266. ALTER TABLE ONLY permissions
  267. ADD CONSTRAINT pg1 FOREIGN KEY (group_id) REFERENCES groups(id);
  268. --
  269. -- start test for triggers with $$ syntax
  270. --
  271. INSERT INTO users (name, email) VALUES ('This $$ should work', 'user@example.org');
  272. CREATE OR REPLACE FUNCTION upd_timestamp() RETURNS TRIGGER
  273. LANGUAGE plpgsql
  274. AS
  275. $$
  276. BEGIN
  277. NEW.created_at = CURRENT_TIMESTAMP;
  278. RETURN NEW;
  279. END;
  280. $$;
  281. -- Test $$ opening quote when is not at the beginning of the line.
  282. CREATE OR REPLACE FUNCTION upd_timestamp() RETURNS TRIGGER
  283. LANGUAGE plpgsql
  284. AS $$
  285. BEGIN
  286. NEW.created_at = CURRENT_TIMESTAMP;
  287. RETURN NEW;
  288. END;
  289. $$;
  290. INSERT INTO users (name, email) VALUES ('This should work as well', 'user2@example.org');
  291. --
  292. -- end test for triggers with $$ syntax
  293. --
  294. CREATE TABLE "composite_pk" (
  295. "group_id" INTEGER NOT NULL,
  296. "id" INTEGER NOT NULL,
  297. "status" VARCHAR NOT NULL,
  298. PRIMARY KEY ("group_id", "id")
  299. );
  300. CREATE TABLE "no_pk" (
  301. "status" VARCHAR NOT NULL
  302. );
  303. CREATE TABLE "order" (
  304. "id" INTEGER NOT NULL PRIMARY KEY,
  305. "name" VARCHAR NOT NULL,
  306. "status" VARCHAR NOT NULL
  307. );
  308. insert into "order"("id","name","status") values (1,'main', 'open');
  309. -- Custom Types
  310. DROP TYPE IF EXISTS composite_type;
  311. CREATE TYPE composite_type AS (
  312. a decimal,
  313. b decimal
  314. );
  315. DROP TYPE IF EXISTS enum_type;
  316. CREATE TYPE enum_type AS ENUM (
  317. 'Mon',
  318. 'Tue',
  319. 'Wed',
  320. 'Thu',
  321. 'Fri',
  322. 'Sat',
  323. 'Sun'
  324. );
  325. DROP TYPE IF EXISTS range_type;
  326. CREATE TYPE range_type AS range (subtype = time);
  327. DROP TYPE IF EXISTS base_type;
  328. CREATE TYPE base_type;
  329. -- --
  330. -- PostgreSQL database dump complete
  331. --