SUBTASKS 1.1 "before all" hook for ":1 "worldcup" database should exist"

I definitly can not pass the test for worldcup database course.
I’ve followed some advices (including delete the container)on the forum but that have no effect.

I’ve noted that when I open the course and it is setting up I see the same msg .
If I close the CodeRoad and open it again, the same error/msg appears again.

I think a need a moderator assistance - if any exists!

Same thing, waiting for help.

Me too, I believe the problem is in since I delete the lines where I insert the data in the games table and every others tasks is ok, but that one not… But before I resolved task I’ve not found problems in insert_data file. I don’t understand…

I suspect the problem is in the 1.1.test.js subtask, it times out on postgres connection.

Did you find a solution on this topic?

Unfortunately, not yet!

If you’ve completed the code for this project but are having trouble passing the project, have you tried the solution which worked for me eventually?

  1. Create copies of your insert_data, queries and database dump files on your local hard drive and then upload them to a public repo.
  2. Go to CodeAlly and delete your project entirely (from the Cloud IDE tab).
  3. Restart the project and manually create your database structure again (NOT from your dump file).
  4. Create your insert_data and queries files again, give them executable permissions and paste in the code.
  5. Click ‘Run’ on the project tests in CodeRoad.
  6. This will hopefully allow all tests to pass and complete the course within CodeRoad.
  7. Click ‘Continue’.
  8. Click on ‘freeCodeCamp’ to go back to the curriculum menu.
  9. Go to the World Cup course and enter your repo link.

Finally! I’ve got it!
Everything was in place, insert_data and queries files. After start a new session in this afternoon, waited the CodeRoad appear, then clicked in the RUN button first. It failed.
Then I opened the terminal and executed the insert_data script, wait a litle bit and clicked in the RUN button again. This time it passed! :grinning:


This is so weird. In my case, I tried a gazillion times to re-run the script, comment out certain lines (that seemed to trigger the error, although the code was ok) and when it eventually worked, it seemed random.

Is there any solution on this?, i literally tried to create the database manually 5-6 times and then when i tried to run the file it says " [SUBTASKS 1.1 “before all” hook for “:1 “worldcup” database should exist”]"…
Somebody help me get through this :slight_smile:

Same. Blocked here. The time limit seems unreasonable since no matter how I tried it always failed.

Hi Everyone, di anyone found the solution to this issue, can’t pass all the tests it fails with
" [SUBTASKS 1.1 “before all” hook for “:1 “worldcup” database should exist”]"

I seem to be having the same issue, has anyone found a reliable fix to this? I’ve been refreshing/restarting all day.

Did you start this project a while ago and are coming back to it today?
Can you connect to your database and view its contents ok?

If yes to both of these questions, I’d recommend creating a dump of your database and then saving both the resulting sql file and your sh file(s) locally, then deleting the project container on CodeAlly and starting completely afresh.

You can then rebuild your database from the sql file and put your sh file(s) back and everything should work as intended.

Hi @igorgetmeabrain - I’ve tried all of that with no luck. I’ve even tried with another other user’s code who said it was able to pass after I cleared everything out of my container.
Link to the comment with the repo that I’ve tried with no success

EDIT: I’ve tried multiple user repo’s and I’m getting the same error every time: “SUBTASKS 1.1 “before all” hook for “:1 “worldcup” database should exist””

I am having the same issue and error unfortunately. I’ve tried the reseting the container and rebuilding the database from scratch and everything like I’ve seen some posts online here suggest but it’s still to no avail.

What I’ve noticed is that clearing out causes the tests to all work and pass (but of course only the ones relating to insert data fail) and I’m getting the same output failed test log as seen in the picture in the original post. It does take quite a long time (took about 47 seconds alone) when I run the insert data script in the terminal so it definitely seems to me that it’s an issue of the 20 second limit, which was mentioned in the instructions.

The thing is, I’m not sure how much tighter I can make my code, so if there are any suggestions there I’ll greatly appreciate that and include my code below. The most I can get for the tests to not show that ‘database should exist’ error is the first two SELECT statements. Anything I add after gives that error. Sadly I kinda need those INSERT statements for the teams and games.

# Truncate all tables
echo $($PSQL "TRUNCATE TABLE teams, games")

  # Skip first row
  if [[ $YEAR != "year" ]]
    # Retrieve team_id for winner and opponent
    TEAM_ID_W=$($PSQL "SELECT team_id FROM teams WHERE name='$WINNER'")
    TEAM_ID_O=$($PSQL "SELECT team_id FROM teams WHERE name='$OPPONENT'")

    # Add winner team to teams table and update variable if it does not already exist
    if [[ -z $TEAM_ID_W ]]
      TEAM_ID_W=$($PSQL "SELECT team_id FROM teams WHERE name='$WINNER'")

    # Add opponent team to teams table and update variable if it does not already exist
    if [[ -z $TEAM_ID_O ]]
      TEAM_ID_O=$($PSQL "SELECT team_id FROM teams WHERE name='$OPPONENT'")

    # Add game details to games table
    INSERT_GAME_RESULT=$($PSQL "INSERT INTO games(year, round, winner_id, opponent_id, winner_goals, opponent_goals) VALUES($YEAR, '$ROUND', $TEAM_ID_W, $TEAM_ID_O, $WINNER_GOALS, $OPPONENT_GOALS)")

I’m not sure how the whole online codespace/code editor CodeRoad CodeAlly stuff works in the backend but maybe it’s a thing where performance varies throughout the day so my last hunch I’ll try is trying the tests late at night or something. Either way perhaps it’d be nice to up that time limit to like maybe a minute?


Also for me. The take quite a long time 50-60 seconds when I run the insert data script in the terminal. But that file contains only inserts, it cannot be reduced any more. Perhaps some performance issue. Please, can be the time limit set to a higher value that 20sec?

So update: it finally decided to let me have all of the passes test! I have been using the time ./ command in the terminal throughout my attempts at different times to keep trying and there was a wide range of results ranging from the 40s, 50s, and even all the way up to 1min and 1min30s.

Today around Thu May 11 15:35:14 CST 2023 I decided to attempt again and got 12s! Running the tests still for some reason didn’t pass the queries and one of the insert_data checkmarks so I still had to reset the container again. After starting it fresh, I rebuilt the database from my dumped file, copy pasted my insert_data and the queries scripts, gave permissions to both, ran the insert_data script once in the terminal, then finally ran the tests which let me through.

So my recommendation for this problem if it’s still a problem for you (and for future folks if it’s still a problem then) is to try the tests later throughout different times or days. You can soft check with time ./ in the terminal and when it shows a nice time then reset the container instead of constantly resetting the container and repasting your code just to run the tests.

The whole performance at different times thing is still just speculation on my part since I tried super late at night and super early morning to no avail so there may be other factors at play but I’d say it’s not something to stress too much. You can always just continue on to the next course in the meantime. Best of luck and I hope everyone else’s tests pass!


Thanks for sharing the time command, @andreshungbz !

Currently (May 12 , 2023 12:36h CEST) I get the following after running time ./insert_data:

Let’s hope we all find a good time to pass this!

1 Like

You need to modify your script to reduce the length of the script