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 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. --
  23. -- Name: categories; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  24. --
  25. CREATE TABLE categories (
  26. id serial NOT NULL,
  27. name character varying(255) NOT NULL,
  28. icon bytea
  29. );
  30. --
  31. -- Name: comments; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  32. --
  33. CREATE TABLE comments (
  34. id serial NOT NULL,
  35. post_id integer NOT NULL,
  36. message character varying(255) NOT NULL
  37. );
  38. --
  39. -- Name: post_tags; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  40. --
  41. CREATE TABLE post_tags (
  42. id serial NOT NULL,
  43. post_id integer NOT NULL,
  44. tag_id integer NOT NULL
  45. );
  46. --
  47. -- Name: posts; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  48. --
  49. CREATE TABLE posts (
  50. id serial NOT NULL,
  51. user_id integer NOT NULL,
  52. category_id integer NOT NULL,
  53. content character varying(255) NOT NULL
  54. );
  55. --
  56. -- Name: tags; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  57. --
  58. CREATE TABLE tags (
  59. id serial NOT NULL,
  60. name character varying(255) NOT NULL
  61. );
  62. --
  63. -- Name: users; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
  64. --
  65. CREATE TABLE users (
  66. id serial NOT NULL,
  67. username character varying(255) NOT NULL,
  68. password character varying(255) NOT NULL
  69. );
  70. --
  71. -- Data for Name: categories; Type: TABLE DATA; Schema: public; Owner: postgres
  72. --
  73. INSERT INTO "categories" ("name", "icon") VALUES
  74. ('anouncement', NULL),
  75. ('article', NULL);
  76. --
  77. -- Data for Name: comments; Type: TABLE DATA; Schema: public; Owner: postgres
  78. --
  79. INSERT INTO "comments" ("post_id", "message") VALUES
  80. (1, 'great'),
  81. (1, 'fantastic'),
  82. (2, 'thank you'),
  83. (2, 'awesome');
  84. --
  85. -- Data for Name: post_tags; Type: TABLE DATA; Schema: public; Owner: postgres
  86. --
  87. INSERT INTO "post_tags" ("post_id", "tag_id") VALUES
  88. (1, 1),
  89. (1, 2),
  90. (2, 1),
  91. (2, 2);
  92. --
  93. -- Data for Name: posts; Type: TABLE DATA; Schema: public; Owner: postgres
  94. --
  95. INSERT INTO "posts" ("user_id", "category_id", "content") VALUES
  96. (1, 1, 'blog started'),
  97. (1, 2, 'It works!');
  98. --
  99. -- Data for Name: tags; Type: TABLE DATA; Schema: public; Owner: postgres
  100. --
  101. INSERT INTO "tags" ("name") VALUES
  102. ('funny'),
  103. ('important');
  104. --
  105. -- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
  106. --
  107. INSERT INTO "users" ("username", "password") VALUES
  108. ('user1', 'pass1'),
  109. ('user2', 'pass2');
  110. --
  111. -- Name: categories_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  112. --
  113. ALTER TABLE ONLY categories
  114. ADD CONSTRAINT categories_pkey PRIMARY KEY (id);
  115. --
  116. -- Name: comments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  117. --
  118. ALTER TABLE ONLY comments
  119. ADD CONSTRAINT comments_pkey PRIMARY KEY (id);
  120. --
  121. -- Name: post_tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  122. --
  123. ALTER TABLE ONLY post_tags
  124. ADD CONSTRAINT post_tags_pkey PRIMARY KEY (id);
  125. --
  126. -- Name: post_tags_post_id_tag_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  127. --
  128. ALTER TABLE ONLY post_tags
  129. ADD CONSTRAINT post_tags_post_id_tag_id_key UNIQUE (post_id, tag_id);
  130. --
  131. -- Name: posts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  132. --
  133. ALTER TABLE ONLY posts
  134. ADD CONSTRAINT posts_pkey PRIMARY KEY (id);
  135. --
  136. -- Name: tags_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  137. --
  138. ALTER TABLE ONLY tags
  139. ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
  140. --
  141. -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
  142. --
  143. ALTER TABLE ONLY users
  144. ADD CONSTRAINT users_pkey PRIMARY KEY (id);
  145. --
  146. -- Name: comments_post_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  147. --
  148. CREATE INDEX comments_post_id_idx ON comments USING btree (post_id);
  149. --
  150. -- Name: post_tags_post_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  151. --
  152. CREATE INDEX post_tags_post_id_idx ON post_tags USING btree (post_id);
  153. --
  154. -- Name: post_tags_tag_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  155. --
  156. CREATE INDEX post_tags_tag_id_idx ON post_tags USING btree (tag_id);
  157. --
  158. -- Name: posts_category_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  159. --
  160. CREATE INDEX posts_category_id_idx ON posts USING btree (category_id);
  161. --
  162. -- Name: posts_user_id_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
  163. --
  164. CREATE INDEX posts_user_id_idx ON posts USING btree (user_id);
  165. --
  166. -- Name: comments_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  167. --
  168. ALTER TABLE ONLY comments
  169. ADD CONSTRAINT comments_post_id_fkey FOREIGN KEY (post_id) REFERENCES posts(id);
  170. --
  171. -- Name: post_tags_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  172. --
  173. ALTER TABLE ONLY post_tags
  174. ADD CONSTRAINT post_tags_post_id_fkey FOREIGN KEY (post_id) REFERENCES posts(id);
  175. --
  176. -- Name: post_tags_tag_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  177. --
  178. ALTER TABLE ONLY post_tags
  179. ADD CONSTRAINT post_tags_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tags(id);
  180. --
  181. -- Name: posts_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  182. --
  183. ALTER TABLE ONLY posts
  184. ADD CONSTRAINT posts_category_id_fkey FOREIGN KEY (category_id) REFERENCES categories(id);
  185. --
  186. -- Name: posts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
  187. --
  188. ALTER TABLE ONLY posts
  189. ADD CONSTRAINT posts_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
  190. --
  191. -- PostgreSQL database dump complete
  192. --