Changeset cc841a5


Ignore:
Timestamp:
12/27/25 20:00:37 (7 months ago)
Author:
Tome <gjorgievtome@…>
Branches:
main
Children:
9137793
Parents:
05361b8
Message:

Add migration check

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docker-entrypoint.sh

    r05361b8 rcc841a5  
    88done
    99
    10 echo "Generating migrations..."
    11 npm run drizzle:generate
     10echo "Checking if database needs migration..."
     11TABLE_COUNT=$(psql -h db -U app -d postgres -t -c "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public';" 2>/dev/null || echo "0")
    1212
    13 echo "Running migrations..."
    14 npm run drizzle:migrate
     13if [ "$TABLE_COUNT" -eq "0" ]; then
     14  echo "Database is empty, running migrations..."
     15  npm run drizzle:generate
     16  npm run drizzle:migrate
    1517
    16 echo "Seeding database..."
    17 npm run drizzle:seed
     18  echo "Seeding database..."
     19  npm run drizzle:seed
     20else
     21  echo "Database already initialized (found $TABLE_COUNT tables), skipping migrations and seed"
     22fi
    1823
    1924echo "Starting application..."
Note: See TracChangeset for help on using the changeset viewer.