graphql-engine/server/tests-py/queries/graphql_mutation/insert/views/schema_setup.yaml
Swann Moreau 5bc0355bdd [server] coalesce multiple run_sql calls in tests (#270)
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
2021-01-06 16:07:22 +00:00

71 lines
1.4 KiB
YAML

type: bulk
args:
#Author table
- type: run_sql
args:
sql: |
create table author(
id serial primary key,
name text unique,
is_registered boolean not null default false
);
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 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: track_table
args:
schema: public
name: author_simple
#Create author complex view
- type: track_table
args:
schema: public
name: author_complex
#Create object relations on views
- type: create_object_relationship
args:
table: article
name: author_simple
using:
manual_configuration:
remote_table: author_simple
column_mapping:
author_id: id
- type: create_object_relationship
args:
table: article
name: author_complex
using:
manual_configuration:
remote_table: author_complex
column_mapping:
author_id: author_id