1
0
mirror of https://github.com/hasura/graphql-engine.git synced 2024-12-24 07:52:14 +03:00
graphql-engine/server/tests-py/queries/v1/relationships/setup.yaml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

163 lines
3.3 KiB
YAML
Raw Normal View History

type: bulk
args:
#Author table
- type: run_sql
args:
sql: |
create table author(
id serial primary key,
name text unique,
remarks text
);
create table author_details(
id serial primary key,
author_id INTEGER REFERENCES author(id),
email text unique
);
CREATE VIEW author_view AS
SELECT id, UPPER(name) as name FROM author;
CREATE TABLE article (
id SERIAL PRIMARY KEY,
title TEXT,
content TEXT,
author_id INTEGER REFERENCES author(id),
is_published BOOLEAN,
published_on TIMESTAMP
);
CREATE VIEW article_view AS
SELECT id, title, content, author_id FROM article;
CREATE TABLE hge_tests.resident (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
age INTEGER NOT NULL
);
CREATE VIEW hge_tests.resident_view AS
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
- type: track_table
args:
schema: public
name: author_details
#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: track_table
args:
schema: hge_tests
name: address_view
#Insert Author table data
- type: insert
args:
table: author
objects:
- name: Author 1
- name: Author 2
- type: insert
args:
table: author_details
objects:
- author_id: 1
email: "author1@authors.com"
- author_id: 2
email: "author2@authors.com"
#Insert Article table data
- type: insert
args:
table: article
objects:
- content: Sample article content 1
title: Article 1
author_id: 1
- content: Sample article content 2
title: Article 2
author_id: 1
- content: Sample article content 3
title: Article 3
author_id: 2
#Insert resident table data
- type: insert
args:
table:
name: resident
schema: hge_tests
objects:
- name: John
age: 23
- name: Tom
age: 31
#Insert address table data
- type: insert
args:
table:
name: address
schema: hge_tests
objects:
- door_no: 12-21
street: Madhapur
city: Hyderabad
resident_id: 1
- door_no: 11-19
street: Koramangala
city: Bangalore
resident_id: 1
- door_no: 13-21
street: Teynampet
city: Chennai
resident_id: 2