Skip to content

Commit

Permalink
fix(mysql): the schema files order of execution shouldn't matter
Browse files Browse the repository at this point in the history
order of files given by `find` depends on the underlying filesystem and can be
different on macOS and linux
  • Loading branch information
shivaraj-bh committed Mar 18, 2024
1 parent 61bab77 commit 6ab0a56
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions nix/mysql/mysql_test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
echo "$isBarPresent" | grep 1
echo "Checking if both foo.sql and bar.sql are executed, ignoring baz.md"
echo "SELECT * from users where id = '1';" | MYSQL_PWD="" mysql -h 127.0.0.1 -u root -D test_database | grep user1
echo "SELECT * from users where id = '2';" | MYSQL_PWD="" mysql -h 127.0.0.1 -u root -D test_database | grep user2
if [[ -z $(echo "SELECT * from users where id = '3';" | MYSQL_PWD="" mysql -h 127.0.0.1 -u root -D test_database) ]]; then
echo "user3 not found"
echo "SELECT * FROM information_schema.tables WHERE table_schema = 'test_database' AND table_name = 'foo' LIMIT 1;" | MYSQL_PWD="" mysql -h 127.0.0.1 -u root | grep foo
echo "SELECT * FROM information_schema.tables WHERE table_schema = 'test_database' AND table_name = 'bar' LIMIT 1;" | MYSQL_PWD="" mysql -h 127.0.0.1 -u root | grep bar
if [[ -z $(echo "SELECT * FROM information_schema.tables WHERE table_schema = 'test_database' AND table_name = 'baz' LIMIT 1;" | MYSQL_PWD="" mysql -h 127.0.0.1 -u root) ]]; then
echo "success! baz table not found"
else
echo "user3 shoudn't be present"
echo "baz table shoudn't exist"
exit 1
fi
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/mysql/test_schemas/bar.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO users values (2, 'user2');
CREATE TABLE bar (id INT PRIMARY KEY);
2 changes: 1 addition & 1 deletion nix/mysql/test_schemas/baz.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
INSERT INTO users values (3, 'user3');
CREATE TABLE baz (id INT PRIMARY KEY);
4 changes: 1 addition & 3 deletions nix/mysql/test_schemas/foo.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
CREATE TABLE users (id INT PRIMARY KEY, user_name VARCHAR(25));

INSERT INTO users values (1, 'user1');
CREATE TABLE foo (id INT PRIMARY KEY);

0 comments on commit 6ab0a56

Please sign in to comment.