Skip to content

Commit fc27118

Browse files
authored
Merge pull request #47 from weiznich/fix/ci_bug
Make sure to not create table twice in tests
2 parents b9ae137 + b49791e commit fc27118

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/doctest_setup.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cfg_if::cfg_if! {
2727
}
2828

2929
async fn create_tables(connection: &mut AsyncPgConnection) {
30-
diesel::sql_query("CREATE TABLE users (
30+
diesel::sql_query("CREATE TABLE IF NOT EXISTS users (
3131
id SERIAL PRIMARY KEY,
3232
name VARCHAR NOT NULL
3333
)").execute(connection).await.unwrap();
@@ -36,7 +36,7 @@ cfg_if::cfg_if! {
3636
).execute(connection).await.unwrap();
3737

3838
diesel::sql_query(
39-
"CREATE TABLE animals (
39+
"CREATE TABLE IF NOT EXISTS animals (
4040
id SERIAL PRIMARY KEY,
4141
species VARCHAR NOT NULL,
4242
legs INTEGER NOT NULL,
@@ -50,7 +50,7 @@ cfg_if::cfg_if! {
5050
.await.unwrap();
5151

5252
diesel::sql_query(
53-
"CREATE TABLE posts (
53+
"CREATE TABLE IF NOT EXISTS posts (
5454
id SERIAL PRIMARY KEY,
5555
user_id INTEGER NOT NULL,
5656
title VARCHAR NOT NULL
@@ -61,7 +61,7 @@ cfg_if::cfg_if! {
6161
(1, 'About Rust'),
6262
(2, 'My first post too')").execute(connection).await.unwrap();
6363

64-
diesel::sql_query("CREATE TABLE comments (
64+
diesel::sql_query("CREATE TABLE IF NOT EXISTS comments (
6565
id SERIAL PRIMARY KEY,
6666
post_id INTEGER NOT NULL,
6767
body VARCHAR NOT NULL
@@ -71,7 +71,7 @@ cfg_if::cfg_if! {
7171
(2, 'Yay! I am learning Rust'),
7272
(3, 'I enjoyed your post')").execute(connection).await.unwrap();
7373

74-
diesel::sql_query("CREATE TABLE brands (
74+
diesel::sql_query("CREATE TABLE IF NOT EXISTS brands (
7575
id SERIAL PRIMARY KEY,
7676
color VARCHAR NOT NULL DEFAULT 'Green',
7777
accent VARCHAR DEFAULT 'Blue'

0 commit comments

Comments
 (0)