api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

blog_postgresql.sql 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. --
  2. -- PostgreSQL database dump
  3. --
  4. SET statement_timeout = 0;
  5. SET lock_timeout = 0;
  6. SET client_encoding = 'UTF8';
  7. SET standard_conforming_strings = on;
  8. SET check_function_bodies = false;
  9. SET client_min_messages = warning;
  10. SET search_path = public, pg_catalog;
  11. SET default_tablespace = '';
  12. SET default_with_oids = false;
  13. --
  14. -- Drop everything
  15. --
  16. DROP TABLE IF EXISTS categories CASCADE;
  17. DROP TABLE IF EXISTS comments CASCADE;
  18. DROP TABLE IF EXISTS post_tags CASCADE;
  19. DROP TABLE IF EXISTS posts CASCADE;
  20. DROP TABLE IF EXISTS tags CASCADE;
  21. DROP TABLE IF EXISTS users CASCADE;
  22. DROP TABLE IF EXISTS countries CASCADE;
  23. DROP TABLE IF EXISTS events CASCADE;
  24. DROP VIEW IF EXISTS tag_usage;
  25. DROP TABLE IF EXISTS products CASCADE;
  26. --
  27. -- Name: categories; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  28. --
  29. CREATE TABLE categories (
  30. id serial NOT NULL,
  31. name character varying(255) NOT NULL,
  32. icon bytea
  33. );
  34. --
  35. -- Name: comments; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  36. --
  37. CREATE TABLE comments (
  38. id serial NOT NULL,
  39. post_id integer NOT NULL,
  40. message character varying(255) NOT NULL
  41. );
  42. --
  43. -- Name: post_tags; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  44. --
  45. CREATE TABLE post_tags (
  46. id serial NOT NULL,
  47. post_id integer NOT NULL,
  48. tag_id integer NOT NULL
  49. );
  50. --
  51. -- Name: posts; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  52. --
  53. CREATE TABLE posts (
  54. id serial NOT NULL,
  55. user_id integer NOT NULL,
  56. category_id integer NOT NULL,
  57. content character varying(255) NOT NULL
  58. );
  59. --
  60. -- Name: tags; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  61. --
  62. CREATE TABLE tags (
  63. id serial NOT NULL,
  64. name character varying(255) NOT NULL
  65. );
  66. --
  67. -- Name: users; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  68. --
  69. CREATE TABLE users (
  70. id serial NOT NULL,
  71. username character varying(255) NOT NULL,
  72. password character varying(255) NOT NULL,
  73. location geometry NULL
  74. );
  75. --
  76. -- Name: countries; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  77. --
  78. CREATE TABLE countries (
  79. id serial NOT NULL,
  80. name character varying(255) NOT NULL,
  81. shape geometry NOT NULL
  82. );
  83. --
  84. -- Name: events; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  85. --
  86. CREATE TABLE events (
  87. id serial NOT NULL,
  88. name character varying(255) NOT NULL,
  89. datetime timestamp NOT NULL
  90. );
  91. --
  92. -- Name: tag_usage; Type: VIEW; Schema: public; Owner: postgres; Tablespace:
  93. --
  94. CREATE VIEW "tag_usage" AS select "name", count("name") AS "count" from "tags", "post_tags" where "tags"."id" = "post_tags"."tag_id" group by "name" order by "count" desc, "name";
  95. --
  96. -- Name: products; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  97. --
  98. CREATE TABLE products (
  99. id serial NOT NULL,
  100. name character varying(255) NOT NULL,
  101. price decimal(10,2) NOT NULL
  102. );
  103. --
  104. -- Data for Name: categories; Type: TABLE DATA; Schema: public; Owner: postgres
  105. --
  106. INSERT INTO "categories" ("name", "icon") VALUES
  107. ('announcement', NULL),
  108. ('article', NULL);
  109. --
  110. -- Data for Name: comments; Type: TABLE DATA; Schema: public; Owner: postgres
  111. --
  112. INSERT INTO "comments" ("post_id", "message") VALUES
  113. (1, 'great'),
  114. (1, 'fantastic'),
  115. (2, 'thank you'),
  116. (2, 'awesome');
  117. --
  118. -- Data for Name: post_tags; Type: TABLE DATA; Schema: public; Owner: postgres
  119. --
  120. INSERT INTO "post_tags" ("post_id", "tag_id") VALUES
  121. (1, 1),
  122. (1, 2),
  123. (2, 1),
  124. (2, 2);
  125. --
  126. -- Data for Name: posts; Type: TABLE DATA; Schema: public; Owner: postgres
  127. --
  128. INSERT INTO "posts" ("user_id", "category_id", "content") VALUES
  129. (1, 1, 'blog started'),
  130. (1, 2, 'It works!');
  131. --
  132. -- Data for Name: tags; Type: TABLE DATA; Schema: public; Owner: postgres
  133. --
  134. INSERT INTO "tags" ("name") VALUES
  135. ('funny'),
  136. ('important');
  137. --
  138. -- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
  139. --
  140. INSERT INTO "users" ("username", "password", "location") VALUES
  141. ('user1', 'pass1', NULL),
  142. ('user2', 'pass2', NULL);
  143. --
  144. -- Data for Name: countries; Type: TABLE DATA; Schema: public; Owner: postgres
  145. --
  146. INSERT INTO "countries" ("name", "shape") VALUES
  147. ('Left', ST_GeomFromText('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))')),
  148. ('Right', ST_GeomFromText('POLYGON ((70 10, 80 40, 60 40, 50 20, 70 10))'));
  149. --
  150. -- Data for Name: events; Type: TABLE DATA; Schema: public; Owner: postgres
  151. --
  152. INSERT INTO "events" ("name", "datetime") VALUES
  153. ('Launch', '2016-01-01 13:01:01.111');
  154. --
  155. -- Data for Name: events; Type: TABLE DATA; Schema: public; Owner: postgres
  156. --
  157. INSERT INTO "products" ("name", "price") VALUES
  158. ('Calculator', '23.01');
  159. --
  160. -- Name: categories_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  161. --
  162. ALTER TABLE ONLY categories
  163. ADD CONSTRAINT categories_pkey PRIMARY KEY (id);
  164. --
  165. -- Name: comments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  166. --
  167. ALTER TABLE ONLY comments
  168. ADD CONSTRAINT comments_pkey PRIMARY KEY (id);
  169. --
  170. -- Name: post_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  171. --
  172. ALTER TABLE ONLY post_tags
  173. ADD CONSTRAINT post_tags_pkey PRIMARY KEY (id);
  174. --
  175. -- Name: post_tags_post_id_tag_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  176. --
  177. ALTER TABLE ONLY post_tags
  178. ADD CONSTRAINT post_tags_post_id_tag_id_key UNIQUE (post_id, tag_id);
  179. --
  180. -- Name: posts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  181. --
  182. ALTER TABLE ONLY posts
  183. ADD CONSTRAINT posts_pkey PRIMARY KEY (id);
  184. --
  185. -- Name: tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  186. --
  187. ALTER TABLE ONLY tags
  188. ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
  189. --
  190. -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  191. --
  192. ALTER TABLE ONLY users
  193. ADD CONSTRAINT users_pkey PRIMARY KEY (id);
  194. --
  195. -- Name: countries_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  196. --
  197. ALTER TABLE ONLY countries
  198. ADD CONSTRAINT countries_pkey PRIMARY KEY (id);
  199. --
  200. -- Name: events_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  201. --
  202. ALTER TABLE ONLY events
  203. ADD CONSTRAINT events_pkey PRIMARY KEY (id);
  204. --
  205. -- Name: products_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  206. --
  207. ALTER TABLE ONLY products
  208. ADD CONSTRAINT products_pkey PRIMARY KEY (id);
  209. --
  210. -- Name: comments_post_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  211. --
  212. CREATE INDEX comments_post_id_idx ON comments USING btree (post_id);
  213. --
  214. -- Name: post_tags_post_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  215. --
  216. CREATE INDEX post_tags_post_id_idx ON post_tags USING btree (post_id);
  217. --
  218. -- Name: post_tags_tag_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  219. --
  220. CREATE INDEX post_tags_tag_id_idx ON post_tags USING btree (tag_id);
  221. --
  222. -- Name: posts_category_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  223. --
  224. CREATE INDEX posts_category_id_idx ON posts USING btree (category_id);
  225. --
  226. -- Name: posts_user_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  227. --
  228. CREATE INDEX posts_user_id_idx ON posts USING btree (user_id);
  229. --
  230. -- Name: comments_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  231. --
  232. ALTER TABLE ONLY comments
  233. ADD CONSTRAINT comments_post_id_fkey FOREIGN KEY (post_id) REFERENCES posts(id);
  234. --
  235. -- Name: post_tags_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  236. --
  237. ALTER TABLE ONLY post_tags
  238. ADD CONSTRAINT post_tags_post_id_fkey FOREIGN KEY (post_id) REFERENCES posts(id);
  239. --
  240. -- Name: post_tags_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  241. --
  242. ALTER TABLE ONLY post_tags
  243. ADD CONSTRAINT post_tags_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tags(id);
  244. --
  245. -- Name: posts_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  246. --
  247. ALTER TABLE ONLY posts
  248. ADD CONSTRAINT posts_category_id_fkey FOREIGN KEY (category_id) REFERENCES categories(id);
  249. --
  250. -- Name: posts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  251. --
  252. ALTER TABLE ONLY posts
  253. ADD CONSTRAINT posts_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
  254. --
  255. -- PostgreSQL database dump complete
  256. --