mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 13:02:11 +03:00
5bc0355bdd
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
89 lines
1.7 KiB
YAML
89 lines
1.7 KiB
YAML
type: bulk
|
|
args:
|
|
|
|
#Author table
|
|
|
|
- type: run_sql
|
|
args:
|
|
sql: |
|
|
create table author(
|
|
id serial primary key,
|
|
name text unique
|
|
);
|
|
CREATE TABLE article (
|
|
id SERIAL PRIMARY KEY,
|
|
title TEXT,
|
|
content TEXT,
|
|
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
|
|
name: article
|
|
|
|
|
|
#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
|
|
|
|
# Enum table
|
|
- type: track_table
|
|
args:
|
|
table: colors
|
|
is_enum: true
|
|
- type: track_table
|
|
args: posts
|
|
|
|
#Set timezone
|