test: Reorganize test/ folder into one subdirectory for each test type
This commit is contained in:
committed by
Wolfgang Walther
parent
8060fe3559
commit
8b63d928ae
Vendored
+732
@@ -0,0 +1,732 @@
|
||||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 9.5beta1
|
||||
-- Dumped by pg_dump version 9.5beta1
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SET check_function_bodies = false;
|
||||
SET client_min_messages = warning;
|
||||
|
||||
SET search_path = postgrest, pg_catalog;
|
||||
|
||||
--
|
||||
-- Data for Name: auth; Type: TABLE DATA; Schema: postgrest; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE auth CASCADE;
|
||||
INSERT INTO auth VALUES ('jdoe', 'postgrest_test_author', '1234 ');
|
||||
|
||||
|
||||
SET search_path = private, pg_catalog;
|
||||
|
||||
--
|
||||
-- Data for Name: articles; Type: TABLE DATA; Schema: private; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE articles CASCADE;
|
||||
INSERT INTO articles VALUES (1, 'No… It''s a thing; it''s like a plan, but with more greatness.', 'diogo');
|
||||
INSERT INTO articles VALUES (2, 'Stop talking, brain thinking. Hush.', 'diogo');
|
||||
INSERT INTO articles VALUES (3, 'It''s a fez. I wear a fez now. Fezes are cool.', 'diogo');
|
||||
|
||||
|
||||
SET search_path = test, pg_catalog;
|
||||
|
||||
--
|
||||
-- Data for Name: users; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE users CASCADE;
|
||||
INSERT INTO users VALUES (1, 'Angela Martin');
|
||||
INSERT INTO users VALUES (2, 'Michael Scott');
|
||||
INSERT INTO users VALUES (3, 'Dwight Schrute');
|
||||
|
||||
|
||||
SET search_path = private, pg_catalog;
|
||||
|
||||
--
|
||||
-- Data for Name: article_stars; Type: TABLE DATA; Schema: private; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE article_stars CASCADE;
|
||||
INSERT INTO article_stars VALUES (1, 1, '2015-12-08 04:22:57.472738');
|
||||
INSERT INTO article_stars VALUES (1, 2, '2015-12-08 04:22:57.472738');
|
||||
INSERT INTO article_stars VALUES (2, 3, '2015-12-08 04:22:57.472738');
|
||||
INSERT INTO article_stars VALUES (3, 2, '2015-12-08 04:22:57.472738');
|
||||
INSERT INTO article_stars VALUES (1, 3, '2015-12-08 04:22:57.472738');
|
||||
|
||||
|
||||
SET search_path = test, pg_catalog;
|
||||
|
||||
--
|
||||
-- Data for Name: authors_only; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
TRUNCATE TABLE authors_only CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: auto_incrementing_pk; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
TRUNCATE TABLE auto_incrementing_pk CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: auto_incrementing_pk_id_seq; Type: SEQUENCE SET; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('auto_incrementing_pk_id_seq', 1, true);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: clients; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE clients CASCADE;
|
||||
INSERT INTO clients VALUES (1, 'Microsoft');
|
||||
INSERT INTO clients VALUES (2, 'Apple');
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: projects; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE projects CASCADE;
|
||||
INSERT INTO projects VALUES (1, 'Windows 7', 1);
|
||||
INSERT INTO projects VALUES (2, 'Windows 10', 1);
|
||||
INSERT INTO projects VALUES (3, 'IOS', 2);
|
||||
INSERT INTO projects VALUES (4, 'OSX', 2);
|
||||
INSERT INTO projects VALUES (5, 'Orphan', NULL);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: tasks; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE tasks CASCADE;
|
||||
INSERT INTO tasks VALUES (1, 'Design w7', 1);
|
||||
INSERT INTO tasks VALUES (2, 'Code w7', 1);
|
||||
INSERT INTO tasks VALUES (3, 'Design w10', 2);
|
||||
INSERT INTO tasks VALUES (4, 'Code w10', 2);
|
||||
INSERT INTO tasks VALUES (5, 'Design IOS', 3);
|
||||
INSERT INTO tasks VALUES (6, 'Code IOS', 3);
|
||||
INSERT INTO tasks VALUES (7, 'Design OSX', 4);
|
||||
INSERT INTO tasks VALUES (8, 'Code OSX', 4);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: users_tasks; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE users_tasks CASCADE;
|
||||
INSERT INTO users_tasks VALUES (1, 1);
|
||||
INSERT INTO users_tasks VALUES (1, 2);
|
||||
INSERT INTO users_tasks VALUES (1, 3);
|
||||
INSERT INTO users_tasks VALUES (1, 4);
|
||||
INSERT INTO users_tasks VALUES (2, 5);
|
||||
INSERT INTO users_tasks VALUES (2, 6);
|
||||
INSERT INTO users_tasks VALUES (2, 7);
|
||||
INSERT INTO users_tasks VALUES (3, 1);
|
||||
INSERT INTO users_tasks VALUES (3, 5);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: comments; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE comments CASCADE;
|
||||
INSERT INTO comments VALUES (1, 1, 2, 6, 'Needs to be delivered ASAP');
|
||||
|
||||
--
|
||||
-- Data for Name: files; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE files CASCADE;
|
||||
INSERT INTO files VALUES
|
||||
(1, 'command.com', '#include <unix.h>')
|
||||
,(1, 'autoexec.bat', '@ECHO OFF')
|
||||
,(1, 'io.sys', 'TODO')
|
||||
,(2, 'README.md', '# make $$$!')
|
||||
,(2, 'marketing.key', '$-$')
|
||||
;
|
||||
|
||||
TRUNCATE TABLE touched_files CASCADE;
|
||||
INSERT INTO touched_files VALUES
|
||||
(1, 1, 1, 'command.com')
|
||||
,(1, 1, 1, 'autoexec.bat')
|
||||
,(1, 1, 2, 'README.md')
|
||||
,(3, 1, 1, 'autoexec.bat')
|
||||
;
|
||||
|
||||
--
|
||||
-- Data for Name: complex_items; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE complex_items CASCADE;
|
||||
INSERT INTO complex_items VALUES (1, 'One', '{"foo":{"int":1,"bar":"baz"}}', '{1}');
|
||||
INSERT INTO complex_items VALUES (2, 'Two', '{"foo":{"int":1,"bar":"baz"}}', '{1,2}');
|
||||
INSERT INTO complex_items VALUES (3, 'Three', '{"foo":{"int":1,"bar":"baz"}}', '{1,2,3}');
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: compound_pk; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
TRUNCATE TABLE compound_pk CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: simple_pk; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE simple_pk CASCADE;
|
||||
INSERT INTO simple_pk VALUES ('xyyx', 'u');
|
||||
INSERT INTO simple_pk VALUES ('xYYx', 'v');
|
||||
|
||||
--
|
||||
-- Data for Name: has_fk; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
TRUNCATE TABLE has_fk CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: has_fk_id_seq; Type: SEQUENCE SET; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('has_fk_id_seq', 1, false);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: items; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE items CASCADE;
|
||||
INSERT INTO items VALUES (1);
|
||||
INSERT INTO items VALUES (2);
|
||||
INSERT INTO items VALUES (3);
|
||||
INSERT INTO items VALUES (4);
|
||||
INSERT INTO items VALUES (5);
|
||||
INSERT INTO items VALUES (6);
|
||||
INSERT INTO items VALUES (7);
|
||||
INSERT INTO items VALUES (8);
|
||||
INSERT INTO items VALUES (9);
|
||||
INSERT INTO items VALUES (10);
|
||||
INSERT INTO items VALUES (11);
|
||||
INSERT INTO items VALUES (12);
|
||||
INSERT INTO items VALUES (13);
|
||||
INSERT INTO items VALUES (14);
|
||||
INSERT INTO items VALUES (15);
|
||||
|
||||
|
||||
--
|
||||
-- Name: items_id_seq; Type: SEQUENCE SET; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('items_id_seq', 15, true);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: items2; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE items2 CASCADE;
|
||||
INSERT INTO items2 VALUES (1);
|
||||
INSERT INTO items2 VALUES (2);
|
||||
INSERT INTO items2 VALUES (3);
|
||||
INSERT INTO items2 VALUES (4);
|
||||
INSERT INTO items2 VALUES (5);
|
||||
INSERT INTO items2 VALUES (6);
|
||||
INSERT INTO items2 VALUES (7);
|
||||
INSERT INTO items2 VALUES (8);
|
||||
INSERT INTO items2 VALUES (9);
|
||||
INSERT INTO items2 VALUES (10);
|
||||
INSERT INTO items2 VALUES (11);
|
||||
INSERT INTO items2 VALUES (12);
|
||||
INSERT INTO items2 VALUES (13);
|
||||
INSERT INTO items2 VALUES (14);
|
||||
INSERT INTO items2 VALUES (15);
|
||||
|
||||
|
||||
--
|
||||
-- Name: items_id_seq; Type: SEQUENCE SET; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('items2_id_seq', 15, true);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: json_table; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE json_table CASCADE;
|
||||
INSERT INTO json_table VALUES ('{"foo":{"bar":"baz"},"id":1}');
|
||||
INSERT INTO json_table VALUES ('{"id":3}');
|
||||
INSERT INTO json_table VALUES ('{"id":0}');
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: menagerie; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
TRUNCATE TABLE menagerie CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: no_pk; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE no_pk CASCADE;
|
||||
INSERT INTO no_pk VALUES (NULL, NULL);
|
||||
INSERT INTO no_pk VALUES ('1', '0');
|
||||
INSERT INTO no_pk VALUES ('2', '0');
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: nullable_integer; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE nullable_integer CASCADE;
|
||||
INSERT INTO nullable_integer VALUES (NULL);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: tsearch; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE tsearch CASCADE;
|
||||
INSERT INTO tsearch VALUES (to_tsvector('It''s kind of fun to do the impossible'));
|
||||
INSERT INTO tsearch VALUES (to_tsvector('But also fun to do what is possible'));
|
||||
INSERT INTO tsearch VALUES (to_tsvector('Fat cats ate rats'));
|
||||
INSERT INTO tsearch VALUES (to_tsvector('french', 'C''est un peu amusant de faire l''impossible'));
|
||||
INSERT INTO tsearch VALUES (to_tsvector('german', 'Es ist eine Art Spaß, das Unmögliche zu machen'));
|
||||
|
||||
--
|
||||
-- Data for Name: users_projects; Type: TABLE DATA; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
TRUNCATE TABLE users_projects CASCADE;
|
||||
INSERT INTO users_projects VALUES (1, 1);
|
||||
INSERT INTO users_projects VALUES (1, 2);
|
||||
INSERT INTO users_projects VALUES (2, 3);
|
||||
INSERT INTO users_projects VALUES (2, 4);
|
||||
INSERT INTO users_projects VALUES (3, 1);
|
||||
INSERT INTO users_projects VALUES (3, 3);
|
||||
|
||||
TRUNCATE TABLE "Escap3e;" CASCADE;
|
||||
INSERT INTO "Escap3e;" VALUES (1), (2), (3), (4), (5);
|
||||
|
||||
TRUNCATE TABLE "ghostBusters" CASCADE;
|
||||
INSERT INTO "ghostBusters" VALUES (1), (3), (5);
|
||||
|
||||
TRUNCATE TABLE "withUnique" CASCADE;
|
||||
INSERT INTO "withUnique" VALUES ('nodup', 'blah');
|
||||
|
||||
|
||||
|
||||
TRUNCATE TABLE addresses CASCADE;
|
||||
INSERT INTO addresses VALUES (1, 'address 1');
|
||||
INSERT INTO addresses VALUES (2, 'address 2');
|
||||
INSERT INTO addresses VALUES (3, 'address 3');
|
||||
INSERT INTO addresses VALUES (4, 'address 4');
|
||||
|
||||
TRUNCATE TABLE orders CASCADE;
|
||||
INSERT INTO orders VALUES (1, 'order 1', 1, 2);
|
||||
INSERT INTO orders VALUES (2, 'order 2', 3, 4);
|
||||
|
||||
TRUNCATE TABLE images CASCADE;
|
||||
INSERT INTO images(name, img) VALUES ('A.png', decode('iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeAQMAAAAB/jzhAAAABlBMVEUAAAD/AAAb/40iAAAAP0lEQVQI12NgwAbYG2AE/wEYwQMiZB4ACQkQYZEAIgqAhAGIKLCAEQ8kgMT/P1CCEUwc4IMSzA3sUIIdCHECAGSQEkeOTUyCAAAAAElFTkSuQmCC', 'base64'));
|
||||
INSERT INTO images(name, img) VALUES ('B.png', decode('iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeAQMAAAAB/jzhAAAABlBMVEX///8AAP94wDzzAAAAL0lEQVQIW2NgwAb+HwARH0DEDyDxwAZEyGAhLODqHmBRzAcn5GAS///A1IF14AAA5/Adbiiz/0gAAAAASUVORK5CYII=', 'base64'));
|
||||
|
||||
TRUNCATE TABLE w_or_wo_comma_names CASCADE;
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('Hebdon, John');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('Williams, Mary');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('Smith, Joseph');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('David White');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('Larry Thompson');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('Double O Seven(007)');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('"');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('Double"Quote"McGraw"');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('\');
|
||||
INSERT INTO w_or_wo_comma_names VALUES ('/\Slash/\Beast/\');
|
||||
|
||||
TRUNCATE TABLE items_with_different_col_types CASCADE;
|
||||
INSERT INTO items_with_different_col_types VALUES (1, null, null, null, null, null, null, null);
|
||||
|
||||
TRUNCATE TABLE entities CASCADE;
|
||||
INSERT INTO entities VALUES (1, 'entity 1', '{1}', '''bar'':2 ''foo'':1');
|
||||
INSERT INTO entities VALUES (2, 'entity 2', '{1,2}', '''baz'':1 ''qux'':2');
|
||||
INSERT INTO entities VALUES (3, 'entity 3', '{1,2,3}', null);
|
||||
INSERT INTO entities VALUES (4, null, null, null);
|
||||
|
||||
TRUNCATE TABLE child_entities CASCADE;
|
||||
INSERT INTO child_entities VALUES (1, 'child entity 1', 1);
|
||||
INSERT INTO child_entities VALUES (2, 'child entity 2', 1);
|
||||
INSERT INTO child_entities VALUES (3, 'child entity 3', 2);
|
||||
INSERT INTO child_entities VALUES (4, 'child entity 4', 1);
|
||||
INSERT INTO child_entities VALUES (5, 'child entity 5', 1);
|
||||
INSERT INTO child_entities VALUES (6, 'child entity 6', 2);
|
||||
|
||||
TRUNCATE TABLE grandchild_entities CASCADE;
|
||||
INSERT INTO grandchild_entities VALUES (1, 'grandchild entity 1', 1, null, null, null);
|
||||
INSERT INTO grandchild_entities VALUES (2, 'grandchild entity 2', 1, null, null, null);
|
||||
INSERT INTO grandchild_entities VALUES (3, 'grandchild entity 3', 2, null, null, null);
|
||||
INSERT INTO grandchild_entities VALUES (4, '(grandchild,entity,4)', 2, null, null, '{"a": {"b":"foo"}}');
|
||||
INSERT INTO grandchild_entities VALUES (5, '(grandchild,entity,5)', 2, null, null, '{"b":"bar"}');
|
||||
|
||||
TRUNCATE TABLE ranges CASCADE;
|
||||
INSERT INTO ranges VALUES (1, '[1,3]');
|
||||
INSERT INTO ranges VALUES (2, '[3,6]');
|
||||
INSERT INTO ranges VALUES (3, '[6,9]');
|
||||
INSERT INTO ranges VALUES (4, '[9,12]');
|
||||
|
||||
TRUNCATE TABLE being CASCADE;
|
||||
INSERT INTO being VALUES (1), (2), (3), (4);
|
||||
|
||||
TRUNCATE TABLE descendant CASCADE;
|
||||
INSERT INTO descendant VALUES (1,1), (2,1), (3,1), (4,2);
|
||||
|
||||
TRUNCATE TABLE part CASCADE;
|
||||
INSERT INTO part VALUES (1), (2), (3), (4);
|
||||
|
||||
TRUNCATE TABLE being_part CASCADE;
|
||||
INSERT INTO being_part VALUES (1,1), (2,1), (3,2), (4,3);
|
||||
|
||||
TRUNCATE TABLE employees CASCADE;
|
||||
INSERT INTO employees VALUES
|
||||
('Frances M.', 'Roe', '24000', 'One-Up Realty', 'Author'),
|
||||
('Daniel B.', 'Lyon', '36000', 'Dubrow''s Cafeteria', 'Packer'),
|
||||
('Edwin S.', 'Smith', '48000', 'Pro Garden Management', 'Marine biologist');
|
||||
|
||||
TRUNCATE TABLE tiobe_pls CASCADE;
|
||||
INSERT INTO tiobe_pls VALUES ('Java', 1), ('C', 2), ('Python', 4);
|
||||
|
||||
TRUNCATE TABLE single_unique CASCADE;
|
||||
INSERT INTO single_unique (unique_key, value) VALUES (1, 'A');
|
||||
|
||||
TRUNCATE TABLE compound_unique CASCADE;
|
||||
INSERT INTO compound_unique (key1, key2, value) VALUES (1, 1, 'A');
|
||||
|
||||
TRUNCATE TABLE only_pk CASCADE;
|
||||
INSERT INTO only_pk VALUES (1), (2);
|
||||
|
||||
TRUNCATE TABLE family_tree CASCADE;
|
||||
INSERT INTO family_tree VALUES ('1', 'Parental Unit', NULL);
|
||||
INSERT INTO family_tree VALUES ('2', 'Kid One', '1');
|
||||
INSERT INTO family_tree VALUES ('3', 'Kid Two', '1');
|
||||
INSERT INTO family_tree VALUES ('4', 'Grandkid One', '2');
|
||||
INSERT INTO family_tree VALUES ('5', 'Grandkid Two', '3');
|
||||
|
||||
TRUNCATE TABLE managers CASCADE;
|
||||
INSERT INTO managers VALUES (1, 'Referee Manager');
|
||||
INSERT INTO managers VALUES (2, 'Auditor Manager');
|
||||
INSERT INTO managers VALUES (3, 'Acme Manager');
|
||||
INSERT INTO managers VALUES (4, 'Umbrella Manager');
|
||||
INSERT INTO managers VALUES (5, 'Cyberdyne Manager');
|
||||
INSERT INTO managers VALUES (6, 'Oscorp Manager');
|
||||
|
||||
TRUNCATE TABLE organizations CASCADE;
|
||||
INSERT INTO organizations VALUES (1, 'Referee Org', null, null, 1);
|
||||
INSERT INTO organizations VALUES (2, 'Auditor Org', null, null, 2);
|
||||
INSERT INTO organizations VALUES (3, 'Acme', 1, 2, 3);
|
||||
INSERT INTO organizations VALUES (4, 'Umbrella', 1, 2, 4);
|
||||
INSERT INTO organizations VALUES (5, 'Cyberdyne', 3, 4, 5);
|
||||
INSERT INTO organizations VALUES (6, 'Oscorp', 3, 4, 6);
|
||||
|
||||
SET search_path = private, pg_catalog;
|
||||
|
||||
TRUNCATE TABLE authors CASCADE;
|
||||
INSERT INTO authors VALUES (1, 'George Orwell');
|
||||
INSERT INTO authors VALUES (2, 'Anne Frank');
|
||||
INSERT INTO authors VALUES (3, 'Antoine de Saint-Exupéry');
|
||||
INSERT INTO authors VALUES (4, 'J.D. Salinger');
|
||||
INSERT INTO authors VALUES (5, 'Ray Bradbury');
|
||||
INSERT INTO authors VALUES (6, 'William Golding');
|
||||
INSERT INTO authors VALUES (7, 'Harper Lee');
|
||||
INSERT INTO authors VALUES (8, 'Kurt Vonnegut');
|
||||
INSERT INTO authors VALUES (9, 'Ken Kesey');
|
||||
|
||||
TRUNCATE TABLE publishers CASCADE;
|
||||
INSERT INTO publishers VALUES (1, 'Secker & Warburg');
|
||||
INSERT INTO publishers VALUES (2, 'Contact Publishing');
|
||||
INSERT INTO publishers VALUES (3, 'Reynal & Hitchcock');
|
||||
INSERT INTO publishers VALUES (4, 'Little, Brown and Company');
|
||||
INSERT INTO publishers VALUES (5, 'Ballantine Books');
|
||||
INSERT INTO publishers VALUES (6, 'Faber and Faber');
|
||||
INSERT INTO publishers VALUES (7, 'J. B. Lippincott & Co.');
|
||||
INSERT INTO publishers VALUES (8, 'Delacorte');
|
||||
INSERT INTO publishers VALUES (9, 'Viking Press & Signet Books');
|
||||
|
||||
TRUNCATE TABLE books CASCADE;
|
||||
INSERT INTO books VALUES (1, '1984', 1949, 1, 1);
|
||||
INSERT INTO books VALUES (2, 'The Diary of a Young Girl', 1947, 2, 2);
|
||||
INSERT INTO books VALUES (3, 'The Little Prince', 1947, 3, 3);
|
||||
INSERT INTO books VALUES (4, 'The Catcher in the Rye', 1951, 4, 4);
|
||||
INSERT INTO books VALUES (5, 'Farenheit 451', 1953, 5, 5);
|
||||
INSERT INTO books VALUES (6, 'Lord of the Flies', 1954, 6, 6);
|
||||
INSERT INTO books VALUES (7, 'To Kill a Mockingbird', 1960, 7, 7);
|
||||
INSERT INTO books VALUES (8, 'Slaughterhouse-Five', 1969, 8, 8);
|
||||
INSERT INTO books VALUES (9, 'One Flew Over the Cuckoo''s Nest', 1962, 9, 9);
|
||||
|
||||
SET search_path = test, pg_catalog;
|
||||
|
||||
TRUNCATE TABLE person CASCADE;
|
||||
|
||||
INSERT INTO person VALUES (1, 'John');
|
||||
INSERT INTO person VALUES (2, 'Jane');
|
||||
INSERT INTO person VALUES (3, 'Jake');
|
||||
INSERT INTO person VALUES (4, 'Julie');
|
||||
|
||||
TRUNCATE TABLE message CASCADE;
|
||||
INSERT INTO message VALUES (1, 'Hello Jane', 1, 2);
|
||||
INSERT INTO message VALUES (2, 'Hi John', 2, 1);
|
||||
INSERT INTO message VALUES (3, 'How are you doing?', 1, 2);
|
||||
INSERT INTO message VALUES (4, 'Hey Julie', 3, 4);
|
||||
INSERT INTO message VALUES (5, 'What''s up Jake', 4, 3);
|
||||
|
||||
TRUNCATE TABLE space CASCADE;
|
||||
INSERT INTO space VALUES (1, 'space 1');
|
||||
|
||||
TRUNCATE TABLE zone CASCADE;
|
||||
INSERT INTO zone VALUES (1, 'zone 1', 2, 1);
|
||||
INSERT INTO zone VALUES (2, 'zone 2', 2, 1);
|
||||
INSERT INTO zone VALUES (3, 'store 3', 3, 1);
|
||||
INSERT INTO zone VALUES (4, 'store 4', 3, 1);
|
||||
|
||||
-- for foreign table projects_dump
|
||||
copy (select id, name, client_id from projects) to '/tmp/projects_dump.csv' with csv;
|
||||
|
||||
TRUNCATE TABLE "UnitTest" CASCADE;
|
||||
INSERT INTO "UnitTest" VALUES (1, 'unit test 1');
|
||||
|
||||
TRUNCATE TABLE json_arr CASCADE;
|
||||
INSERT INTO json_arr VALUES (1, '[1, 2, 3]');
|
||||
INSERT INTO json_arr VALUES (2, '[4, 5, 6]');
|
||||
INSERT INTO json_arr VALUES (3, '[[9, 8, 7], [11, 12, 13]]');
|
||||
INSERT INTO json_arr VALUES (4, '[[[5, 6], 7, 8]]');
|
||||
INSERT INTO json_arr VALUES (5, '[{"a": "A"}, {"b": "B"}]');
|
||||
INSERT INTO json_arr VALUES (6, '[{"a": [1,2,3]}, {"b": [4,5]}]');
|
||||
INSERT INTO json_arr VALUES (7, '{"c": [1,2,3], "d": [4,5]}');
|
||||
INSERT INTO json_arr VALUES (8, '{"c": [{"d": [4,5,6,7,8]}]}');
|
||||
INSERT INTO json_arr VALUES (9, '[{"0xy1": [1,{"23-xy-45": [2, {"xy-6": [3]}]}]}]');
|
||||
|
||||
TRUNCATE TABLE jsonb_test CASCADE;
|
||||
INSERT INTO jsonb_test VALUES (1, '{ "a": {"b": 2} }');
|
||||
INSERT INTO jsonb_test VALUES (2, '{ "c": [1,2,3] }');
|
||||
INSERT INTO jsonb_test VALUES (3, '[{ "d": "test" }]');
|
||||
INSERT INTO jsonb_test VALUES (4, '{ "e": 1 }');
|
||||
|
||||
TRUNCATE TABLE private.player CASCADE;
|
||||
INSERT into private.player
|
||||
SELECT
|
||||
generate_series,
|
||||
'first_name_' || generate_series,
|
||||
'last_name_' || generate_series,
|
||||
'2018-10-11'
|
||||
FROM generate_series(1, 12);
|
||||
|
||||
TRUNCATE TABLE contract CASCADE;
|
||||
insert into contract
|
||||
select
|
||||
'tournament_' || generate_series,
|
||||
tsrange(now()::timestamp, null),
|
||||
10*generate_series,
|
||||
generate_series,
|
||||
'first_name_' || generate_series,
|
||||
'last_name_' || generate_series,
|
||||
'2018-10-11'
|
||||
from generate_series(1, 6);
|
||||
|
||||
TRUNCATE TABLE ltree_sample CASCADE;
|
||||
INSERT INTO ltree_sample VALUES ('Top');
|
||||
INSERT INTO ltree_sample VALUES ('Top.Science');
|
||||
INSERT INTO ltree_sample VALUES ('Top.Science.Astronomy');
|
||||
INSERT INTO ltree_sample VALUES ('Top.Science.Astronomy.Astrophysics');
|
||||
INSERT INTO ltree_sample VALUES ('Top.Science.Astronomy.Cosmology');
|
||||
|
||||
TRUNCATE TABLE isn_sample CASCADE;
|
||||
INSERT INTO isn_sample VALUES ('978-0-393-04002-9', 'Mathematics: From the Birth of Numbers');
|
||||
|
||||
TRUNCATE TABLE "Server Today" CASCADE;
|
||||
COPY "Server Today" ("cHostname", "Just A Server Model") FROM STDIN CSV DELIMITER '|';
|
||||
argnim1 | IBM,9113-550 (P5-550)
|
||||
argnim2 | IBM,9113-550 (P5-550)
|
||||
daaa2nim71 | IBM,9131-52A (P5-52A)
|
||||
daah3nim71 | IBM,8406-71Y (P7-PS701)
|
||||
hbnim1 | IBM,9133-55A (P5-55A)
|
||||
\.
|
||||
|
||||
TRUNCATE TABLE pgrst_reserved_chars CASCADE;
|
||||
COPY pgrst_reserved_chars ("*id*", ":arr->ow::cast", "(inside,parens)", "a.dotted.column", " col w space ") FROM STDIN CSV DELIMITER '|';
|
||||
1 | arrow-1 | parens-1 | dotted-1 | space-1
|
||||
2 | arrow-2 | parens-2 | dotted-2 | space-2
|
||||
3 | arrow-3 | parens-3 | dotted-3 | space-3
|
||||
\.
|
||||
|
||||
TRUNCATE TABLE web_content CASCADE;
|
||||
INSERT INTO web_content VALUES (5, 'wat', null);
|
||||
INSERT INTO web_content VALUES (0, 'tardis', 5);
|
||||
INSERT INTO web_content VALUES (1, 'fezz', 0);
|
||||
INSERT INTO web_content VALUES (2, 'foo', 0);
|
||||
INSERT INTO web_content VALUES (3, 'bar', 0);
|
||||
INSERT INTO web_content VALUES (4, 'wut', 1);
|
||||
|
||||
TRUNCATE TABLE app_users CASCADE;
|
||||
INSERT INTO app_users (id, email, "password") VALUES (1, 'test@123.com','pass');
|
||||
INSERT INTO app_users (id, email, "password") VALUES (2, 'abc@123.com','pass');
|
||||
INSERT INTO app_users (id, email, "password") VALUES (3, 'def@123.com','pass');
|
||||
|
||||
TRUNCATE TABLE private.pages CASCADE;
|
||||
INSERT INTO private.pages VALUES (1, 'http://postgrest.org/en/v6.0/api.html');
|
||||
INSERT INTO private.pages VALUES (2, 'http://postgrest.org/en/v6.0/admin.html');
|
||||
|
||||
TRUNCATE TABLE private.referrals CASCADE;
|
||||
INSERT INTO private.referrals VALUES ('github.com', 1);
|
||||
INSERT INTO private.referrals VALUES ('hub.docker.com', 2);
|
||||
|
||||
TRUNCATE TABLE big_projects CASCADE;
|
||||
INSERT INTO big_projects (big_project_id, name)
|
||||
VALUES (1, 'big project 1'),
|
||||
(2, 'big project 2');
|
||||
|
||||
TRUNCATE TABLE sites CASCADE;
|
||||
INSERT INTO sites (site_id, name, main_project_id)
|
||||
VALUES (1, 'site 1', 1),
|
||||
(2, 'site 2', null),
|
||||
(3, 'site 3', 2),
|
||||
(4, 'site 4', null);
|
||||
|
||||
TRUNCATE TABLE jobs CASCADE;
|
||||
INSERT INTO jobs (job_id, name, site_id, big_project_id)
|
||||
VALUES ('bc5d5362-b881-438f-b9f5-7417e08704ed', 'job 1-1', 1, 1),
|
||||
('3bd52697-033b-4edd-8a28-46a9c04b7c1e', 'job 2-1', 2, 1),
|
||||
('e6e67e4e-19b1-11e9-ab14-d663bd873d93', 'job 2-2', 2, 2);
|
||||
|
||||
TRUNCATE TABLE departments CASCADE;
|
||||
TRUNCATE TABLE agents CASCADE;
|
||||
INSERT INTO agents (id, name)
|
||||
VALUES (1, 'agent 1'),
|
||||
(2, 'agent 2'),
|
||||
(3, 'agent 3'),
|
||||
(4, 'agent 4');
|
||||
|
||||
INSERT INTO departments (id, name, head_id)
|
||||
VALUES (1, 'dep 1', 1),
|
||||
(2, 'dep 3', 3);
|
||||
|
||||
UPDATE agents SET department_id = 1 WHERE id in (1, 2);
|
||||
UPDATE agents SET department_id = 2 WHERE id in (3, 4);
|
||||
|
||||
TRUNCATE TABLE schedules CASCADE;
|
||||
INSERT INTO schedules VALUES(1, 'morning', '06:00:00', '11:59:00');
|
||||
INSERT INTO schedules VALUES(2, 'afternoon', '12:00:00', '17:59:00');
|
||||
INSERT INTO schedules VALUES(3, 'night', '18:00:00', '23:59:00');
|
||||
INSERT INTO schedules VALUES(4, 'early morning', '00:00:00', '05:59:00');
|
||||
|
||||
TRUNCATE TABLE activities CASCADE;
|
||||
INSERT INTO activities(id, schedule_id, car_id) VALUES(1, 1, 'CAR-349');
|
||||
INSERT INTO activities(id, schedule_id, camera_id) VALUES(2, 3, 'CAM-123');
|
||||
|
||||
TRUNCATE TABLE unit_workdays CASCADE;
|
||||
INSERT INTO unit_workdays VALUES(1, '2019-12-02', 1, 1, 2, 3);
|
||||
|
||||
TRUNCATE TABLE v1.parents CASCADE;
|
||||
INSERT INTO v1.parents VALUES(1, 'parent v1-1'), (2, 'parent v1-2');
|
||||
|
||||
TRUNCATE TABLE v1.children CASCADE;
|
||||
INSERT INTO v1.children VALUES(1, 'child v1-1', 1), (2, 'child v1-2', 2);
|
||||
|
||||
TRUNCATE TABLE v2.parents CASCADE;
|
||||
INSERT INTO v2.parents VALUES(3, 'parent v2-3'), (4, 'parent v2-4');
|
||||
|
||||
TRUNCATE TABLE v2.children CASCADE;
|
||||
INSERT INTO v2.children VALUES(1, 'child v2-3', 3);
|
||||
|
||||
TRUNCATE TABLE v2.another_table CASCADE;
|
||||
INSERT INTO v2.another_table VALUES(5, 'value 5'), (6, 'value 6');
|
||||
|
||||
TRUNCATE TABLE private.stuff CASCADE;
|
||||
INSERT INTO private.stuff (id, name) VALUES (1, 'stuff 1');
|
||||
|
||||
TRUNCATE TABLE private.screens CASCADE;
|
||||
INSERT INTO private.screens(name) VALUES ('banana'), ('helicopter'), ('formula 1 banana');
|
||||
|
||||
INSERT INTO private.labels(name) VALUES ('vehicles'), ('fruit');
|
||||
|
||||
INSERT INTO private.label_screen(label_id, screen_id) VALUES
|
||||
((SELECT id FROM labels WHERE name='vehicles'), (SELECT id FROM screens WHERE name='helicopter')),
|
||||
((SELECT id FROM labels WHERE name='vehicles'), (SELECT id FROM screens WHERE name='formula 1 banana')),
|
||||
((SELECT id FROM labels WHERE name='fruit'), (SELECT id FROM screens WHERE name='banana')),
|
||||
((SELECT id FROM labels WHERE name='fruit'), (SELECT id FROM screens WHERE name='formula 1 banana'));
|
||||
|
||||
TRUNCATE TABLE private.actors CASCADE;
|
||||
INSERT INTO private.actors (id, name) VALUES (1,'john'), (2,'mary');
|
||||
|
||||
TRUNCATE TABLE private.films CASCADE;
|
||||
INSERT INTO private.films (id, title) VALUES (12,'douze commandements'), (2001,'odyssée de l''espace');
|
||||
|
||||
TRUNCATE TABLE private.personnages CASCADE;
|
||||
INSERT INTO private.personnages (film_id, role_id, character) VALUES (12,1,'méchant'), (2001,2,'astronaute');
|
||||
|
||||
DO $do$BEGIN
|
||||
IF (SELECT current_setting('server_version_num')::INT >= 100000) THEN
|
||||
INSERT INTO test.car_models(name, year) VALUES ('DeLorean',1981);
|
||||
INSERT INTO test.car_models(name, year) VALUES ('F310-B',1997);
|
||||
INSERT INTO test.car_models(name, year) VALUES ('Veneno',2013);
|
||||
INSERT INTO test.car_models(name, year) VALUES ('Murcielago',2001);
|
||||
END IF;
|
||||
|
||||
IF (SELECT current_setting('server_version_num')::INT >= 110000) THEN
|
||||
INSERT INTO test.car_brands(name) VALUES ('DMC');
|
||||
INSERT INTO test.car_brands(name) VALUES ('Ferrari');
|
||||
INSERT INTO test.car_brands(name) VALUES ('Lamborghini');
|
||||
|
||||
UPDATE test.car_models SET car_brand_name = 'DMC' WHERE name = 'DeLorean';
|
||||
UPDATE test.car_models SET car_brand_name = 'Ferrari' WHERE name = 'F310-B';
|
||||
UPDATE test.car_models SET car_brand_name = 'Lamborghini' WHERE name = 'Veneno';
|
||||
UPDATE test.car_models SET car_brand_name = 'Lamborghini' WHERE name = 'Murcielago';
|
||||
END IF;
|
||||
|
||||
IF (SELECT current_setting('server_version_num')::INT >= 120000) THEN
|
||||
INSERT INTO test.car_model_sales(date, quantity, car_model_name, car_model_year) VALUES ('2021-01-14',7,'DeLorean',1981);
|
||||
INSERT INTO test.car_model_sales(date, quantity, car_model_name, car_model_year) VALUES ('2021-01-15',9,'DeLorean',1981);
|
||||
INSERT INTO test.car_model_sales(date, quantity, car_model_name, car_model_year) VALUES ('2021-02-11',1,'Murcielago',2001);
|
||||
INSERT INTO test.car_model_sales(date, quantity, car_model_name, car_model_year) VALUES ('2021-02-12',3,'Murcielago',2001);
|
||||
|
||||
INSERT INTO test.car_racers(name) VALUES ('Alain Prost');
|
||||
INSERT INTO test.car_racers(name, car_model_name, car_model_year) VALUES ('Michael Schumacher', 'F310-B', 1997);
|
||||
|
||||
INSERT INTO test.car_dealers(name,city) VALUES ('Springfield Cars S.A.','Springfield');
|
||||
INSERT INTO test.car_dealers(name,city) VALUES ('The Best Deals S.A.','Franklin');
|
||||
|
||||
INSERT INTO test.car_models_car_dealers(car_model_name, car_model_year, car_dealer_name, car_dealer_city, quantity) VALUES ('DeLorean',1981,'Springfield Cars S.A.','Springfield',15);
|
||||
INSERT INTO test.car_models_car_dealers(car_model_name, car_model_year, car_dealer_name, car_dealer_city, quantity) VALUES ('Murcielago',2001,'The Best Deals S.A.','Franklin',2);
|
||||
END IF;
|
||||
END$do$;
|
||||
|
||||
TRUNCATE TABLE test.products CASCADE;
|
||||
INSERT INTO test.products (id, name) VALUES (1,'product-1'), (2,'product-2'), (3,'product-3');
|
||||
|
||||
TRUNCATE TABLE test.suppliers CASCADE;
|
||||
INSERT INTO test.suppliers (id, name) VALUES (1,'supplier-1'), (2,'supplier-2'), (3, 'supplier-3');
|
||||
|
||||
TRUNCATE TABLE test.products_suppliers CASCADE;
|
||||
INSERT INTO test.products_suppliers (product_id, supplier_id) VALUES (1,1), (1,2), (2,1), (2,3);
|
||||
|
||||
TRUNCATE TABLE test.trade_unions CASCADE;
|
||||
INSERT INTO test.trade_unions (id, name) VALUES (1,'union-1'), (2,'union-2'), (3, 'union-3'), (4, 'union-4');
|
||||
|
||||
TRUNCATE TABLE test.suppliers_trade_unions CASCADE;
|
||||
INSERT INTO test.suppliers_trade_unions (supplier_id, trade_union_id) VALUES (1,1), (1,2), (2,3), (2,4);
|
||||
|
||||
TRUNCATE TABLE test.client CASCADE;
|
||||
INSERT INTO test.client (id,name) values (1,'Walmart'),(2,'Target'),(3,'Big Lots');
|
||||
|
||||
TRUNCATE TABLE test.contact CASCADE;
|
||||
INSERT INTO test.contact (id,name, clientid) values (1,'Wally Walton',1),(2,'Wilma Wellers',1),(3,'Tabby Targo',2),(4,'Bobby Bots',3),(5,'Bonnie Bits',3),(6,'Billy Boats',3) returning *;
|
||||
|
||||
TRUNCATE TABLE test.clientinfo CASCADE;
|
||||
INSERT INTO test.clientinfo (id,clientid, other) values (1,1,'123 Main St'),(2,2,'456 South 3rd St'),(3,3,'789 Palm Tree Ln');
|
||||
|
||||
TRUNCATE TABLE test.chores CASCADE;
|
||||
INSERT INTO test.chores (id, name, done) values (1, 'take out the garbage', true), (2, 'do the laundry', false), (3, 'wash the dishes', null);
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
ALTER DATABASE :DBNAME SET request.jwt.claim.id = '-1';
|
||||
|
||||
set client_min_messages to warning;
|
||||
DROP SCHEMA IF EXISTS test, private, postgrest, jwt, public, تست, extensions, v1, v2 CASCADE;
|
||||
DROP TYPE IF EXISTS jwt_token CASCADE;
|
||||
Vendored
+151
@@ -0,0 +1,151 @@
|
||||
{
|
||||
"id": "draft04.json",
|
||||
"$schema": "draft04.json",
|
||||
"description": "Core schema meta-schema",
|
||||
"definitions": {
|
||||
"schemaArray": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": { "$ref": "#" }
|
||||
},
|
||||
"positiveInteger": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"positiveIntegerDefault0": {
|
||||
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
|
||||
},
|
||||
"simpleTypes": {
|
||||
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
"items": { "type": "string" },
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": {},
|
||||
"multipleOf": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"exclusiveMinimum": true
|
||||
},
|
||||
"maximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMaximum": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"minimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMinimum": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maxLength": { "$ref": "#/definitions/positiveInteger" },
|
||||
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||
"pattern": {
|
||||
"type": "string",
|
||||
"format": "regex"
|
||||
},
|
||||
"additionalItems": {
|
||||
"anyOf": [
|
||||
{ "type": "boolean" },
|
||||
{ "$ref": "#" }
|
||||
],
|
||||
"default": {}
|
||||
},
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{ "$ref": "#" },
|
||||
{ "$ref": "#/definitions/schemaArray" }
|
||||
],
|
||||
"default": {}
|
||||
},
|
||||
"maxItems": { "$ref": "#/definitions/positiveInteger" },
|
||||
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||
"uniqueItems": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
|
||||
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
|
||||
"required": { "$ref": "#/definitions/stringArray" },
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{ "type": "boolean" },
|
||||
{ "$ref": "#" }
|
||||
],
|
||||
"default": {}
|
||||
},
|
||||
"definitions": {
|
||||
"type": "object",
|
||||
"additionalProperties": { "$ref": "#" },
|
||||
"default": {}
|
||||
},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"additionalProperties": { "$ref": "#" },
|
||||
"default": {}
|
||||
},
|
||||
"patternProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": { "$ref": "#" },
|
||||
"default": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{ "$ref": "#" },
|
||||
{ "$ref": "#/definitions/stringArray" }
|
||||
]
|
||||
}
|
||||
},
|
||||
"enum": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"type": {
|
||||
"anyOf": [
|
||||
{ "$ref": "#/definitions/simpleTypes" },
|
||||
{
|
||||
"type": "array",
|
||||
"items": { "$ref": "#/definitions/simpleTypes" },
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": { "type": "string" },
|
||||
"allOf": { "$ref": "#/definitions/schemaArray" },
|
||||
"anyOf": { "$ref": "#/definitions/schemaArray" },
|
||||
"oneOf": { "$ref": "#/definitions/schemaArray" },
|
||||
"not": { "$ref": "#" }
|
||||
},
|
||||
"dependencies": {
|
||||
"exclusiveMaximum": [ "maximum" ],
|
||||
"exclusiveMinimum": [ "minimum" ]
|
||||
},
|
||||
"default": {}
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 324 B |
Vendored
+280
@@ -0,0 +1,280 @@
|
||||
-- from gavinwahl/postgres-json-schema commit 5a257e19a1569a77b82e9182b0b7d9fc8b6f6382
|
||||
|
||||
/*
|
||||
Copyright (c) 2016, Gavin Wahl
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose, without fee, and without a written agreement is
|
||||
hereby granted, provided that the above copyright notice and this paragraph and
|
||||
the following two paragraphs appear in all copies.
|
||||
|
||||
IN NO EVENT SHALL GAVIN WAHL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
|
||||
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
|
||||
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF GAVIN WAHL HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
GAVIN WAHL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND GAVIN WAHL
|
||||
HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
|
||||
MODIFICATIONS.
|
||||
*/
|
||||
|
||||
CREATE OR REPLACE FUNCTION public._validate_json_schema_type(type text, data jsonb) RETURNS boolean AS $f$
|
||||
BEGIN
|
||||
IF type = 'integer' THEN
|
||||
IF jsonb_typeof(data) != 'number' THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
IF trunc(data::text::numeric) != data::text::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
ELSE
|
||||
IF type != jsonb_typeof(data) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
RETURN true;
|
||||
END;
|
||||
$f$ LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION test.validate_json_schema(schema jsonb, data jsonb, root_schema jsonb DEFAULT NULL) RETURNS boolean AS $f$
|
||||
DECLARE
|
||||
prop text;
|
||||
item jsonb;
|
||||
path text[];
|
||||
types text[];
|
||||
pattern text;
|
||||
props text[];
|
||||
BEGIN
|
||||
IF root_schema IS NULL THEN
|
||||
root_schema = schema;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'type' THEN
|
||||
IF jsonb_typeof(schema->'type') = 'array' THEN
|
||||
types = ARRAY(SELECT jsonb_array_elements_text(schema->'type'));
|
||||
ELSE
|
||||
types = ARRAY[schema->>'type'];
|
||||
END IF;
|
||||
IF (SELECT NOT bool_or(public._validate_json_schema_type(type, data)) FROM unnest(types) type) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'properties' THEN
|
||||
FOR prop IN SELECT jsonb_object_keys(schema->'properties') LOOP
|
||||
IF data ? prop AND NOT validate_json_schema(schema->'properties'->prop, data->prop, root_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END LOOP;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'required' AND jsonb_typeof(data) = 'object' THEN
|
||||
IF NOT ARRAY(SELECT jsonb_object_keys(data)) @>
|
||||
ARRAY(SELECT jsonb_array_elements_text(schema->'required')) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'items' AND jsonb_typeof(data) = 'array' THEN
|
||||
IF jsonb_typeof(schema->'items') = 'object' THEN
|
||||
FOR item IN SELECT jsonb_array_elements(data) LOOP
|
||||
IF NOT validate_json_schema(schema->'items', item, root_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END LOOP;
|
||||
ELSE
|
||||
IF NOT (
|
||||
SELECT bool_and(i > jsonb_array_length(schema->'items') OR validate_json_schema(schema->'items'->(i::int - 1), elem, root_schema))
|
||||
FROM jsonb_array_elements(data) WITH ORDINALITY AS t(elem, i)
|
||||
) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF jsonb_typeof(schema->'additionalItems') = 'boolean' and NOT (schema->'additionalItems')::text::boolean AND jsonb_typeof(schema->'items') = 'array' THEN
|
||||
IF jsonb_array_length(data) > jsonb_array_length(schema->'items') THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF jsonb_typeof(schema->'additionalItems') = 'object' THEN
|
||||
IF NOT (
|
||||
SELECT bool_and(validate_json_schema(schema->'additionalItems', elem, root_schema))
|
||||
FROM jsonb_array_elements(data) WITH ORDINALITY AS t(elem, i)
|
||||
WHERE i > jsonb_array_length(schema->'items')
|
||||
) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'minimum' AND jsonb_typeof(data) = 'number' THEN
|
||||
IF data::text::numeric < (schema->>'minimum')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'maximum' AND jsonb_typeof(data) = 'number' THEN
|
||||
IF data::text::numeric > (schema->>'maximum')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF COALESCE((schema->'exclusiveMinimum')::text::bool, FALSE) THEN
|
||||
IF data::text::numeric = (schema->>'minimum')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF COALESCE((schema->'exclusiveMaximum')::text::bool, FALSE) THEN
|
||||
IF data::text::numeric = (schema->>'maximum')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'anyOf' THEN
|
||||
IF NOT (SELECT bool_or(validate_json_schema(sub_schema, data, root_schema)) FROM jsonb_array_elements(schema->'anyOf') sub_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'allOf' THEN
|
||||
IF NOT (SELECT bool_and(validate_json_schema(sub_schema, data, root_schema)) FROM jsonb_array_elements(schema->'allOf') sub_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'oneOf' THEN
|
||||
IF 1 != (SELECT COUNT(*) FROM jsonb_array_elements(schema->'oneOf') sub_schema WHERE validate_json_schema(sub_schema, data, root_schema)) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF COALESCE((schema->'uniqueItems')::text::boolean, false) THEN
|
||||
IF (SELECT COUNT(*) FROM jsonb_array_elements(data)) != (SELECT count(DISTINCT val) FROM jsonb_array_elements(data) val) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'additionalProperties' AND jsonb_typeof(data) = 'object' THEN
|
||||
props := ARRAY(
|
||||
SELECT key
|
||||
FROM jsonb_object_keys(data) key
|
||||
WHERE key NOT IN (SELECT jsonb_object_keys(schema->'properties'))
|
||||
AND NOT EXISTS (SELECT * FROM jsonb_object_keys(schema->'patternProperties') pat WHERE key ~ pat)
|
||||
);
|
||||
IF jsonb_typeof(schema->'additionalProperties') = 'boolean' THEN
|
||||
IF NOT (schema->'additionalProperties')::text::boolean AND jsonb_typeof(data) = 'object' AND NOT props <@ ARRAY(SELECT jsonb_object_keys(schema->'properties')) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
ELSEIF NOT (
|
||||
SELECT bool_and(validate_json_schema(schema->'additionalProperties', data->key, root_schema))
|
||||
FROM unnest(props) key
|
||||
) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? '$ref' THEN
|
||||
path := ARRAY(
|
||||
SELECT regexp_replace(regexp_replace(path_part, '~1', '/'), '~0', '~')
|
||||
FROM UNNEST(regexp_split_to_array(schema->>'$ref', '/')) path_part
|
||||
);
|
||||
-- ASSERT path[1] = '#', 'only refs anchored at the root are supported';
|
||||
IF NOT validate_json_schema(root_schema #> path[2:array_length(path, 1)], data, root_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'enum' THEN
|
||||
IF NOT EXISTS (SELECT * FROM jsonb_array_elements(schema->'enum') val WHERE val = data) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'minLength' AND jsonb_typeof(data) = 'string' THEN
|
||||
IF char_length(data #>> '{}') < (schema->>'minLength')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'maxLength' AND jsonb_typeof(data) = 'string' THEN
|
||||
IF char_length(data #>> '{}') > (schema->>'maxLength')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'not' THEN
|
||||
IF validate_json_schema(schema->'not', data, root_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'maxProperties' AND jsonb_typeof(data) = 'object' THEN
|
||||
IF (SELECT count(*) FROM jsonb_object_keys(data)) > (schema->>'maxProperties')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'minProperties' AND jsonb_typeof(data) = 'object' THEN
|
||||
IF (SELECT count(*) FROM jsonb_object_keys(data)) < (schema->>'minProperties')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'maxItems' AND jsonb_typeof(data) = 'array' THEN
|
||||
IF (SELECT count(*) FROM jsonb_array_elements(data)) > (schema->>'maxItems')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'minItems' AND jsonb_typeof(data) = 'array' THEN
|
||||
IF (SELECT count(*) FROM jsonb_array_elements(data)) < (schema->>'minItems')::numeric THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'dependencies' THEN
|
||||
FOR prop IN SELECT jsonb_object_keys(schema->'dependencies') LOOP
|
||||
IF data ? prop THEN
|
||||
IF jsonb_typeof(schema->'dependencies'->prop) = 'array' THEN
|
||||
IF NOT (SELECT bool_and(data ? dep) FROM jsonb_array_elements_text(schema->'dependencies'->prop) dep) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
ELSE
|
||||
IF NOT validate_json_schema(schema->'dependencies'->prop, data, root_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
END LOOP;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'pattern' AND jsonb_typeof(data) = 'string' THEN
|
||||
IF (data #>> '{}') !~ (schema->>'pattern') THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'patternProperties' AND jsonb_typeof(data) = 'object' THEN
|
||||
FOR prop IN SELECT jsonb_object_keys(data) LOOP
|
||||
FOR pattern IN SELECT jsonb_object_keys(schema->'patternProperties') LOOP
|
||||
RAISE NOTICE 'prop %s, pattern %, schema %', prop, pattern, schema->'patternProperties'->pattern;
|
||||
IF prop ~ pattern AND NOT validate_json_schema(schema->'patternProperties'->pattern, data->prop, root_schema) THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
END IF;
|
||||
|
||||
IF schema ? 'multipleOf' AND jsonb_typeof(data) = 'number' THEN
|
||||
IF data::text::numeric % (schema->>'multipleOf')::numeric != 0 THEN
|
||||
RETURN false;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
RETURN true;
|
||||
END;
|
||||
$f$ LANGUAGE 'plpgsql' IMMUTABLE;
|
||||
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
-- From michelp/pgjwt commit c02bbd3
|
||||
BEGIN;
|
||||
|
||||
set search_path to public;
|
||||
|
||||
set client_min_messages to warning;
|
||||
DROP SCHEMA IF EXISTS jwt CASCADE;
|
||||
CREATE SCHEMA jwt;
|
||||
|
||||
CREATE OR REPLACE FUNCTION jwt.url_encode(data bytea) RETURNS text LANGUAGE sql AS $$
|
||||
SELECT translate(encode(data, 'base64'), E'+/=\n', '-_');
|
||||
$$;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION jwt.url_decode(data text) RETURNS bytea LANGUAGE sql AS $$
|
||||
WITH t AS (SELECT translate(data, '-_', '+/')),
|
||||
rem AS (SELECT length((SELECT * FROM t)) % 4) -- compute padding size
|
||||
SELECT decode(
|
||||
(SELECT * FROM t) ||
|
||||
CASE WHEN (SELECT * FROM rem) > 0
|
||||
THEN repeat('=', (4 - (SELECT * FROM rem)))
|
||||
ELSE '' END,
|
||||
'base64');
|
||||
$$;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION jwt.algorithm_sign(signables text, secret text, algorithm text)
|
||||
RETURNS text LANGUAGE sql AS $$
|
||||
WITH
|
||||
alg AS (
|
||||
SELECT CASE
|
||||
WHEN algorithm = 'HS256' THEN 'sha256'
|
||||
WHEN algorithm = 'HS384' THEN 'sha384'
|
||||
WHEN algorithm = 'HS512' THEN 'sha512'
|
||||
ELSE '' END) -- hmac throws error
|
||||
SELECT jwt.url_encode(public.hmac(signables, secret, (select * FROM alg)));
|
||||
$$;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION jwt.sign(payload json, secret text, algorithm text DEFAULT 'HS256')
|
||||
RETURNS text LANGUAGE sql AS $$
|
||||
WITH
|
||||
header AS (
|
||||
SELECT jwt.url_encode(convert_to('{"alg":"' || algorithm || '","typ":"JWT"}', 'utf8'))
|
||||
),
|
||||
payload AS (
|
||||
SELECT jwt.url_encode(convert_to(payload::text, 'utf8'))
|
||||
),
|
||||
signables AS (
|
||||
SELECT (SELECT * FROM header) || '.' || (SELECT * FROM payload)
|
||||
)
|
||||
SELECT
|
||||
(SELECT * FROM signables)
|
||||
|| '.' ||
|
||||
jwt.algorithm_sign((SELECT * FROM signables), secret, algorithm);
|
||||
$$;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION jwt.verify(token text, secret text, algorithm text DEFAULT 'HS256')
|
||||
RETURNS table(header json, payload json, valid boolean) LANGUAGE sql AS $$
|
||||
SELECT
|
||||
convert_from(jwt.url_decode(r[1]), 'utf8')::json AS header,
|
||||
convert_from(jwt.url_decode(r[2]), 'utf8')::json AS payload,
|
||||
r[3] = jwt.algorithm_sign(r[1] || '.' || r[2], secret, algorithm) AS valid
|
||||
FROM regexp_split_to_array(token, '\.') r;
|
||||
$$;
|
||||
COMMIT;
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
-- Loads all fixtures for the PostgREST tests
|
||||
|
||||
\set ON_ERROR_STOP on
|
||||
|
||||
\ir database.sql
|
||||
\ir roles.sql
|
||||
\ir schema.sql
|
||||
\ir jwt.sql
|
||||
\ir jsonschema.sql
|
||||
\ir privileges.sql
|
||||
\ir data.sql
|
||||
Vendored
+1607
File diff suppressed because it is too large
Load Diff
Vendored
+218
@@ -0,0 +1,218 @@
|
||||
-- Privileges for anonymous
|
||||
GRANT USAGE ON SCHEMA
|
||||
postgrest
|
||||
, test
|
||||
, jwt
|
||||
, public
|
||||
, "تست"
|
||||
, extensions
|
||||
, v1
|
||||
, v2
|
||||
TO postgrest_test_anonymous;
|
||||
|
||||
-- Schema test objects
|
||||
SET search_path = test, "تست", pg_catalog;
|
||||
|
||||
GRANT ALL ON TABLE
|
||||
items
|
||||
, items2
|
||||
, items3
|
||||
, "articleStars"
|
||||
, articles
|
||||
, auto_incrementing_pk
|
||||
, clients
|
||||
, comments
|
||||
, complex_items
|
||||
, compound_pk
|
||||
, compound_pk_view
|
||||
, deferrable_unique_constraint
|
||||
, empty_table
|
||||
, has_count_column
|
||||
, has_fk
|
||||
, insertable_view_with_join
|
||||
, json_table
|
||||
, materialized_view
|
||||
, menagerie
|
||||
, no_pk
|
||||
, nullable_integer
|
||||
, projects
|
||||
, projects_view
|
||||
, projects_view_alt
|
||||
, test_null_pk_competitors_sponsors
|
||||
, simple_pk
|
||||
, simple_pk2
|
||||
, tasks
|
||||
, filtered_tasks
|
||||
, tsearch
|
||||
, users
|
||||
, users_projects
|
||||
, users_tasks
|
||||
, files
|
||||
, touched_files
|
||||
, "Escap3e;"
|
||||
, "ghostBusters"
|
||||
, "withUnique"
|
||||
, "clashing_column"
|
||||
, "موارد"
|
||||
, addresses
|
||||
, orders
|
||||
, public.public_consumers
|
||||
, public.public_orders
|
||||
, consumers_view
|
||||
, consumers_view_view
|
||||
, consumers_extra_view
|
||||
, orders_view
|
||||
, images
|
||||
, images_base64
|
||||
, w_or_wo_comma_names
|
||||
, items_with_different_col_types
|
||||
, entities
|
||||
, child_entities
|
||||
, grandchild_entities
|
||||
, ranges
|
||||
, being
|
||||
, descendant
|
||||
, being_part
|
||||
, part
|
||||
, leak
|
||||
, perf_articles
|
||||
, employees
|
||||
, tiobe_pls
|
||||
, single_unique
|
||||
, compound_unique
|
||||
, only_pk
|
||||
, family_tree
|
||||
, managers
|
||||
, organizations
|
||||
, authors
|
||||
, books
|
||||
, forties_books
|
||||
, fifties_books
|
||||
, sixties_books
|
||||
, person
|
||||
, message
|
||||
, person_detail
|
||||
, space
|
||||
, zone
|
||||
, projects_dump
|
||||
, "UnitTest"
|
||||
, json_arr
|
||||
, jsonb_test
|
||||
, authors_books_number
|
||||
, authors_have_book_in_decade
|
||||
, authors_have_book_in_decade2
|
||||
, forties_and_fifties_books
|
||||
, odd_years_publications
|
||||
, foos
|
||||
, bars
|
||||
, materialized_projects
|
||||
, contract
|
||||
, player_view
|
||||
, contract_view
|
||||
, ltree_sample
|
||||
, isn_sample
|
||||
, projects_count_grouped_by
|
||||
, "Server Today"
|
||||
, pgrst_reserved_chars
|
||||
, authors_w_entities
|
||||
, openapi_types
|
||||
, openapi_defaults
|
||||
, getallprojects_view
|
||||
, get_projects_above_view
|
||||
, web_content
|
||||
, pages
|
||||
, referrals
|
||||
, big_projects
|
||||
, sites
|
||||
, jobs
|
||||
, main_jobs
|
||||
, whatev_projects
|
||||
, whatev_sites
|
||||
, whatev_jobs
|
||||
, agents
|
||||
, departments
|
||||
, schedules
|
||||
, activities
|
||||
, unit_workdays
|
||||
, stuff
|
||||
, loc_test
|
||||
, v1.parents
|
||||
, v2.parents
|
||||
, v2.another_table
|
||||
, v1.children
|
||||
, v2.children
|
||||
, screens
|
||||
, labels
|
||||
, label_screen
|
||||
, actors
|
||||
, films
|
||||
, personnages
|
||||
, end_1
|
||||
, end_2
|
||||
, schauspieler
|
||||
, filme
|
||||
, rollen
|
||||
, products
|
||||
, suppliers
|
||||
, products_suppliers
|
||||
, trade_unions
|
||||
, suppliers_trade_unions
|
||||
, client
|
||||
, clientinfo
|
||||
, contact
|
||||
, chores
|
||||
TO postgrest_test_anonymous;
|
||||
|
||||
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
||||
|
||||
GRANT USAGE ON SEQUENCE
|
||||
auto_incrementing_pk_id_seq
|
||||
, items_id_seq
|
||||
, items2_id_seq
|
||||
, items3_id_seq
|
||||
, callcounter_count
|
||||
, leak_id_seq
|
||||
TO postgrest_test_anonymous;
|
||||
|
||||
-- Privileges for non anonymous users
|
||||
GRANT USAGE ON SCHEMA test TO postgrest_test_author;
|
||||
GRANT ALL ON TABLE authors_only TO postgrest_test_author;
|
||||
|
||||
GRANT SELECT (article_id, user_id) ON TABLE limited_article_stars TO postgrest_test_anonymous;
|
||||
GRANT INSERT (article_id, user_id) ON TABLE limited_article_stars TO postgrest_test_anonymous;
|
||||
GRANT UPDATE (article_id, user_id) ON TABLE limited_article_stars TO postgrest_test_anonymous;
|
||||
|
||||
GRANT SELECT(id, email) ON TABLE app_users TO postgrest_test_anonymous;
|
||||
GRANT INSERT, UPDATE ON TABLE app_users TO postgrest_test_anonymous;
|
||||
GRANT DELETE ON TABLE app_users TO postgrest_test_anonymous;
|
||||
|
||||
REVOKE EXECUTE ON FUNCTION privileged_hello(text) FROM PUBLIC; -- All functions are available to every role(PUBLIC) by default
|
||||
GRANT EXECUTE ON FUNCTION privileged_hello(text) TO postgrest_test_author;
|
||||
|
||||
GRANT USAGE ON SCHEMA test TO postgrest_test_default_role;
|
||||
|
||||
|
||||
DO $do$BEGIN
|
||||
IF (SELECT current_setting('server_version_num')::INT >= 100000) THEN
|
||||
GRANT ALL ON TABLE test.car_models TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_models_2021 TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_models_default TO postgrest_test_anonymous;
|
||||
END IF;
|
||||
|
||||
IF (SELECT current_setting('server_version_num')::INT >= 110000) THEN
|
||||
GRANT ALL ON TABLE test.car_brands TO postgrest_test_anonymous;
|
||||
END IF;
|
||||
|
||||
IF (SELECT current_setting('server_version_num')::INT >= 120000) THEN
|
||||
GRANT ALL ON TABLE test.car_model_sales TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_model_sales_202101 TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_model_sales_default TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_racers TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_dealers TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_dealers_springfield TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_dealers_default TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_models_car_dealers TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_models_car_dealers_10to20 TO postgrest_test_anonymous;
|
||||
GRANT ALL ON TABLE test.car_models_car_dealers_default TO postgrest_test_anonymous;
|
||||
END IF;
|
||||
END$do$;
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
\set AUTHENTICATOR current_user
|
||||
DROP ROLE IF EXISTS postgrest_test_anonymous, postgrest_test_default_role, postgrest_test_author;
|
||||
CREATE ROLE postgrest_test_anonymous;
|
||||
CREATE ROLE postgrest_test_default_role;
|
||||
CREATE ROLE postgrest_test_author;
|
||||
|
||||
GRANT postgrest_test_anonymous, postgrest_test_default_role, postgrest_test_author TO :USER;
|
||||
Vendored
+2429
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user