Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ $ docker-compose build
# Start the database container (in the background with -d)
$ docker-compose up -d db

# Generate random database fixtures
$ docker-compose run --rm api rake db:setup db:populate
# Create database
$ docker-compose run --rm api rake db:setup

# Generate Fake Data
$ docker-compose run --rm api ./utils/db/populate.sh

# Start the Rails development server in the api container (in the foreground)
$ docker-compose up api
Expand Down
26 changes: 26 additions & 0 deletions utils/db/populate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Path to the fake data SQL file
SQL_FILE="utils/db/sql/fake-data.sql"

# Check if SQL file exists
if [ ! -f "$SQL_FILE" ]; then
echo "Error: SQL file $SQL_FILE does not exist"
exit 1
fi

# List available databases to diagnose
echo "Listing available databases:"
PGPASSWORD=postgres psql -h db -U postgres -p 5432 -l

# Populate database
echo "Populating database with fake data from $SQL_FILE..."
PGPASSWORD=postgres psql -h db -U postgres -p 5432 -d askdarcel_development -f "$SQL_FILE"

# Check execution status
if [ $? -eq 0 ]; then
echo "Database population completed successfully."
else
echo "Error populating database."
exit 1
fi``
Loading