mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
5bc0355bdd
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
80 lines
1.4 KiB
YAML
80 lines
1.4 KiB
YAML
type: bulk
|
|
args:
|
|
|
|
- type: run_sql
|
|
args:
|
|
sql: |
|
|
CREATE TABLE author(
|
|
id SERIAL PRIMARY KEY,
|
|
name TEXT UNIQUE NOT NULL
|
|
);
|
|
|
|
INSERT INTO author (name)
|
|
VALUES ('Author 1'), ('Author 2'), ('Author 3'), ('Author 4');
|
|
|
|
CREATE TABLE article (
|
|
id SERIAL PRIMARY KEY,
|
|
title TEXT,
|
|
content TEXT,
|
|
author_id INTEGER REFERENCES author(id)
|
|
);
|
|
|
|
INSERT INTO article (title, content, author_id)
|
|
VALUES
|
|
(
|
|
'Article 1',
|
|
'Sample article content 1',
|
|
1
|
|
),
|
|
(
|
|
'Article 2',
|
|
'Sample article content 2',
|
|
1
|
|
),
|
|
(
|
|
'Article 3',
|
|
'Sample article content 3',
|
|
1
|
|
),
|
|
(
|
|
'Article 4',
|
|
'Sample article content 4',
|
|
2
|
|
),
|
|
(
|
|
'Article 5',
|
|
'Sample article content 5',
|
|
2
|
|
),
|
|
(
|
|
'Article 6',
|
|
'Sample article content 6',
|
|
3
|
|
);
|
|
|
|
- type: track_table
|
|
args:
|
|
name: author
|
|
schema: public
|
|
|
|
- type: track_table
|
|
args:
|
|
name: article
|
|
schema: public
|
|
|
|
- type: create_object_relationship
|
|
args:
|
|
table: article
|
|
name: author
|
|
using:
|
|
foreign_key_constraint_on: author_id
|
|
|
|
- type: create_array_relationship
|
|
args:
|
|
table: author
|
|
name: articles
|
|
using:
|
|
foreign_key_constraint_on:
|
|
table: article
|
|
column: author_id
|