Skip to content

Commit eb00a61

Browse files
author
Alexei Pastuchov
committed
[skip ci] mysql migration quieries
1 parent 0188c08 commit eb00a61

File tree

1 file changed

+18
-9
lines changed
  • wundergraph_cli/src/print_schema

1 file changed

+18
-9
lines changed

wundergraph_cli/src/print_schema/mod.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,28 @@ mod tests {
127127

128128
#[cfg(feature = "mysql")]
129129
const MIGRATION: &[&str] = &[
130-
"CREATE TABLE users(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, name TEXT NOT NULL);",
130+
r#"CREATE TABLE users(
131+
id INTEGER NOT NULL AUTO_INCREMENT,
132+
name TEXT NOT NULL,
133+
PRIMARY KEY (`id`)
134+
);"#,
131135
r#"CREATE TABLE posts(
132-
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
133-
author INTEGER REFERENCES users(id),
136+
id INTEGER NOT NULL AUTO_INCREMENT,
137+
author INTEGER DEFAULT NULL,
134138
title TEXT NOT NULL,
135-
datetime TIMESTAMP,
136-
content TEXT
139+
datetime TIMESTAMP NULL DEFAULT NULL,
140+
content TEXT,
141+
PRIMARY KEY (`id`),
142+
FOREIGN KEY (`author`) REFERENCES `users` (`id`)
137143
);"#,
138144
r#"CREATE TABLE comments(
139-
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
140-
post INTEGER REFERENCES posts(id),
141-
commenter INTEGER REFERENCES users(id),
142-
content TEXT NOT NULL
145+
id INTEGER NOT NULL AUTO_INCREMENT,
146+
post INTEGER DEFAULT NULL,
147+
commenter INTEGER DEFAULT NULL,
148+
content TEXT NOT NULL,
149+
PRIMARY KEY (`id`),
150+
FOREIGN KEY (`post`) REFERENCES `posts` (`id`),
151+
FOREIGN KEY (`commenter`) REFERENCES `users` (`id`)
143152
);"#,
144153
];
145154

0 commit comments

Comments
 (0)