mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-24 01:13:21 +00:00
Added cmake dep to dockerfile and added script for db:schema:load that runs only if the schema is different than the latest migration
This commit is contained in:
15
script/load_schema.sh
Executable file
15
script/load_schema.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🔍 Checking if schema is missing or outdated..."
|
||||
|
||||
# Get the current DB version
|
||||
DB_VERSION=$(bundle exec rails db:version | grep 'Current version' | awk '{print $NF}')
|
||||
FILE_VERSION=$(grep 'version:' db/schema.rb | awk '{print $2}')
|
||||
|
||||
if [ -z "$DB_VERSION" ] || [ "$DB_VERSION" != "$FILE_VERSION" ]; then
|
||||
echo "🧾 Schema mismatch detected (DB=$DB_VERSION, File=$FILE_VERSION). Running db:schema:load..."
|
||||
bundle exec rails db:schema:load
|
||||
else
|
||||
echo "✅ Schema is up to date (version $DB_VERSION)."
|
||||
fi
|
||||
Reference in New Issue
Block a user