2021-10-22 02:50:18 +03:00
|
|
|
# For MySQL, every statement ends with a `;\n` (that's a semicolon followed by
|
|
|
|
# a newline), and it cannot parse the next if a new statement follows after an
|
|
|
|
# indentation, like we normally write for other backends. So breaking apart the
|
|
|
|
# requests into individual statements turned out to be the ergonomic way to make
|
|
|
|
# this work.
|
|
|
|
#
|
|
|
|
# Also tried typical YAML multi-line (block) syntax in all combinations `|`,
|
|
|
|
# `>` with `+` and `-`, including specification of the indentation levels with
|
|
|
|
# numbers, without success.
|
|
|
|
#
|
|
|
|
# NOTE: For local development, if manual data seeding is ever necessary, we
|
|
|
|
# maintain a `mysql-ddl-dml.sql` that should always remain in sync with this
|
|
|
|
# file.
|
2021-07-21 13:22:03 +03:00
|
|
|
|
2021-07-15 15:44:26 +03:00
|
|
|
type: bulk
|
2021-07-21 13:22:03 +03:00
|
|
|
args:
|
|
|
|
|
|
|
|
- type: mysql_run_sql
|
|
|
|
args:
|
|
|
|
source: mysql
|
|
|
|
sql: |
|
|
|
|
DROP TABLE IF EXISTS article;
|
|
|
|
|
|
|
|
- type: mysql_run_sql
|
|
|
|
args:
|
|
|
|
source: mysql
|
|
|
|
sql: |
|
|
|
|
DROP TABLE IF EXISTS author;
|
|
|
|
|
2021-10-22 02:50:18 +03:00
|
|
|
|
2021-07-21 13:22:03 +03:00
|
|
|
- type: mysql_run_sql
|
|
|
|
args:
|
|
|
|
source: mysql
|
|
|
|
sql: |
|
|
|
|
CREATE TABLE author
|
|
|
|
(
|
2021-10-22 02:50:18 +03:00
|
|
|
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
name VARCHAR(45) UNIQUE KEY,
|
2021-07-21 13:22:03 +03:00
|
|
|
createdAt DATETIME
|
|
|
|
);
|
|
|
|
|
|
|
|
- type: mysql_run_sql
|
|
|
|
args:
|
|
|
|
source: mysql
|
|
|
|
sql: |
|
|
|
|
INSERT INTO author
|
|
|
|
(name, createdAt)
|
|
|
|
VALUES
|
2021-08-04 14:42:24 +03:00
|
|
|
( 'Author 1', '2017-09-21 09:39:44' ),
|
|
|
|
( 'Author 2', '2017-09-21 09:50:44' );
|
2021-07-21 13:22:03 +03:00
|
|
|
|
2021-10-22 02:50:18 +03:00
|
|
|
|
2021-07-21 13:22:03 +03:00
|
|
|
- type: mysql_run_sql
|
|
|
|
args:
|
|
|
|
source: mysql
|
|
|
|
sql: |
|
|
|
|
CREATE TABLE article (
|
|
|
|
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
title TEXT,
|
|
|
|
content TEXT,
|
|
|
|
is_published BIT,
|
|
|
|
published_on TIMESTAMP,
|
2021-10-22 02:50:18 +03:00
|
|
|
author_id INT UNSIGNED,
|
|
|
|
co_author_id INT UNSIGNED,
|
2021-07-21 13:22:03 +03:00
|
|
|
FOREIGN KEY (author_id) REFERENCES author(id),
|
|
|
|
FOREIGN KEY (co_author_id) REFERENCES author(id)
|
|
|
|
);
|
2021-07-15 15:44:26 +03:00
|
|
|
|
2021-07-21 13:22:03 +03:00
|
|
|
- type: mysql_run_sql
|
|
|
|
args:
|
|
|
|
source: mysql
|
|
|
|
sql: |
|
|
|
|
INSERT INTO article
|
|
|
|
(title, content, author_id, is_published)
|
|
|
|
VALUES
|
|
|
|
( 'Article 1', 'Sample article content 1', 1, 0 ),
|
|
|
|
( 'Article 2', 'Sample article content 2', 1, 1 ),
|
|
|
|
( 'Article 3', 'Sample article content 3', 2, 1 );
|
2021-10-22 02:50:18 +03:00
|
|
|
|
|
|
|
|
|
|
|
# NOTE on dropping tables that have dependent views:
|
|
|
|
# ref: https://dev.mysql.com/doc/refman/5.7/en/view-restrictions.html
|
|
|
|
#
|
|
|
|
# You can use DROP TABLE or ALTER TABLE to drop or alter a table that is used
|
|
|
|
# in a view definition. No warning results from the DROP or ALTER operation,
|
|
|
|
# even though this invalidates the view. Instead, an error occurs later, when
|
|
|
|
# the view is used. CHECK TABLE can be used to check for views that have been
|
|
|
|
# invalidated by DROP or ALTER operations.
|
|
|
|
- type: mysql_run_sql
|
|
|
|
args:
|
|
|
|
source: mysql
|
|
|
|
sql: |
|
|
|
|
CREATE OR REPLACE VIEW search_author_view AS
|
|
|
|
SELECT * FROM author;
|