Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. --
  11. -- Name: plpgsql; Type: EXTENSION; Schema: -;
  12. --
  13. CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
  14. --
  15. -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -;
  16. --
  17. COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
  18. --
  19. -- Name: unaccent; Type: EXTENSION; Schema: -;
  20. --
  21. CREATE EXTENSION IF NOT EXISTS unaccent WITH SCHEMA public;
  22. --
  23. -- Name: EXTENSION unaccent; Type: COMMENT; Schema: -;
  24. --
  25. COMMENT ON EXTENSION unaccent IS 'text search dictionary that removes accents';
  26. --
  27. -- Name: uuid-ossp; Type: EXTENSION; Schema: -;
  28. --
  29. CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
  30. --
  31. -- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -;
  32. --
  33. COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
  34. SET search_path = public, pg_catalog;
  35. --
  36. -- Name: get_uuid(); Type: FUNCTION; Schema: public;
  37. --
  38. CREATE FUNCTION get_uuid() RETURNS uuid
  39. LANGUAGE sql
  40. AS $$SELECT * FROM uuid_generate_v1()$$;
  41. --
  42. -- Name: lu_on_row_delete(); Type: FUNCTION; Schema: public;
  43. --
  44. CREATE FUNCTION lu_on_row_delete() RETURNS trigger
  45. LANGUAGE plpgsql
  46. AS $$BEGIN
  47. INSERT INTO lu_entities_history ("table", "data") VALUES(TG_TABLE_NAME, to_json(OLD));
  48. RETURN OLD;
  49. END$$;
  50. --
  51. -- Name: lu_on_row_update(); Type: FUNCTION; Schema: public;
  52. --
  53. CREATE FUNCTION lu_on_row_update() RETURNS trigger
  54. LANGUAGE plpgsql
  55. AS $$BEGIN
  56. NEW.updated_at := now();
  57. INSERT INTO lu_entities_history ("table", "data") VALUES(TG_TABLE_NAME, to_json(OLD));
  58. return NEW;
  59. END$$;
  60. --
  61. -- Name: lu_text_match_prepare(text); Type: FUNCTION; Schema: public; Owner: dev
  62. --
  63. CREATE FUNCTION lu_text_match_prepare(data text) RETURNS text
  64. LANGUAGE sql
  65. AS $$SELECT regexp_replace(unaccent(data), '[^a-zA-Z0-9]+', ' ', 'g')$$;
  66. --
  67. -- Name: lu_text_match(text, text); Type: FUNCTION; Schema: public;
  68. --
  69. CREATE FUNCTION lu_text_match(query text, data text) RETURNS boolean
  70. LANGUAGE sql
  71. AS $$SELECT lu_text_match_prepare(data) ILIKE ('%' || lu_text_match_prepare(query) || '%') AS result$$;
  72. --
  73. -- Name: lu_texts_match(text, text[]); Type: FUNCTION; Schema: public;
  74. --
  75. CREATE FUNCTION lu_texts_match(query text, VARIADIC data text[]) RETURNS boolean
  76. LANGUAGE sql
  77. AS $$
  78. WITH q AS (
  79. SELECT unnest(data) AS d UNION SELECT array_to_string(data, ' ')
  80. )
  81. SELECT lu_text_match(query, d.d) AS res FROM q d ORDER BY res DESC LIMIT 1
  82. $$;
  83. SET default_tablespace = '';
  84. SET default_with_oids = false;
  85. --
  86. -- Name: lu_entities_history; Type: TABLE; Schema: public; ; Tablespace:
  87. --
  88. CREATE TABLE lu_entities_history (
  89. id uuid DEFAULT get_uuid() NOT NULL,
  90. "table" character varying(128) NOT NULL,
  91. data json,
  92. date timestamp with time zone DEFAULT now() NOT NULL
  93. );
  94. --
  95. -- Name: lu_entities_history_pkey; Type: CONSTRAINT; Schema: public; ; Tablespace:
  96. --
  97. ALTER TABLE ONLY lu_entities_history
  98. ADD CONSTRAINT lu_entities_history_pkey PRIMARY KEY (id);
  99. --
  100. -- PostgreSQL database dump complete
  101. --