mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-11-03 20:37:24 +03:00
[server] coalesce multiple run_sql calls in tests (#270)
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
This commit is contained in:
parent
6f86d3892a
commit
5bc0355bdd
14
scripts/coalesce_run_sql/requirements.txt
Normal file
14
scripts/coalesce_run_sql/requirements.txt
Normal file
@ -0,0 +1,14 @@
|
||||
backcall==0.2.0
|
||||
decorator==4.4.2
|
||||
ipython==7.19.0
|
||||
ipython-genutils==0.2.0
|
||||
jedi==0.18.0
|
||||
parso==0.8.1
|
||||
pexpect==4.8.0
|
||||
pickleshare==0.7.5
|
||||
prompt-toolkit==3.0.8
|
||||
ptyprocess==0.6.0
|
||||
Pygments==2.7.3
|
||||
ruamel.yaml==0.16.12
|
||||
traitlets==5.0.5
|
||||
wcwidth==0.2.5
|
84
scripts/coalesce_run_sql/run.py
Executable file
84
scripts/coalesce_run_sql/run.py
Executable file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import ruamel.yaml
|
||||
from ruamel.yaml import YAML
|
||||
import textwrap
|
||||
import copy
|
||||
|
||||
filename = sys.argv[1]
|
||||
yaml = YAML(typ='rt')
|
||||
orig = yaml.load(Path(filename))
|
||||
|
||||
sql = ""
|
||||
comments = ""
|
||||
ixs_to_delete = []
|
||||
|
||||
if orig['type'] != 'bulk':
|
||||
sys.exit(0)
|
||||
|
||||
if orig['args'].ca.items:
|
||||
try:
|
||||
for i in orig['args'].ca.items.values():
|
||||
for j in i:
|
||||
if j is not None:
|
||||
for k in j:
|
||||
comments += k.value
|
||||
except KeyError:
|
||||
print(orig['args'].ca.items)
|
||||
|
||||
min_ix = None
|
||||
|
||||
for ix, p in enumerate(orig['args']):
|
||||
if p['type'] == 'run_sql':
|
||||
if min_ix is None:
|
||||
min_ix = ix
|
||||
#print(p.ca)
|
||||
|
||||
if p.ca.items:
|
||||
for i in p.ca.items.values():
|
||||
if i is not None:
|
||||
for j in i:
|
||||
comments += j.value
|
||||
|
||||
current = p['args']['sql']
|
||||
|
||||
# some sql strings don't end with a ;
|
||||
# so we fix those up
|
||||
if current[-2:] != ";\n":
|
||||
current = current[:-1] + ";\n"
|
||||
|
||||
sql += current
|
||||
ixs_to_delete.append(ix)
|
||||
|
||||
# ancient trick
|
||||
# if you do it in any order that isn't monotonically decreasing
|
||||
# the indices shift after each del
|
||||
# i don't _like_ using del but CommentedSeq has no .delete() method
|
||||
for ix in sorted(ixs_to_delete, reverse=True):
|
||||
del orig['args'][ix]
|
||||
print(sql)
|
||||
print("---")
|
||||
if len(sql) < 5:
|
||||
print(filename)
|
||||
print(sql)
|
||||
print("---")
|
||||
sys.exit(0)
|
||||
|
||||
coalesced = """
|
||||
{}
|
||||
type: 'run_sql'
|
||||
args:
|
||||
sql: |
|
||||
{}
|
||||
""".format(textwrap.indent(comments, " " * 2), textwrap.indent(sql, " " * 8))
|
||||
# print(coalesced)
|
||||
|
||||
orig['args'].insert(min_ix, yaml.load(coalesced))
|
||||
#orig.yaml_set_comment_before_key('args', comments)
|
||||
with open(filename, "w") as outfile:
|
||||
yaml.dump(orig, outfile)
|
||||
|
||||
#for k, v in y:
|
||||
# print(k)
|
||||
# yaml.dump(v, sys.stdout)
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -13,6 +14,7 @@ args:
|
||||
title text NOT NULL,
|
||||
body text NOT NULL
|
||||
);
|
||||
|
||||
- args:
|
||||
name: authors
|
||||
schema: public
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -84,8 +85,8 @@ args:
|
||||
kind: synchronous
|
||||
arguments:
|
||||
- name: arg
|
||||
type: 'InObject!'
|
||||
output_type: 'OutObject'
|
||||
type: InObject!
|
||||
output_type: OutObject
|
||||
handler: http://127.0.0.1:5593/mirror-action
|
||||
|
||||
- type: create_action
|
||||
@ -95,8 +96,8 @@ args:
|
||||
type: query
|
||||
arguments:
|
||||
- name: email
|
||||
type: 'String!'
|
||||
output_type: 'UserId!'
|
||||
type: String!
|
||||
output_type: UserId!
|
||||
handler: http://127.0.0.1:5593/get-user-by-email
|
||||
|
||||
- type: create_action
|
||||
@ -106,6 +107,6 @@ args:
|
||||
type: query
|
||||
arguments:
|
||||
- name: email
|
||||
type: 'String!'
|
||||
type: String!
|
||||
output_type: '[UserId]!'
|
||||
handler: http://127.0.0.1:5593/get-users-by-email
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,10 +1,12 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE test (id serial primary key, name text);
|
||||
INSERT INTO test (name) values ('Gzip'), ('Brotli'), ('Nothing');
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,9 +20,9 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592/timeout_long
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,9 +20,9 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,3 +8,4 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,14 +20,14 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592
|
||||
headers:
|
||||
- name: "X-Header-From-Value"
|
||||
value: "MyValue"
|
||||
- name: "X-Header-From-Env"
|
||||
value_from_env: "EVENT_WEBHOOK_HEADER"
|
||||
- name: X-Header-From-Value
|
||||
value: MyValue
|
||||
- name: X-Header-From-Env
|
||||
value_from_env: EVENT_WEBHOOK_HEADER
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,5 +20,5 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,11 +20,11 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
enable_manual: true
|
||||
webhook: http://127.0.0.1:5592
|
||||
- type: create_event_trigger
|
||||
@ -32,10 +34,10 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
enable_manual: false
|
||||
webhook: http://127.0.0.1:5592
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -15,6 +16,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -34,11 +36,11 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592/fail
|
||||
retry_conf:
|
||||
num_retries: 4
|
||||
@ -50,11 +52,11 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t2
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592/timeout_short
|
||||
retry_conf:
|
||||
num_retries: 2
|
||||
@ -67,11 +69,11 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t3
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592/timeout_long
|
||||
retry_conf:
|
||||
num_retries: 0
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,11 +20,11 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: ["c1"]
|
||||
columns: [c1]
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592
|
||||
retry_conf:
|
||||
num_retries: 10
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,14 +20,14 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
payload: "*"
|
||||
columns: '*'
|
||||
payload: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
payload: ["c1"]
|
||||
columns: '*'
|
||||
payload: [c1]
|
||||
delete:
|
||||
columns: "*"
|
||||
payload: ["c2"]
|
||||
columns: '*'
|
||||
payload: [c2]
|
||||
webhook: http://127.0.0.1:5592
|
||||
retry_conf:
|
||||
num_retries: 10
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -8,6 +9,7 @@ args:
|
||||
c2 text,
|
||||
c3 json
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -19,7 +21,7 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: ["c2", "c3"]
|
||||
columns: [c2, c3]
|
||||
webhook: http://127.0.0.1:5592
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,9 +20,9 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
webhook_from_env: WEBHOOK_FROM_ENV
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
@ -18,9 +20,9 @@ args:
|
||||
schema: hge_tests
|
||||
name: test_t1
|
||||
insert:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
update:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: "*"
|
||||
webhook: "{{WEBHOOK_FROM_ENV}}/trigger"
|
||||
columns: '*'
|
||||
webhook: '{{WEBHOOK_FROM_ENV}}/trigger'
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,6 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +17,14 @@ args:
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN NOT NULL default FALSE,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -1,5 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -22,3 +23,4 @@ args:
|
||||
, 2
|
||||
)
|
||||
;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -15,7 +16,6 @@ args:
|
||||
author_id INTEGER REFERENCES author(id)
|
||||
);
|
||||
|
||||
|
||||
- type: track_table
|
||||
version: 2
|
||||
args:
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -22,3 +23,4 @@ args:
|
||||
, 2
|
||||
)
|
||||
;
|
||||
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -20,15 +21,6 @@ args:
|
||||
info jsonb,
|
||||
location geography
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -36,7 +28,14 @@ args:
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +17,14 @@ args:
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -11,15 +12,6 @@ args:
|
||||
payments_done boolean not null default false,
|
||||
user_id int
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -27,7 +19,29 @@ args:
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
age INTEGER NOT NULL
|
||||
);
|
||||
create table "user" (
|
||||
id serial primary key,
|
||||
name text not null unique,
|
||||
is_admin boolean default false
|
||||
);
|
||||
|
||||
create table account (
|
||||
id serial primary key,
|
||||
account_no integer not null
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -98,14 +112,6 @@ args:
|
||||
- author_id: X-HASURA-USER-ID
|
||||
|
||||
#Create resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
age INTEGER NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -142,20 +148,6 @@ args:
|
||||
$in: X-Hasura-Allowed-Resident-Ids
|
||||
|
||||
# Tables to test '_exist' field
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table "user" (
|
||||
id serial primary key,
|
||||
name text not null unique,
|
||||
is_admin boolean default false
|
||||
);
|
||||
|
||||
create table account (
|
||||
id serial primary key,
|
||||
account_no integer not null
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: user
|
||||
|
@ -46,6 +46,8 @@ args:
|
||||
title: Article 5
|
||||
|
||||
#Insert users and accounts
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -53,3 +55,4 @@ args:
|
||||
values ('user_1', false), ('user_2', true)
|
||||
;
|
||||
insert into account (account_no) values (1), (2) ;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -2,46 +2,56 @@
|
||||
# (#1514)
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
# test functions having multiple defaults
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "user" (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
score INTEGER,
|
||||
/* We just return the session vars as this column from our function
|
||||
* to show they're passed through properly.
|
||||
*
|
||||
* NOTE: with the addition of function "tracking" we probably want to
|
||||
* logically be defining permissions on composite types (which might
|
||||
* or might not have been created implicitly in a CREATE TABLE).
|
||||
*
|
||||
* See: https://github.com/hasura/graphql-engine-internal/issues/502
|
||||
*/
|
||||
role_echo TEXT DEFAULT ''
|
||||
);
|
||||
|
||||
# Adds a value (defaulting to 1) to users matching 'search', returning updated
|
||||
# rows and echoing the hasura session vars.
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "user" (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
score INTEGER,
|
||||
/* We just return the session vars as this column from our function
|
||||
* to show they're passed through properly.
|
||||
*
|
||||
* NOTE: with the addition of function "tracking" we probably want to
|
||||
* logically be defining permissions on composite types (which might
|
||||
* or might not have been created implicitly in a CREATE TABLE).
|
||||
*
|
||||
* See: https://github.com/hasura/graphql-engine-internal/issues/502
|
||||
*/
|
||||
role_echo TEXT DEFAULT ''
|
||||
);
|
||||
CREATE FUNCTION add_to_score(hasura_session json, search text, increment integer default 1)
|
||||
RETURNS SETOF "user" AS $$
|
||||
UPDATE "user"
|
||||
SET score = score + increment
|
||||
WHERE name ilike ('%' || search || '%')
|
||||
RETURNING id,
|
||||
name,
|
||||
score,
|
||||
RETURNING id,
|
||||
name,
|
||||
score,
|
||||
/* NOTE: other fields may be added to hasura_session
|
||||
* depending on the flavor of test run on CI, e.g.
|
||||
* x-hasura-auth-mode: webhook, so filter just x-hasura-role
|
||||
*/
|
||||
hasura_session->>'x-hasura-role' AS role_echo
|
||||
$$ LANGUAGE sql VOLATILE;
|
||||
CREATE FUNCTION volatile_func1()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql VOLATILE;
|
||||
CREATE FUNCTION stable_func1()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
CREATE FUNCTION volatile_func2()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql VOLATILE;
|
||||
CREATE FUNCTION stable_func2()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
@ -73,36 +83,6 @@ args:
|
||||
|
||||
|
||||
# A few unimportant functions for smoke tests
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE FUNCTION volatile_func1()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql VOLATILE;
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE FUNCTION stable_func1()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE FUNCTION volatile_func2()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql VOLATILE;
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE FUNCTION stable_func2()
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT * FROM "user" ORDER BY id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
# Infer that function should be a mutation from VOLATILE, if exposed_as
|
||||
- version: 2
|
||||
type: track_function
|
||||
args:
|
||||
|
@ -9,3 +9,4 @@ args:
|
||||
, ('Bellamy Blake', 10)
|
||||
, ('Dora Black', 50)
|
||||
;
|
||||
|
||||
|
@ -2,28 +2,15 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Set timezone
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -31,96 +18,27 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Person table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: person
|
||||
|
||||
#Person views
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE VIEW person_const_view AS select * from person LIMIT 600;
|
||||
CREATE VIEW person_mut_view AS select * from person;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: person_const_view
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: person_mut_view
|
||||
|
||||
#Order table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
placed TIMESTAMPTZ NOT NULL,
|
||||
shipped TIMESTAMPTZ
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TYPE complex AS (
|
||||
r double precision,
|
||||
i double precision
|
||||
);
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TYPE inventory_item AS (
|
||||
name text,
|
||||
supplier_id integer,
|
||||
price numeric
|
||||
);
|
||||
|
||||
#Test table with different types
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table test_types (
|
||||
c1_smallint smallint,
|
||||
c2_integer integer,
|
||||
@ -167,6 +85,60 @@ args:
|
||||
c43_range_timestamptz tstzrange,
|
||||
c44_xml xml
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Person table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: person
|
||||
|
||||
#Person views
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: person_const_view
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: person_mut_view
|
||||
|
||||
#Order table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,36 +10,31 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Create resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
age INTEGER NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: resident
|
||||
|
||||
#Create address table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE address (
|
||||
id SERIAL PRIMARY KEY,
|
||||
door_no TEXT NOT NULL,
|
||||
street TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
resident_id INTEGER REFERENCES resident(id)
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Create resident table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: resident
|
||||
|
||||
#Create address table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -1,77 +1,76 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF PostGIS_lib_version() ~ '^3.*' THEN
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_raster;
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
|
||||
#User location table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
CREATE TABLE drone_3d_location (
|
||||
drone_id INTEGER PRIMARY KEY,
|
||||
location GEOGRAPHY(Pointz)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: drone_3d_location
|
||||
|
||||
#landmark table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE landmark (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT,
|
||||
type TEXT,
|
||||
location GEOGRAPHY(Point)
|
||||
);
|
||||
CREATE TABLE road (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT,
|
||||
path GEOGRAPHY(LINESTRING)
|
||||
);
|
||||
CREATE TABLE service_locations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
service TEXT,
|
||||
locations GEOGRAPHY(MULTIPOINT)
|
||||
);
|
||||
CREATE TABLE route (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT,
|
||||
route GEOGRAPHY(MULTILINESTRING)
|
||||
);
|
||||
CREATE TABLE area (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT,
|
||||
area GEOGRAPHY(POLYGON)
|
||||
);
|
||||
CREATE TABLE compounds (
|
||||
user_id integer PRIMARY KEY,
|
||||
name TEXT,
|
||||
areas GEOGRAPHY(MULTIPOLYGON)
|
||||
);
|
||||
CREATE TABLE geometry_collection (
|
||||
id SERIAL PRIMARY KEY,
|
||||
geometries GEOGRAPHY(GEOMETRYCOLLECTION)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: drone_3d_location
|
||||
|
||||
#landmark table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: landmark
|
||||
|
||||
#straight_road table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE road (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT,
|
||||
path GEOGRAPHY(LINESTRING)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: road
|
||||
|
||||
#curved_road table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE service_locations (
|
||||
id SERIAL PRIMARY KEY,
|
||||
service TEXT,
|
||||
locations GEOGRAPHY(MULTIPOINT)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -79,57 +78,25 @@ args:
|
||||
|
||||
|
||||
#route table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE route (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT,
|
||||
route GEOGRAPHY(MULTILINESTRING)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: route
|
||||
|
||||
#Area table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE area (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT,
|
||||
area GEOGRAPHY(POLYGON)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: area
|
||||
|
||||
#Compounds table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE compounds (
|
||||
user_id integer PRIMARY KEY,
|
||||
name TEXT,
|
||||
areas GEOGRAPHY(MULTIPOLYGON)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: compounds
|
||||
|
||||
#Generic geometry table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE geometry_collection (
|
||||
id SERIAL PRIMARY KEY,
|
||||
geometries GEOGRAPHY(GEOMETRYCOLLECTION)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: geometry_collection
|
||||
|
||||
|
@ -4,39 +4,11 @@ args:
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE drone_3d_location
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE landmark
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE road
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE service_locations
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE route
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE area
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE compounds
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DROP TABLE geometry_collection
|
||||
DROP TABLE drone_3d_location;
|
||||
DROP TABLE landmark;
|
||||
DROP TABLE road;
|
||||
DROP TABLE service_locations;
|
||||
DROP TABLE route;
|
||||
DROP TABLE area;
|
||||
DROP TABLE compounds;
|
||||
DROP TABLE geometry_collection;
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -11,15 +12,6 @@ args:
|
||||
is_registered boolean not null default false,
|
||||
emails text[] not null default '{}'::text[]
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -40,6 +32,12 @@ args:
|
||||
) AND author_id = author_row.id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Test table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,8 +10,9 @@ args:
|
||||
id serial primary key,
|
||||
"nullName" text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: "nullPrefixTestTable"
|
||||
name: nullPrefixTestTable
|
||||
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,34 +17,35 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
);
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
placed TIMESTAMPTZ NOT NULL,
|
||||
shipped TIMESTAMPTZ
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Person table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: person
|
||||
|
||||
#Order table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
placed TIMESTAMPTZ NOT NULL,
|
||||
shipped TIMESTAMPTZ
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,15 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
|
||||
|
||||
# Tables to test '_exist' field
|
||||
|
||||
|
||||
|
||||
# a sales role can only update the leads added by them
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -11,15 +20,6 @@ args:
|
||||
bio text,
|
||||
is_registered boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -38,7 +38,58 @@ args:
|
||||
OR content ilike ('%' || search || '%')
|
||||
) AND author_id = author_row.id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
age INTEGER NOT NULL,
|
||||
is_user BOOLEAN DEFAULT FALSE NOT NULL
|
||||
);
|
||||
CREATE TABLE address (
|
||||
id SERIAL PRIMARY KEY,
|
||||
door_no TEXT NOT NULL,
|
||||
street TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
resident_id INTEGER REFERENCES resident(id)
|
||||
);
|
||||
CREATE TABLE "Company" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"name" TEXT
|
||||
);
|
||||
CREATE TABLE blog (
|
||||
id serial primary key,
|
||||
title text not null,
|
||||
content text,
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
last_updated timestamptz,
|
||||
updated_by INTEGER REFERENCES author(id)
|
||||
);
|
||||
CREATE TABLE computer (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
spec JSONB NOT NULL
|
||||
);
|
||||
create table "user" (
|
||||
id serial primary key,
|
||||
name text not null unique,
|
||||
is_admin boolean default false
|
||||
);
|
||||
|
||||
create table account (
|
||||
id serial primary key,
|
||||
account_no integer not null
|
||||
);
|
||||
create table leads (
|
||||
id serial primary key,
|
||||
name text not null,
|
||||
added_by text not null
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -53,44 +104,18 @@ args:
|
||||
table_argument: author_row
|
||||
|
||||
#Create resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
age INTEGER NOT NULL,
|
||||
is_user BOOLEAN DEFAULT FALSE NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: resident
|
||||
|
||||
#Create address table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE address (
|
||||
id SERIAL PRIMARY KEY,
|
||||
door_no TEXT NOT NULL,
|
||||
street TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
resident_id INTEGER REFERENCES resident(id)
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: address
|
||||
|
||||
#Create Company table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "Company" (
|
||||
"id" SERIAL PRIMARY KEY,
|
||||
"name" TEXT
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -329,18 +354,6 @@ args:
|
||||
|
||||
|
||||
#Create blog table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE blog (
|
||||
id serial primary key,
|
||||
title text not null,
|
||||
content text,
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
last_updated timestamptz,
|
||||
updated_by INTEGER REFERENCES author(id)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: blog
|
||||
@ -372,18 +385,9 @@ args:
|
||||
- content
|
||||
filter: {}
|
||||
set:
|
||||
last_updated: 'NOW()'
|
||||
last_updated: NOW()
|
||||
updated_by: X-Hasura-User-Id
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE computer (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
spec JSONB NOT NULL
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: computer
|
||||
@ -424,22 +428,6 @@ args:
|
||||
permission:
|
||||
columns: '*'
|
||||
filter: {}
|
||||
|
||||
# Tables to test '_exist' field
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table "user" (
|
||||
id serial primary key,
|
||||
name text not null unique,
|
||||
is_admin boolean default false
|
||||
);
|
||||
|
||||
create table account (
|
||||
id serial primary key,
|
||||
account_no integer not null
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: user
|
||||
@ -522,15 +510,6 @@ args:
|
||||
set:
|
||||
is_admin: false
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table leads (
|
||||
id serial primary key,
|
||||
name text not null,
|
||||
added_by text not null
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -555,7 +534,7 @@ args:
|
||||
permission:
|
||||
columns: [name]
|
||||
filter:
|
||||
added_by: "X-Hasura-User-Id"
|
||||
added_by: X-Hasura-User-Id
|
||||
check:
|
||||
name:
|
||||
_ne: ""
|
||||
_ne: ''
|
||||
|
@ -26,13 +26,18 @@ args:
|
||||
|
||||
|
||||
#Create blog table
|
||||
|
||||
#Insert Author table data
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO blog (id, title, author_id) VALUES
|
||||
(1, 'first blog', 1), (2, 'second blog', 2);
|
||||
insert into "user" (name, is_admin)
|
||||
values ('user_1', false), ('user_2', true)
|
||||
;
|
||||
|
||||
#Insert residents
|
||||
- type: insert
|
||||
args:
|
||||
table: resident
|
||||
@ -45,9 +50,3 @@ args:
|
||||
age: 22
|
||||
|
||||
#Insert users
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into "user" (name, is_admin)
|
||||
values ('user_1', false), ('user_2', true)
|
||||
;
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,15 +11,6 @@ args:
|
||||
name text unique,
|
||||
is_registered boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,30 +18,31 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
create view author_simple as
|
||||
select * from author;
|
||||
create view author_complex as
|
||||
select a.id as author_id, b.title as article_title
|
||||
from author a join article b on (a.id = b.author_id);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Create author simple view
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create view author_simple as
|
||||
select * from author;
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author_simple
|
||||
|
||||
#Create author complex view
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create view author_complex as
|
||||
select a.id as author_id, b.title as article_title
|
||||
from author a join article b on (a.id = b.author_id);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -20,15 +21,6 @@ args:
|
||||
info jsonb,
|
||||
location geography
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -36,7 +28,29 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
);
|
||||
SET lc_monetary TO "en_US.utf-8";
|
||||
CREATE TABLE numerics (
|
||||
id SERIAL PRIMARY KEY,
|
||||
num_smallint SMALLINT,
|
||||
num_integer INTEGER,
|
||||
num_bigint BIGINT,
|
||||
num_real REAL,
|
||||
num_double DOUBLE PRECISION,
|
||||
num_money MONEY,
|
||||
num_numeric NUMERIC
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -63,13 +77,6 @@ args:
|
||||
|
||||
#Person table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -77,20 +84,6 @@ args:
|
||||
|
||||
#Numerics table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET lc_monetary TO "en_US.utf-8";
|
||||
CREATE TABLE numerics (
|
||||
id SERIAL PRIMARY KEY,
|
||||
num_smallint SMALLINT,
|
||||
num_integer INTEGER,
|
||||
num_bigint BIGINT,
|
||||
num_real REAL,
|
||||
num_double DOUBLE PRECISION,
|
||||
num_money MONEY,
|
||||
num_numeric NUMERIC
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,13 +2,15 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Person table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,15 +11,6 @@ args:
|
||||
name text unique,
|
||||
user_id int
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL,
|
||||
title TEXT,
|
||||
@ -39,7 +31,33 @@ args:
|
||||
OR content ilike ('%' || search || '%')
|
||||
) AND author_id = author_row.id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
);
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
age INTEGER NOT NULL,
|
||||
city TEXT NOT NULL
|
||||
);
|
||||
create table "user" (
|
||||
id serial primary key,
|
||||
name text not null unique,
|
||||
is_admin boolean default false
|
||||
);
|
||||
|
||||
create table account (
|
||||
id serial primary key,
|
||||
account_no integer not null
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -73,13 +91,6 @@ args:
|
||||
|
||||
#Person table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE person (
|
||||
id SERIAL PRIMARY KEY,
|
||||
details JSONB NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -140,16 +151,6 @@ args:
|
||||
is_published: false
|
||||
|
||||
#Resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
age INTEGER NOT NULL,
|
||||
city TEXT NOT NULL
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: resident
|
||||
@ -191,20 +192,6 @@ args:
|
||||
city: X-Hasura-City
|
||||
|
||||
# Tables to test '_exist' field
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table "user" (
|
||||
id serial primary key,
|
||||
name text not null unique,
|
||||
is_admin boolean default false
|
||||
);
|
||||
|
||||
create table account (
|
||||
id serial primary key,
|
||||
account_no integer not null
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: user
|
||||
|
@ -36,6 +36,9 @@ args:
|
||||
is_published: false
|
||||
|
||||
#Resident table
|
||||
|
||||
#Insert Author table data
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -44,12 +47,8 @@ args:
|
||||
, ('george', 26, 'sydney')
|
||||
, ('clarke', 21, 'perth')
|
||||
;
|
||||
|
||||
#Insert users and accounts
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into "user" (name, is_admin)
|
||||
values ('user_1', false), ('user_2', true)
|
||||
;
|
||||
insert into account (account_no) values (1), (2) ;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -173,7 +174,7 @@ args:
|
||||
table: article
|
||||
role: role_with_access_to_cols
|
||||
permission:
|
||||
columns: "*"
|
||||
columns: '*'
|
||||
filter: {}
|
||||
allow_aggregations: true
|
||||
limit: 1
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +17,41 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
)
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2');
|
||||
insert into article (title,content,author_id,is_published,published_on)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false,
|
||||
'1999-01-08 04:05:06'
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true,
|
||||
'1999-01-08 04:05:07'
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true,
|
||||
'1999-01-09 04:05:06'
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -51,37 +77,3 @@ args:
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published,published_on)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false,
|
||||
'1999-01-08 04:05:06'
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true,
|
||||
'1999-01-08 04:05:07'
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true,
|
||||
'1999-01-09 04:05:06'
|
||||
)
|
||||
|
@ -1,6 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,6 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -8,32 +9,13 @@ args:
|
||||
r double precision,
|
||||
i double precision
|
||||
);
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TYPE inventory_item AS (
|
||||
name text,
|
||||
supplier_id integer,
|
||||
price numeric
|
||||
);
|
||||
|
||||
#Set timezone
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
#Set money locale
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET lc_monetary TO "en_US.utf-8";
|
||||
|
||||
#Test table with different types
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table test_types (
|
||||
c1_smallint smallint,
|
||||
c2_integer integer,
|
||||
@ -81,30 +63,11 @@ args:
|
||||
c44_xml xml,
|
||||
c45_money money
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: test_types
|
||||
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique,
|
||||
"createdAt" timestamptz
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -112,36 +75,7 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into test_types
|
||||
( c1_smallint
|
||||
, c2_integer
|
||||
@ -229,20 +163,11 @@ args:
|
||||
, '(2011-02-05T12:03:00+00:00, 2012-03-04T16:40:04+00:00]' -- c43_range_timestamptz
|
||||
, '<foo>bar</foo>' -- c44_xml
|
||||
, 123.45 -- c45_money
|
||||
)
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name, "createdAt")
|
||||
values
|
||||
('Author 1', '2017-09-21T09:39:44Z'),
|
||||
('Author 2', '2017-09-21T09:50:44Z')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 2', '2017-09-21T09:50:44Z');
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
@ -262,17 +187,57 @@ args:
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
)
|
||||
|
||||
#User table with bigserial and bigint columns
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE "user" (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
number BIGINT
|
||||
);
|
||||
create extension if not exists citext;
|
||||
create table person (
|
||||
id serial primary key,
|
||||
name citext
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: test_types
|
||||
|
||||
|
||||
#Author table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Insert values
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -286,14 +251,6 @@ args:
|
||||
- name: User 2
|
||||
number: '123456780'
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create extension if not exists citext;
|
||||
create table person (
|
||||
id serial primary key,
|
||||
name citext
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -302,6 +259,6 @@ args:
|
||||
args:
|
||||
table: person
|
||||
objects:
|
||||
- name: "John\\"
|
||||
- name: "Clarke"
|
||||
- name: "clarke"
|
||||
- name: John\
|
||||
- name: Clarke
|
||||
- name: clarke
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,15 +11,13 @@ args:
|
||||
name text unique,
|
||||
is_registered boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO author(name, is_registered)
|
||||
VALUES
|
||||
('Author 1', true),
|
||||
('Author 2', true),
|
||||
('Author 3', false);
|
||||
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,142 +25,72 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
);
|
||||
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE city (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
country TEXT NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
);
|
||||
|
||||
INSERT INTO city (name, country)
|
||||
VALUES
|
||||
('Durham', 'USA'),
|
||||
('New York', 'USA'),
|
||||
('Framlingham', 'UK'),
|
||||
('New Orleans', 'USA');
|
||||
|
||||
#Set timezone
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
#Article order
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
received_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
delivered_at TIMESTAMP WITH TIME ZONE
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
);
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Message table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE message (
|
||||
id int PRIMARY KEY,
|
||||
content TEXT NOT NULL,
|
||||
parent_id INT NULL
|
||||
);
|
||||
|
||||
INSERT INTO message (id, content, parent_id)
|
||||
VALUES
|
||||
(
|
||||
1,
|
||||
'hello world',
|
||||
default
|
||||
),
|
||||
(
|
||||
2,
|
||||
'content 2',
|
||||
1
|
||||
),
|
||||
(
|
||||
3,
|
||||
'content 3',
|
||||
1
|
||||
),
|
||||
(
|
||||
4,
|
||||
'ahoy',
|
||||
default
|
||||
),
|
||||
(
|
||||
5,
|
||||
'content 5',
|
||||
4
|
||||
),
|
||||
(
|
||||
6,
|
||||
'hello three',
|
||||
4
|
||||
);
|
||||
|
||||
alter table message
|
||||
add constraint parent_fk foreign key (parent_id)
|
||||
references message(id)
|
||||
references message(id);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: message
|
||||
|
||||
# parent obj rel
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: message
|
||||
name: parent
|
||||
using:
|
||||
foreign_key_constraint_on: parent_id
|
||||
|
||||
# children array rel
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: message
|
||||
name: children
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: message
|
||||
column: parent_id
|
||||
|
||||
#Insert messages
|
||||
- type: insert
|
||||
args:
|
||||
table: message
|
||||
objects:
|
||||
- id: 1
|
||||
content: "hello world"
|
||||
parent_id: null
|
||||
- id: 2
|
||||
content: "content 2"
|
||||
parent_id: 1
|
||||
- id: 3
|
||||
content: "content 3"
|
||||
parent_id: 1
|
||||
- id: 4
|
||||
content: "ahoy"
|
||||
parent_id: null
|
||||
- id: 5
|
||||
content: "content 5"
|
||||
parent_id: 4
|
||||
- id: 6
|
||||
content: "hello there"
|
||||
parent_id: 4
|
||||
|
||||
#Insert Authors
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
is_registered: true
|
||||
- name: Author 2
|
||||
is_registered: true
|
||||
- name: Author 3
|
||||
is_registered: false
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
@ -187,53 +116,12 @@ args:
|
||||
'Sample article content 4',
|
||||
3,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: city
|
||||
objects:
|
||||
- name: Durham
|
||||
country: USA
|
||||
- name: New York
|
||||
country: USA
|
||||
- name: Framlingham
|
||||
country: UK
|
||||
- name: New Orleans
|
||||
country: USA
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: orders
|
||||
objects:
|
||||
- received_at: '2018-09-21T09:39:44Z'
|
||||
- received_at: '2018-09-21T09:40:44Z'
|
||||
delivered_at: '2018-09-21T09:50:44Z'
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "uuid_test" (
|
||||
id serial primary key,
|
||||
uuid_col UUID NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
name: uuid_test
|
||||
schema: public
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: uuid_test
|
||||
objects:
|
||||
- uuid_col: 28d6d683-1317-49f7-b1cf-7d195242e4e5
|
||||
- uuid_col: 28d6d683-1317-49f7-b1cf-7d195242e4e6
|
||||
- uuid_col: 28d6d683-1317-49f7-b1cf-7d195242e4e7
|
||||
|
||||
# Tables to test '_exist' field
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
create table "user" (
|
||||
id serial primary key,
|
||||
name text not null unique,
|
||||
@ -250,7 +138,101 @@ args:
|
||||
);
|
||||
|
||||
insert into account (account_no) values (1), (2) ;
|
||||
CREATE TABLE table_with_sql_identifier
|
||||
( id serial PRIMARY KEY
|
||||
, sql_id information_schema.sql_identifier );
|
||||
INSERT INTO table_with_sql_identifier (sql_id)
|
||||
VALUES ('one'), ('one'), ('two'), ('three'), ('four'), ('one'), ('two');
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Set timezone
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Message table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: message
|
||||
|
||||
# parent obj rel
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: message
|
||||
name: parent
|
||||
using:
|
||||
foreign_key_constraint_on: parent_id
|
||||
|
||||
# children array rel
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: message
|
||||
name: children
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: message
|
||||
column: parent_id
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: orders
|
||||
objects:
|
||||
- received_at: '2018-09-21T09:39:44Z'
|
||||
- received_at: '2018-09-21T09:40:44Z'
|
||||
delivered_at: '2018-09-21T09:50:44Z'
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: uuid_test
|
||||
schema: public
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: uuid_test
|
||||
objects:
|
||||
- uuid_col: 28d6d683-1317-49f7-b1cf-7d195242e4e5
|
||||
- uuid_col: 28d6d683-1317-49f7-b1cf-7d195242e4e6
|
||||
- uuid_col: 28d6d683-1317-49f7-b1cf-7d195242e4e7
|
||||
|
||||
# Tables to test '_exist' field
|
||||
- type: track_table
|
||||
args:
|
||||
name: user
|
||||
@ -276,13 +258,5 @@ args:
|
||||
id: X-Hasura-User-Id
|
||||
is_admin: true
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE table_with_sql_identifier
|
||||
( id serial PRIMARY KEY
|
||||
, sql_id information_schema.sql_identifier );
|
||||
INSERT INTO table_with_sql_identifier (sql_id)
|
||||
VALUES ('one'), ('one'), ('two'), ('three'), ('four'), ('one'), ('two');
|
||||
- type: track_table
|
||||
args: table_with_sql_identifier
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,21 +18,29 @@ args:
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP,
|
||||
tags JSONB
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE product (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL,
|
||||
spec JSONB NOT NULL
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2');
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -67,14 +67,6 @@ args:
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
|
@ -1,67 +1,32 @@
|
||||
type: bulk
|
||||
args:
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
DO $$
|
||||
BEGIN
|
||||
IF PostGIS_lib_version() ~ '^3.*' THEN
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_raster;
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
|
||||
#Create table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
CREATE TABLE geom_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
type TEXT NOT NULL,
|
||||
geom_col geometry NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
name: geom_table
|
||||
schema: public
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE geog_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
geog_col geography NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_table
|
||||
schema: public
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE geog_as_geom_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
geom_col geometry NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_as_geom_table
|
||||
schema: public
|
||||
|
||||
#Insert data
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO geom_table (type, geom_col)
|
||||
VALUES
|
||||
('point', ST_GeomFromEWKT('SRID=4326;POINT(1 2)')),
|
||||
@ -70,9 +35,6 @@ args:
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))')),
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((2 0, 2 1, 3 1, 3 0, 2 0))'))
|
||||
;
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO geog_table (name, geog_col)
|
||||
VALUES
|
||||
('London', ST_GeographyFromText('SRID=4326;POINT(0.1278 51.5074)') ),
|
||||
@ -81,12 +43,24 @@ args:
|
||||
('New York', ST_GeographyFromText('SRID=4326;POINT(-74.0060 40.7128)') ),
|
||||
('Linestring', ST_GeographyFromText('SRID=4326;LINESTRING(0.0 0.0,0.0 1.0)')),
|
||||
('Point', ST_GeographyFromText('SRID=4326;POINT(0.0 0.5)'));
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO geog_as_geom_table (name, geom_col)
|
||||
VALUES
|
||||
('London', ST_GeomFromEWKT('SRID=4326;POINT(0.1278 51.5074)')),
|
||||
('Paris', ST_GeomFromEWKT('SRID=4326;POINT(2.3522 48.8566)')),
|
||||
('Moscow', ST_GeomFromEWKT('SRID=4326;POINT(37.6173 55.7558)')),
|
||||
('New York', ST_GeomFromEWKT('SRID=4326;POINT(-74.0060 40.7128)'));
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: geom_table
|
||||
schema: public
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_table
|
||||
schema: public
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_as_geom_table
|
||||
schema: public
|
||||
|
||||
#Insert data
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Create required extensions, tables and insert test data
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -22,6 +23,7 @@ args:
|
||||
(ST_AsRaster(ST_Buffer(ST_GeomFromEWKT('SRID=4326;POINT(1 2)'),2), 5, 5))
|
||||
, (ST_AsRaster(ST_Buffer(ST_GeomFromEWKT('SRID=4326;LINESTRING(0 0, 0.5 1, 1 2, 1.5 3)'), 2), 5, 5))
|
||||
;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: dummy_rast
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,60 +17,17 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE city (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
country TEXT NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2'),
|
||||
('Author 3')
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 3') ;
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
@ -104,8 +53,46 @@ args:
|
||||
'Sample article content 4',
|
||||
3,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: insert
|
||||
args:
|
||||
table: city
|
||||
|
@ -1,9 +1,11 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE users (id serial PRIMARY KEY, name text NOT NULL);
|
||||
INSERT INTO users (name) VALUES ('Alyssa'), ('Ben');
|
||||
|
||||
- type: track_table
|
||||
args: users
|
||||
|
@ -1,5 +1,9 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,5 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -1,6 +1,9 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
# A user can query only code but not country
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Article table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,16 +10,7 @@ args:
|
||||
id serial PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: post
|
||||
|
||||
#Search post function
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
create function search_posts(search text)
|
||||
returns setof post as $$
|
||||
select *
|
||||
@ -27,24 +19,10 @@ args:
|
||||
title ilike ('%' || search || '%') or
|
||||
content ilike ('%' || search || '%')
|
||||
$$ language sql stable;
|
||||
- type: track_function
|
||||
args:
|
||||
name: search_posts
|
||||
schema: public
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into post (title, content)
|
||||
values
|
||||
('post by hasura', 'content for post'),
|
||||
('post by another', 'content for another post')
|
||||
|
||||
# Table with uuid column
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('post by another', 'content for another post');
|
||||
create table test(
|
||||
id serial primary key,
|
||||
name text not null,
|
||||
@ -65,29 +43,6 @@ args:
|
||||
returns setof test as $$
|
||||
select * from test where id = (hasura_session ->> 'x-hasura-user-id')::Int
|
||||
$$ language sql stable;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: test
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
args:
|
||||
name: get_test
|
||||
schema: public
|
||||
- type: track_function
|
||||
version: 2
|
||||
args:
|
||||
function:
|
||||
name: get_test_session_id
|
||||
schema: public
|
||||
configuration:
|
||||
session_argument: hasura_session
|
||||
|
||||
# custom add sql function
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE integer_column
|
||||
(
|
||||
result integer
|
||||
@ -97,39 +52,16 @@ args:
|
||||
RETURNS SETOF integer_column as $$
|
||||
SELECT q.* FROM (VALUES (first + second)) as q
|
||||
$$ LANGUAGE SQL STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: integer_column
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
args:
|
||||
name: my_add
|
||||
schema: public
|
||||
|
||||
# test functions having multiple defaults
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "user" (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
is_admin BOOLEAN DEFAULT FALSE
|
||||
);
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO "user" (name, is_admin) VALUES
|
||||
('Starke Blake', true)
|
||||
, ('Bellamy Blake', true)
|
||||
, ('Dora Blake', true)
|
||||
;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE FUNCTION get_users(search text, integer default 10, boolean default false)
|
||||
RETURNS SETOF "user" AS $$
|
||||
SELECT *
|
||||
@ -139,21 +71,6 @@ args:
|
||||
AND is_admin = $3
|
||||
LIMIT $2
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: user
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
args:
|
||||
name: get_users
|
||||
schema: public
|
||||
|
||||
# V2 Functions
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE text_result(
|
||||
result text
|
||||
);
|
||||
@ -162,25 +79,6 @@ args:
|
||||
RETURNS SETOF text_result AS $$
|
||||
SELECT q.* FROM (VALUES (hasura_session ->> session_var)) q
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: text_result
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
version: 2
|
||||
args:
|
||||
function:
|
||||
schema: public
|
||||
name: get_session_var
|
||||
configuration:
|
||||
session_argument: hasura_session
|
||||
|
||||
# track & query functions that return SETOF materialized views
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE author(
|
||||
id SERIAL PRIMARY KEY,
|
||||
first_name TEXT,
|
||||
@ -202,6 +100,74 @@ args:
|
||||
last_name = query
|
||||
$FUNCTION$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: post
|
||||
|
||||
#Search post function
|
||||
- type: track_function
|
||||
args:
|
||||
name: search_posts
|
||||
schema: public
|
||||
|
||||
#Insert values
|
||||
- type: track_table
|
||||
args:
|
||||
name: test
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
args:
|
||||
name: get_test
|
||||
schema: public
|
||||
- type: track_function
|
||||
version: 2
|
||||
args:
|
||||
function:
|
||||
name: get_test_session_id
|
||||
schema: public
|
||||
configuration:
|
||||
session_argument: hasura_session
|
||||
|
||||
# custom add sql function
|
||||
- type: track_table
|
||||
args:
|
||||
name: integer_column
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
args:
|
||||
name: my_add
|
||||
schema: public
|
||||
|
||||
# test functions having multiple defaults
|
||||
- type: track_table
|
||||
args:
|
||||
name: user
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
args:
|
||||
name: get_users
|
||||
schema: public
|
||||
|
||||
# V2 Functions
|
||||
- type: track_table
|
||||
args:
|
||||
name: text_result
|
||||
schema: public
|
||||
|
||||
- type: track_function
|
||||
version: 2
|
||||
args:
|
||||
function:
|
||||
schema: public
|
||||
name: get_session_var
|
||||
configuration:
|
||||
session_argument: hasura_session
|
||||
|
||||
# track & query functions that return SETOF materialized views
|
||||
- type: track_table
|
||||
args:
|
||||
name: author
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,31 +17,11 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 2') ;
|
||||
insert into article (title,content,author_id)
|
||||
values
|
||||
(
|
||||
@ -66,5 +38,24 @@ args:
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,31 +17,11 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 2');
|
||||
insert into article (title,content,author_id)
|
||||
values
|
||||
(
|
||||
@ -66,5 +38,24 @@ args:
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Contact table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,30 +10,12 @@ args:
|
||||
id SERIAL PRIMARY KEY,
|
||||
phone INTEGER,
|
||||
address TEXT
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: contact
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique,
|
||||
contact_id INTEGER REFERENCES contact(id)
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -40,7 +23,87 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
insert into contact (phone)
|
||||
values
|
||||
(1234567890),
|
||||
(1234567891);
|
||||
insert into author (name, contact_id)
|
||||
values
|
||||
('Author 1', 2),
|
||||
('Author 2', 1);
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
);
|
||||
create table "Album" (
|
||||
album_id INTEGER NOT NULL PRIMARY KEY,
|
||||
title TEXT NOT NULL
|
||||
);
|
||||
create table "Track" (
|
||||
track_id INTEGER NOT NULL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
album_id INTEGER REFERENCES "Album"(album_id),
|
||||
milliseconds INTEGER NOT NULL,
|
||||
bytes INTEGER NOT NULL
|
||||
);
|
||||
insert into "Album" (album_id, title)
|
||||
values ( 1, 'Big Ones' ), (2, 'Face Lift');
|
||||
insert into "Track"
|
||||
(track_id, name, album_id, milliseconds, bytes)
|
||||
values
|
||||
( 1, 'Restless', 1, 123654, 9836284),
|
||||
( 2, 'Keepup', 1, 637483, 6382913) ,
|
||||
( 3, 'Havana', 1, 234512, 986384) ,
|
||||
( 4, 'Evil Walks', 2, 437294, 6284302) ,
|
||||
( 5, 'Random', 2, 1094732, 6032547) ,
|
||||
( 6, 'Good One', 2, 346208, 6732987) ,
|
||||
( 7, 'Mistress', 2, 420985, 7521946);
|
||||
CREATE table "Tag" (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
album_id INTEGER NOT NULL REFERENCES "Album"(album_id)
|
||||
);
|
||||
INSERT INTO "Tag" (name, album_id)
|
||||
VALUES
|
||||
( 'Rock', 1),
|
||||
( 'Folk', 1),
|
||||
( 'Hip Hop', 2);
|
||||
CREATE TABLE employee (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
department TEXT,
|
||||
salary INTEGER
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: contact
|
||||
|
||||
#Author table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -72,69 +135,11 @@ args:
|
||||
column: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into contact (phone)
|
||||
values
|
||||
(1234567890),
|
||||
(1234567891)
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name, contact_id)
|
||||
values
|
||||
('Author 1', 2),
|
||||
('Author 2', 1)
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
)
|
||||
|
||||
# Album - Track Schema
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table "Album" (
|
||||
album_id INTEGER NOT NULL PRIMARY KEY,
|
||||
title TEXT NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: Album
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table "Track" (
|
||||
track_id INTEGER NOT NULL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
album_id INTEGER REFERENCES "Album"(album_id),
|
||||
milliseconds INTEGER NOT NULL,
|
||||
bytes INTEGER NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -157,41 +162,6 @@ args:
|
||||
column: album_id
|
||||
|
||||
# Insert values in Album and Track
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into "Album" (album_id, title)
|
||||
values ( 1, 'Big Ones' ), (2, 'Face Lift')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into "Track"
|
||||
(track_id, name, album_id, milliseconds, bytes)
|
||||
values
|
||||
( 1, 'Restless', 1, 123654, 9836284),
|
||||
( 2, 'Keepup', 1, 637483, 6382913) ,
|
||||
( 3, 'Havana', 1, 234512, 986384) ,
|
||||
( 4, 'Evil Walks', 2, 437294, 6284302) ,
|
||||
( 5, 'Random', 2, 1094732, 6032547) ,
|
||||
( 6, 'Good One', 2, 346208, 6732987) ,
|
||||
( 7, 'Mistress', 2, 420985, 7521946)
|
||||
|
||||
# Create Tag table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE table "Tag" (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
album_id INTEGER NOT NULL REFERENCES "Album"(album_id)
|
||||
);
|
||||
INSERT INTO "Tag" (name, album_id)
|
||||
VALUES
|
||||
( 'Rock', 1),
|
||||
( 'Folk', 1),
|
||||
( 'Hip Hop', 2);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: Tag
|
||||
@ -207,15 +177,6 @@ args:
|
||||
column: album_id
|
||||
|
||||
# Create employee table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE employee (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
department TEXT,
|
||||
salary INTEGER
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
name: employee
|
||||
|
@ -1,7 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -11,15 +10,13 @@ args:
|
||||
is_registered boolean not null default false,
|
||||
remarks_internal text
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO author (name, remarks_internal)
|
||||
VALUES
|
||||
('Author 1', 'remark 1'),
|
||||
('Author 2', 'remark 2'),
|
||||
('Author 3', 'remark 3');
|
||||
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -27,7 +24,126 @@ args:
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN NOT NULL default FALSE,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
|
||||
INSERT INTO article (title, content, author_id, is_published)
|
||||
VALUES
|
||||
('Article 1', 'Sample article content 1', 1, false),
|
||||
('Article 2', 'Sample article content 2', 1, true),
|
||||
('Article 3', 'Sample article content 3', 2, true),
|
||||
('Article 4', 'Sample article content 4', 3, false);
|
||||
|
||||
CREATE TABLE "Artist" (
|
||||
id serial PRIMARY KEY ,
|
||||
name text NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO "Artist" (id, name)
|
||||
VALUES
|
||||
(1, 'Camilla'),
|
||||
(2, 'DSP'),
|
||||
(3, 'Akon');
|
||||
|
||||
CREATE TABLE "Track" (
|
||||
id serial PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
artist_id integer REFERENCES "Artist"("id")
|
||||
);
|
||||
|
||||
INSERT INTO "Track" (id, name, artist_id)
|
||||
VALUES
|
||||
(1, 'Keepup', 1),
|
||||
(2, 'Keepdown', 1),
|
||||
(3, 'Happy', 2);
|
||||
|
||||
create function search_tracks(search text)
|
||||
returns setof "Track" as $$
|
||||
select *
|
||||
from "Track"
|
||||
where
|
||||
name ilike ('%' || search || '%')
|
||||
$$ language sql stable;
|
||||
|
||||
CREATE TABLE books (
|
||||
id int,
|
||||
author_name text,
|
||||
book_name text,
|
||||
published_on timestamptz,
|
||||
PRIMARY KEY (id,book_name)
|
||||
);
|
||||
|
||||
INSERT INTO books (id, author_name, book_name, published_on)
|
||||
VALUES (1, 'J.K. Rowling', 'Harry Porter', '1997-06-26');
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF PostGIS_lib_version() ~ '^3.*' THEN
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_raster;
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
|
||||
CREATE TABLE geom_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
type TEXT NOT NULL,
|
||||
geom_col geometry NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO geom_table (type, geom_col)
|
||||
VALUES
|
||||
('point', ST_GeomFromEWKT('SRID=4326;POINT(1 2)')),
|
||||
('linestring', ST_GeomFromEWKT('SRID=4326;LINESTRING(0 0, 0.5 1, 1 2, 1.5 3)')),
|
||||
('linestring', ST_GeomFromEWKT('SRID=4326;LINESTRING(1 0, 0.5 0.5, 0 1)')),
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))')),
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((2 0, 2 1, 3 1, 3 0, 2 0))'))
|
||||
;
|
||||
|
||||
CREATE TABLE jsonb_table(
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
jsonb_col jsonb NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO jsonb_table (id, jsonb_col)
|
||||
VALUES
|
||||
(1, '{"name": "Hasura", "age": 7}'),
|
||||
(2, '{"name": "Cross"}');
|
||||
|
||||
CREATE TABLE gpa (
|
||||
id serial primary key,
|
||||
student_name text not null,
|
||||
gpa_score double precision not null
|
||||
);
|
||||
|
||||
INSERT INTO gpa (student_name, gpa_score) VALUES
|
||||
('clarke', 9.24), ('george', 8.32),
|
||||
('blake', 7.34), ('leonel', 9.56);
|
||||
|
||||
CREATE FUNCTION passed_students (pass_gpa double precision)
|
||||
RETURNS SETOF gpa as $$
|
||||
SELECT * FROM gpa WHERE
|
||||
gpa_score >= pass_gpa
|
||||
$$ language SQL STABLE;
|
||||
CREATE TABLE auction (
|
||||
id serial primary key,
|
||||
price integer not null DEFAULT 250,
|
||||
bid_price integer
|
||||
);
|
||||
|
||||
INSERT INTO auction
|
||||
(bid_price)
|
||||
VALUES
|
||||
(100), (120), (300), (260)
|
||||
;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -132,98 +248,18 @@ args:
|
||||
check:
|
||||
id: X-HASURA-USER-ID
|
||||
|
||||
#Insert Author values
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
remarks_internal: remark 1
|
||||
- name: Author 2
|
||||
remarks_internal: remark 2
|
||||
- name: Author 3
|
||||
remarks_internal: remark 3
|
||||
|
||||
#Insert Article values
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- title: Article 1
|
||||
content: Sample article content 1
|
||||
author_id: 1
|
||||
is_published: false
|
||||
|
||||
- title: Article 2
|
||||
content: Sample article content 2
|
||||
author_id: 1
|
||||
is_published: true
|
||||
|
||||
- title: Article 3
|
||||
content: Sample article content 3
|
||||
author_id: 2
|
||||
is_published: true
|
||||
|
||||
- title: Article 4
|
||||
content: Sample article content 4
|
||||
author_id: 3
|
||||
is_published: false
|
||||
|
||||
#Create Artist table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "Artist" (
|
||||
id serial PRIMARY KEY ,
|
||||
name text NOT NULL
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: Artist
|
||||
|
||||
#Crete Track table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "Track" (
|
||||
id serial PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
artist_id integer REFERENCES "Artist"("id")
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: Track
|
||||
|
||||
# Insert data into Artist and Track table
|
||||
- type: insert
|
||||
args:
|
||||
table: Artist
|
||||
objects:
|
||||
- name: Camilla
|
||||
id: 1
|
||||
- name: DSP
|
||||
id: 2
|
||||
- name: Akon
|
||||
id: 3
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: Track
|
||||
objects:
|
||||
- name: Keepup
|
||||
artist_id: 1
|
||||
id: 1
|
||||
- name: Keepdown
|
||||
artist_id: 1
|
||||
id: 2
|
||||
- name: Happy
|
||||
artist_id: 2
|
||||
id: 3
|
||||
|
||||
#Object relationship Track::artist_id -> Artist::id
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
@ -278,89 +314,25 @@ args:
|
||||
_iregex: X-Hasura-IRegex-Artists
|
||||
|
||||
# Create search_track function
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create function search_tracks(search text)
|
||||
returns setof "Track" as $$
|
||||
select *
|
||||
from "Track"
|
||||
where
|
||||
name ilike ('%' || search || '%')
|
||||
$$ language sql stable;
|
||||
|
||||
- type: track_function
|
||||
args:
|
||||
name: search_tracks
|
||||
schema: public
|
||||
|
||||
#Create Books table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE books (
|
||||
id int,
|
||||
author_name text,
|
||||
book_name text,
|
||||
published_on timestamptz,
|
||||
PRIMARY KEY (id,book_name)
|
||||
);
|
||||
|
||||
# Track table Books
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: books
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: books
|
||||
objects:
|
||||
- id: 1
|
||||
author_name: J.K. Rowling
|
||||
book_name: Harry Porter
|
||||
published_on: "1997-06-26"
|
||||
|
||||
#Create select permission on books, granting permission only to one of the columns of the primary key
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: books
|
||||
role: user
|
||||
permission:
|
||||
columns: ["author_name","book_name","published_on"]
|
||||
columns: [author_name, book_name, published_on]
|
||||
filter: {}
|
||||
|
||||
#Permission based on PostGIS operators
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DO $$
|
||||
BEGIN
|
||||
IF PostGIS_lib_version() ~ '^3.*' THEN
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_raster;
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
|
||||
#Create table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE geom_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
type TEXT NOT NULL,
|
||||
geom_col geometry NOT NULL
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: geom_table
|
||||
@ -413,45 +385,11 @@ args:
|
||||
distance: X-Hasura-Geom-Dist
|
||||
from: X-Hasura-Geom-Val
|
||||
#Insert data
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO geom_table (type, geom_col)
|
||||
VALUES
|
||||
('point', ST_GeomFromEWKT('SRID=4326;POINT(1 2)')),
|
||||
('linestring', ST_GeomFromEWKT('SRID=4326;LINESTRING(0 0, 0.5 1, 1 2, 1.5 3)')),
|
||||
('linestring', ST_GeomFromEWKT('SRID=4326;LINESTRING(1 0, 0.5 0.5, 0 1)')),
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))')),
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((2 0, 2 1, 3 1, 3 0, 2 0))'))
|
||||
;
|
||||
|
||||
|
||||
#Permission based on JSONB operators
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE jsonb_table(
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
jsonb_col jsonb NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
name: jsonb_table
|
||||
schema: public
|
||||
|
||||
#Insert data
|
||||
- type: insert
|
||||
args:
|
||||
table: jsonb_table
|
||||
objects:
|
||||
- id: 1
|
||||
jsonb_col:
|
||||
name: Hasura
|
||||
age: 7
|
||||
- id: 2
|
||||
jsonb_col:
|
||||
name: Cross
|
||||
|
||||
#Create select permission using jsonb operator
|
||||
- type: create_select_permission
|
||||
args:
|
||||
@ -504,25 +442,6 @@ args:
|
||||
$has_keys_all: X-Hasura-Json-Required-Keys
|
||||
|
||||
#Create grade_point table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE gpa (
|
||||
id serial primary key,
|
||||
student_name text not null,
|
||||
gpa_score double precision not null
|
||||
);
|
||||
|
||||
INSERT INTO gpa (student_name, gpa_score) VALUES
|
||||
('clarke', 9.24), ('george', 8.32),
|
||||
('blake', 7.34), ('leonel', 9.56);
|
||||
|
||||
CREATE FUNCTION passed_students (pass_gpa double precision)
|
||||
RETURNS SETOF gpa as $$
|
||||
SELECT * FROM gpa WHERE
|
||||
gpa_score >= pass_gpa
|
||||
$$ language SQL STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: gpa
|
||||
@ -540,21 +459,6 @@ args:
|
||||
- id
|
||||
- student_name
|
||||
filter: {}
|
||||
|
||||
#Auction table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE auction (
|
||||
id serial primary key,
|
||||
price integer not null DEFAULT 250,
|
||||
bid_price integer
|
||||
);
|
||||
INSERT INTO auction
|
||||
(bid_price)
|
||||
VALUES
|
||||
(100), (120), (300), (260)
|
||||
;
|
||||
- type: track_table
|
||||
args:
|
||||
name: auction
|
||||
@ -589,5 +493,5 @@ args:
|
||||
table: author
|
||||
role: critic
|
||||
permission:
|
||||
columns: ["name"]
|
||||
columns: [name]
|
||||
filter: {}
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -80,7 +81,6 @@ args:
|
||||
('first_1', 'last_1', 24, null),
|
||||
('first_2', 'last_2', null, 'Bangalore');
|
||||
|
||||
# Track tables and define relationships
|
||||
- type: track_table
|
||||
args:
|
||||
name: author
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -58,7 +59,6 @@ args:
|
||||
true
|
||||
);
|
||||
|
||||
# Track tables and define relationships
|
||||
- type: track_table
|
||||
args:
|
||||
name: author
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -51,7 +52,6 @@ args:
|
||||
3
|
||||
);
|
||||
|
||||
# Track tables and define relationships
|
||||
- type: track_table
|
||||
args:
|
||||
name: author
|
||||
|
@ -11,6 +11,7 @@ args:
|
||||
# );
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -19,15 +20,6 @@ args:
|
||||
name text unique,
|
||||
"createdAt" timestamptz
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -35,7 +27,44 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
insert into author (name, "createdAt")
|
||||
values
|
||||
('Author 1', '2017-09-21T09:39:44Z'),
|
||||
('Author 2', '2017-09-21T09:50:44Z');
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
);
|
||||
CREATE TABLE "user" (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
number BIGINT
|
||||
);
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -62,47 +91,6 @@ args:
|
||||
column: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name, "createdAt")
|
||||
values
|
||||
('Author 1', '2017-09-21T09:39:44Z'),
|
||||
('Author 2', '2017-09-21T09:50:44Z')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
)
|
||||
|
||||
#User table with bigserial and bigint columns
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "user" (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
number BIGINT
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -117,7 +105,3 @@ args:
|
||||
number: '123456780'
|
||||
|
||||
#Set timezone
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
@ -1,21 +1,26 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
|
||||
# Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
create table author(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT UNIQUE,
|
||||
location GEOGRAPHY(Point)
|
||||
);
|
||||
create table article(
|
||||
id SERIAL PRIMARY KEY,
|
||||
body JSONB
|
||||
);
|
||||
create table misgivings(
|
||||
i INTEGER,
|
||||
f REAL
|
||||
);
|
||||
insert into misgivings values (43, 102);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -23,13 +28,6 @@ args:
|
||||
|
||||
|
||||
# Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table article(
|
||||
id SERIAL PRIMARY KEY,
|
||||
body JSONB
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -37,17 +35,6 @@ args:
|
||||
|
||||
|
||||
# Some other table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table misgivings(
|
||||
i INTEGER,
|
||||
f REAL
|
||||
);
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into misgivings values (43, 102);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -17,12 +18,12 @@ args:
|
||||
name: simple1-graphql
|
||||
comment: testing
|
||||
definition:
|
||||
url: "{{REMOTE_SCHEMAS_WEBHOOK_DOMAIN}}/user-graphql"
|
||||
url: '{{REMOTE_SCHEMAS_WEBHOOK_DOMAIN}}/user-graphql'
|
||||
forward_client_headers: false
|
||||
- type: add_remote_schema
|
||||
args:
|
||||
name: simple2-graphql
|
||||
comment: testing
|
||||
definition:
|
||||
url: "{{REMOTE_SCHEMAS_WEBHOOK_DOMAIN}}/union-graphql"
|
||||
url: '{{REMOTE_SCHEMAS_WEBHOOK_DOMAIN}}/union-graphql'
|
||||
forward_client_headers: false
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -8,10 +9,6 @@ args:
|
||||
code TEXT,
|
||||
name TEXT
|
||||
);
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO hello VALUES
|
||||
(1, 'abc', 'Some data');
|
||||
|
||||
|
@ -14,6 +14,7 @@ args:
|
||||
# }
|
||||
|
||||
#Profile table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -21,13 +22,20 @@ args:
|
||||
id serial primary key,
|
||||
name text
|
||||
);
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into profiles (name) values
|
||||
( 'alice' ),
|
||||
( 'bob' ),
|
||||
( 'alice')
|
||||
( 'alice');
|
||||
create table authors (
|
||||
id serial primary key,
|
||||
name text
|
||||
);
|
||||
create table employees (
|
||||
id serial primary key,
|
||||
name text
|
||||
);
|
||||
insert into employees (name) values ('alice'),(NULL),('bob');
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -40,28 +48,11 @@ args:
|
||||
url: http://localhost:4000
|
||||
forward_client_headers: false
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table authors (
|
||||
id serial primary key,
|
||||
name text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: authors
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table employees (
|
||||
id serial primary key,
|
||||
name text
|
||||
);
|
||||
insert into employees (name) values ('alice'),(NULL),('bob');
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -19,5 +20,5 @@ args:
|
||||
name: simple2-graphql
|
||||
comment: testing
|
||||
definition:
|
||||
url: "{{REMOTE_SCHEMAS_WEBHOOK_DOMAIN}}/user-graphql"
|
||||
url: '{{REMOTE_SCHEMAS_WEBHOOK_DOMAIN}}/user-graphql'
|
||||
forward_client_headers: false
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,6 +8,7 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -7,19 +8,17 @@ args:
|
||||
c1 int,
|
||||
c2 text
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: test_t2
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table hge_tests.articles(
|
||||
id serial primary key,
|
||||
content text,
|
||||
title text,
|
||||
is_public bool default false
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: test_t2
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
|
@ -1,14 +1,10 @@
|
||||
type: bulk
|
||||
args:
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: CREATE TABLE test(id serial PRIMARY KEY);
|
||||
- type: track_table
|
||||
args:
|
||||
name: test
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE test(id serial PRIMARY KEY);
|
||||
create table articles(
|
||||
id serial primary key,
|
||||
user_id int,
|
||||
@ -16,6 +12,10 @@ args:
|
||||
title text,
|
||||
is_public bool default false
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: test
|
||||
- type: track_table
|
||||
args:
|
||||
name: articles
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,6 +11,7 @@ args:
|
||||
INSERT INTO "user" (name)
|
||||
VALUES ('admin'), ('user'), ('anonymous')
|
||||
;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: user
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,15 +11,6 @@ args:
|
||||
name text unique,
|
||||
is_registered boolean
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,33 +18,13 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name, is_registered)
|
||||
values
|
||||
('Author 1', false),
|
||||
('Author 2', true),
|
||||
('Author 3', true),
|
||||
('Author 4', false)
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 4', false);
|
||||
insert into article (title, content, author_id, is_published)
|
||||
values
|
||||
(
|
||||
@ -90,12 +62,7 @@ args:
|
||||
'Sample article content 6',
|
||||
3,
|
||||
true
|
||||
)
|
||||
|
||||
# Search article functions
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE FUNCTION search_articles(search text)
|
||||
RETURNS SETOF article AS $$
|
||||
SELECT *
|
||||
@ -104,3 +71,23 @@ args:
|
||||
title ilike ('%' || search || '%')
|
||||
OR content ilike ('%' || search || '%')
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -8,6 +9,7 @@ args:
|
||||
name text unique,
|
||||
is_registered boolean
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -1,5 +1,6 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,15 +11,6 @@ args:
|
||||
name text unique,
|
||||
is_registered boolean
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,33 +18,13 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name, is_registered)
|
||||
values
|
||||
('Author 1', false),
|
||||
('Author 2', true),
|
||||
('Author 3', true),
|
||||
('Author 4', false)
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 4', false);
|
||||
insert into article (title, content, author_id, is_published)
|
||||
values
|
||||
(
|
||||
@ -90,5 +62,24 @@ args:
|
||||
'Sample article content 6',
|
||||
3,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -11,15 +12,6 @@ args:
|
||||
is_registered boolean not null default false,
|
||||
remarks_internal text
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -27,7 +19,14 @@ args:
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN NOT NULL default FALSE,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +17,38 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2') ;
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -51,35 +74,3 @@ args:
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
)
|
||||
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +17,35 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
placed TIMESTAMPTZ NOT NULL,
|
||||
shipped TIMESTAMPTZ
|
||||
);
|
||||
CREATE TABLE colors
|
||||
( value text PRIMARY KEY
|
||||
, comment text );
|
||||
INSERT INTO colors (value, comment) VALUES
|
||||
('red', '#FF0000'),
|
||||
('green', '#00FF00'),
|
||||
('blue', '#0000FF'),
|
||||
('orange', '#FFFF00'),
|
||||
('yellow', '#00FFFF'),
|
||||
('purple', '#FF00FF');
|
||||
|
||||
CREATE TABLE posts
|
||||
( id serial PRIMARY KEY
|
||||
, title text NOT NULL
|
||||
, custom_color text REFERENCES colors );
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -33,14 +53,6 @@ args:
|
||||
|
||||
|
||||
#Order table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
placed TIMESTAMPTZ NOT NULL,
|
||||
shipped TIMESTAMPTZ
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -66,24 +78,6 @@ args:
|
||||
column: author_id
|
||||
|
||||
# Enum table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE colors
|
||||
( value text PRIMARY KEY
|
||||
, comment text );
|
||||
INSERT INTO colors (value, comment) VALUES
|
||||
('red', '#FF0000'),
|
||||
('green', '#00FF00'),
|
||||
('blue', '#0000FF'),
|
||||
('orange', '#FFFF00'),
|
||||
('yellow', '#00FFFF'),
|
||||
('purple', '#FF00FF');
|
||||
|
||||
CREATE TABLE posts
|
||||
( id serial PRIMARY KEY
|
||||
, title text NOT NULL
|
||||
, custom_color text REFERENCES colors );
|
||||
- type: track_table
|
||||
args:
|
||||
table: colors
|
||||
@ -92,7 +86,3 @@ args:
|
||||
args: posts
|
||||
|
||||
#Set timezone
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +17,14 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -11,15 +12,6 @@ args:
|
||||
bio text,
|
||||
is_registered boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -27,37 +19,38 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Create resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
age INTEGER NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: resident
|
||||
|
||||
#Create address table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE address (
|
||||
id SERIAL PRIMARY KEY,
|
||||
door_no TEXT NOT NULL,
|
||||
street TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
resident_id INTEGER REFERENCES resident(id)
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Create resident table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: resident
|
||||
|
||||
#Create address table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,8 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO author (name)
|
||||
VALUES ('Author 1'), ('Author 2');
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +19,63 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
);
|
||||
create function search_articles(search text)
|
||||
returns setof article as $$
|
||||
select *
|
||||
from article
|
||||
where
|
||||
title ilike ('%' || search || '%') or
|
||||
content ilike ('%' || search || '%')
|
||||
$$ language sql stable;
|
||||
CREATE FUNCTION fetch_articles(search text, author_row author)
|
||||
RETURNS SETOF article AS $$
|
||||
SELECT *
|
||||
FROM article
|
||||
WHERE
|
||||
( title ilike ('%' || search || '%')
|
||||
OR content ilike ('%' || search || '%')
|
||||
) AND author_id = author_row.id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
CREATE FUNCTION test_session(author_row author, key text, session json)
|
||||
RETURNS TEXT AS $$
|
||||
SELECT $3->>$2
|
||||
$$ LANGUAGE sql STABLE;
|
||||
CREATE TABLE text_result(
|
||||
result text
|
||||
);
|
||||
|
||||
CREATE FUNCTION get_session_var(hasura_session json, session_var text)
|
||||
RETURNS SETOF text_result AS $$
|
||||
SELECT q.* FROM (VALUES (hasura_session ->> session_var)) q
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -51,69 +101,12 @@ args:
|
||||
column: author_id
|
||||
comment: List all articles of the author
|
||||
|
||||
#Insert Author table data
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
- name: Author 2
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
)
|
||||
|
||||
#Create search article function
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create function search_articles(search text)
|
||||
returns setof article as $$
|
||||
select *
|
||||
from article
|
||||
where
|
||||
title ilike ('%' || search || '%') or
|
||||
content ilike ('%' || search || '%')
|
||||
$$ language sql stable;
|
||||
- type: track_function
|
||||
args:
|
||||
name: search_articles
|
||||
schema: public
|
||||
|
||||
#Create get_articles computed field
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE FUNCTION fetch_articles(search text, author_row author)
|
||||
RETURNS SETOF article AS $$
|
||||
SELECT *
|
||||
FROM article
|
||||
WHERE
|
||||
( title ilike ('%' || search || '%')
|
||||
OR content ilike ('%' || search || '%')
|
||||
) AND author_id = author_row.id
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: add_computed_field
|
||||
args:
|
||||
table: author
|
||||
@ -123,14 +116,6 @@ args:
|
||||
table_argument: author_row
|
||||
|
||||
#Computed field with session argument
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE FUNCTION test_session(author_row author, key text, session json)
|
||||
RETURNS TEXT AS $$
|
||||
SELECT $3->>$2
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
||||
- type: add_computed_field
|
||||
args:
|
||||
table: author
|
||||
@ -138,15 +123,3 @@ args:
|
||||
definition:
|
||||
function: test_session
|
||||
session_argument: session
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE text_result(
|
||||
result text
|
||||
);
|
||||
|
||||
CREATE FUNCTION get_session_var(hasura_session json, session_var text)
|
||||
RETURNS SETOF text_result AS $$
|
||||
SELECT q.* FROM (VALUES (hasura_session ->> session_var)) q
|
||||
$$ LANGUAGE sql STABLE;
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,15 +11,6 @@ args:
|
||||
name text unique,
|
||||
remarks text
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,5 +18,11 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -10,26 +11,8 @@ args:
|
||||
name text unique,
|
||||
remarks text
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#View author_view
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE VIEW author_view AS
|
||||
SELECT id, UPPER(name) as name FROM author;
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author_view
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -37,70 +20,68 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#View article_view
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE VIEW article_view AS
|
||||
SELECT id, title, content, author_id FROM article;
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article_view
|
||||
|
||||
#Create resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE hge_tests.resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
age INTEGER NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: resident
|
||||
|
||||
#Create view resident_view
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE VIEW hge_tests.resident_view AS
|
||||
SELECT id, name FROM hge_tests.resident
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: resident_view
|
||||
|
||||
#Create address table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SELECT id, name FROM hge_tests.resident;
|
||||
CREATE TABLE hge_tests.address (
|
||||
id SERIAL PRIMARY KEY,
|
||||
door_no TEXT NOT NULL,
|
||||
street TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
resident_id INTEGER REFERENCES hge_tests.resident(id)
|
||||
)
|
||||
);
|
||||
CREATE VIEW hge_tests.address_view AS
|
||||
SELECT id, door_no, city, resident_id FROM hge_tests.address;
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#View author_view
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author_view
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#View article_view
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article_view
|
||||
|
||||
#Create resident table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: resident
|
||||
|
||||
#Create view resident_view
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: resident_view
|
||||
|
||||
#Create address table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: address
|
||||
|
||||
#Create view address_view
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE VIEW hge_tests.address_view AS
|
||||
SELECT id, door_no, city, resident_id FROM hge_tests.address
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
|
@ -2,6 +2,9 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
#test table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,7 +17,43 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2') ;
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
);
|
||||
CREATE TABLE "user" (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
number BIGINT
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -51,47 +79,6 @@ args:
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
)
|
||||
|
||||
#User table with bigserial and bigint columns
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE "user" (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
number BIGINT
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
|
@ -2,23 +2,22 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
id serial primary key,
|
||||
name text unique,
|
||||
is_registered boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO author(name, is_registered)
|
||||
VALUES
|
||||
('Author 1', true),
|
||||
('Author 2', true),
|
||||
('Author 3', false);
|
||||
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,82 +25,28 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
);
|
||||
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE city (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
country TEXT NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
);
|
||||
|
||||
INSERT INTO city (name, country)
|
||||
VALUES
|
||||
('Durham', 'USA'),
|
||||
('New York', 'USA'),
|
||||
('Framlingham', 'UK'),
|
||||
('New Orleans', 'USA');
|
||||
|
||||
#Set timezone
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
#Article order
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
received_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
delivered_at TIMESTAMP WITH TIME ZONE
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert Authors
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
is_registered: true
|
||||
- name: Author 2
|
||||
is_registered: true
|
||||
- name: Author 3
|
||||
is_registered: false
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
@ -127,20 +72,50 @@ args:
|
||||
'Sample article content 4',
|
||||
3,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
- type: insert
|
||||
- type: track_table
|
||||
args:
|
||||
table: city
|
||||
objects:
|
||||
- name: Durham
|
||||
country: USA
|
||||
- name: New York
|
||||
country: USA
|
||||
- name: Framlingham
|
||||
country: UK
|
||||
- name: New Orleans
|
||||
country: USA
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Set timezone
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -26,21 +18,29 @@ args:
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP,
|
||||
tags JSONB
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE product (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL,
|
||||
spec JSONB NOT NULL
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2');
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
@ -67,14 +67,6 @@ args:
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
|
@ -1,69 +1,32 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
DO $$
|
||||
BEGIN
|
||||
IF PostGIS_lib_version() ~ '^3.*' THEN
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_raster;
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
|
||||
#Create table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis_topology;
|
||||
CREATE TABLE geom_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
type TEXT NOT NULL,
|
||||
geom_col geometry NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
name: geom_table
|
||||
schema: public
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE geog_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
geog_col geography NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_table
|
||||
schema: public
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE geog_as_geom_table(
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
geom_col geometry NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_as_geom_table
|
||||
schema: public
|
||||
|
||||
#Insert data
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO geom_table (type, geom_col)
|
||||
VALUES
|
||||
('point', ST_GeomFromEWKT('SRID=4326;POINT(1 2)')),
|
||||
@ -72,9 +35,6 @@ args:
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))')),
|
||||
('polygon', ST_GeomFromEWKT('SRID=4326;POLYGON((2 0, 2 1, 3 1, 3 0, 2 0))'))
|
||||
;
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO geog_table (name, geog_col)
|
||||
VALUES
|
||||
('London', ST_GeographyFromText('SRID=4326;POINT(0.1278 51.5074)') ),
|
||||
@ -83,12 +43,26 @@ args:
|
||||
('New York', ST_GeographyFromText('SRID=4326;POINT(-74.0060 40.7128)') ),
|
||||
('Linestring', ST_GeographyFromText('SRID=4326;LINESTRING(0.0 0.0,0.0 1.0)')),
|
||||
('Point', ST_GeographyFromText('SRID=4326;POINT(0.0 0.5)'));
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
INSERT INTO geog_as_geom_table (name, geom_col)
|
||||
VALUES
|
||||
('London', ST_GeomFromEWKT('SRID=4326;POINT(0.1278 51.5074)')),
|
||||
('Paris', ST_GeomFromEWKT('SRID=4326;POINT(2.3522 48.8566)')),
|
||||
('Moscow', ST_GeomFromEWKT('SRID=4326;POINT(37.6173 55.7558)')),
|
||||
('New York', ST_GeomFromEWKT('SRID=4326;POINT(-74.0060 40.7128)'));
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: geom_table
|
||||
schema: public
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_table
|
||||
schema: public
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
name: geog_as_geom_table
|
||||
schema: public
|
||||
|
||||
#Insert data
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,60 +17,17 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
CREATE TABLE city (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
country TEXT NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2'),
|
||||
('Author 3')
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 3') ;
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
@ -104,8 +53,46 @@ args:
|
||||
'Sample article content 4',
|
||||
3,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: insert
|
||||
args:
|
||||
table: city
|
||||
|
@ -2,6 +2,7 @@ type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
@ -9,15 +10,6 @@ args:
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
@ -25,31 +17,11 @@ args:
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
);
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
('Author 2') ;
|
||||
insert into article (title,content,author_id)
|
||||
values
|
||||
(
|
||||
@ -66,5 +38,24 @@ args:
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2
|
||||
)
|
||||
);
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user