mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 18:42:30 +03:00
296 lines
8.0 KiB
YAML
296 lines
8.0 KiB
YAML
type: bulk
|
|
args:
|
|
|
|
- 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,
|
|
c3_bigint bigint,
|
|
c4_decimal decimal (5, 2),
|
|
c5_numeric numeric (4, 3),
|
|
c6_real real,
|
|
c7_double_precision double precision,
|
|
c8_smallserial smallserial,
|
|
c9_serial serial,
|
|
c10_bigserial bigserial,
|
|
c11_varchar_3 varchar(3),
|
|
c12_char_4 char(4),
|
|
c13_text text,
|
|
c14_timestamp timestamp,
|
|
c15_timestamptz timestamptz,
|
|
c16_date date,
|
|
c17_time time,
|
|
c18_time_with_zone time with time zone,
|
|
c19_interval interval,
|
|
c20_boolean boolean,
|
|
c21_point point,
|
|
c22_line line,
|
|
c23_lseg lseg,
|
|
c24_box box,
|
|
c25_closed_path path,
|
|
c26_open_path path,
|
|
c27_polygon polygon,
|
|
c28_circle circle,
|
|
c29_cidr cidr,
|
|
c30_inet inet,
|
|
c31_macaddr macaddr,
|
|
c32_json json,
|
|
c33_jsonb jsonb,
|
|
c34_text_array text[],
|
|
c35_integer_2d_array integer[][],
|
|
c36_uuid uuid,
|
|
c37_composite_type_complex complex,
|
|
c38_composite_type_inventory inventory_item,
|
|
c39_range_integer int4range,
|
|
c40_range_bigint int8range,
|
|
c41_range_numeric numrange,
|
|
c42_range_timestamp tsrange,
|
|
c43_range_timestamptz tstzrange,
|
|
c44_xml xml
|
|
);
|
|
- 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,
|
|
content TEXT,
|
|
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
|
|
, c3_bigint
|
|
, c4_decimal
|
|
, c5_numeric
|
|
, c6_real
|
|
, c7_double_precision
|
|
, c11_varchar_3
|
|
, c12_char_4
|
|
, c13_text
|
|
, c14_timestamp
|
|
, c15_timestamptz
|
|
, c16_date
|
|
, c17_time
|
|
, c18_time_with_zone
|
|
, c19_interval
|
|
, c20_boolean
|
|
, c21_point
|
|
, c22_line
|
|
, c23_lseg
|
|
, c24_box
|
|
, c25_closed_path
|
|
, c26_open_path
|
|
, c27_polygon
|
|
, c28_circle
|
|
, c29_cidr
|
|
, c30_inet
|
|
, c31_macaddr
|
|
, c32_json
|
|
, c33_jsonb
|
|
, c34_text_array
|
|
, c35_integer_2d_array
|
|
, c36_uuid
|
|
, c37_composite_type_complex
|
|
, c38_composite_type_inventory
|
|
, c39_range_integer
|
|
, c40_range_bigint
|
|
, c41_range_numeric
|
|
, c42_range_timestamp
|
|
, c43_range_timestamptz
|
|
, c44_xml
|
|
)
|
|
values
|
|
( 32767 -- c1_smallint
|
|
, 2147483647 -- c2_integer
|
|
, 9223372036854775807 -- c3_bigint
|
|
, 123.45 -- c4_decimal
|
|
, 1.234 -- c5_numeric
|
|
, 0.00390625 -- c6_real
|
|
, 16.0001220703125 -- c7_double_precision
|
|
, 'abc' -- c11_varchar_3
|
|
, 'baaz' -- c12_char_4
|
|
, 'foo bar baz' -- c13_text
|
|
, '2004-10-19T10:23:54' -- c14_timestamp
|
|
, '2015-10-17T14:42:43+00:00' -- c15_timestamptz
|
|
, '2014-09-14' -- c16_date
|
|
, '11:09:23' -- c17_time
|
|
, '15:22:23+00' -- c18_time_with_zone
|
|
, '01:03:02' -- c19_interval
|
|
, true -- c20_boolean
|
|
, '(1,2)' -- c21_point
|
|
, '{2,3,-1}' -- c22_line
|
|
, '[(4,2),(3,1)]' -- c23_line
|
|
, '((31,12),(14,11))' -- c24_box
|
|
, '((0,0),(0,3),(1,0))' -- c25_closed_path
|
|
, '[(0,0),(0,-1),(-3,0)]' -- c26_open_path
|
|
, '((0,0),(0,6),(2,0))' -- c27_polygon
|
|
, '<(-2,-3),3>' -- c28_circle
|
|
, '192.168.100.128/25' -- c29_cidr
|
|
, '198.24.10.0' -- c30_inet
|
|
, '08:00:2b:01:02:03' -- c31_macaddr
|
|
, '{ "a" : "b", "obj": { "c1": "c2" }, "arr": [1, 2, 3] }' -- c32_json
|
|
, '{ "c" : "d", "obj": { "e1": "e2" }, "arr": [4, 5, 6] }' -- c33_jsonb
|
|
, '{"a","b","c"}' -- c34_text_array
|
|
, '{{4,5,6},{7,8,9}}' -- c35_integer_2d_array
|
|
, 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11' -- c36_uuid
|
|
, '(1.23,-3.456)' -- c37_composite_type_complexa
|
|
, '("fuzzy dice",42,1.99)' -- c38_composite_type_inventory
|
|
, '[123,456)' -- c39_range_integer
|
|
, '[1147483647, 2147483647)' -- c40_range_bigint
|
|
, '[1.23, 4.56]' -- c41_range_numeric
|
|
, '[2010-01-01 14:30:00, 2010-01-01 15:30:02)' -- c42_range_timestamp
|
|
, '(2011-02-05T12:03:00+00:00, 2012-03-04T16:40:04+00:00]' -- c43_range_timestamptz
|
|
, '<foo>bar</foo>' -- c44_xml
|
|
)
|
|
|
|
#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
|
|
name: user
|
|
- type: insert
|
|
args:
|
|
table: user
|
|
objects:
|
|
- name: User 1
|
|
number: '123456789'
|
|
- name: User 2
|
|
number: '123456780'
|
|
|
|
- type: run_sql
|
|
args:
|
|
sql: |
|
|
create table person (
|
|
id serial primary key,
|
|
name text
|
|
);
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: person
|
|
- type: insert
|
|
args:
|
|
table: person
|
|
objects:
|
|
- name: "John\\"
|
|
|
|
#Set timezone
|
|
- type: run_sql
|
|
args:
|
|
sql: |
|
|
SET TIME ZONE 'UTC';
|