Files
Compass/scripts/combine-migrations.sh
Okechi Jones-Williams b18a6d7ff3 [Onboarding Flow] Added database checks to the onboarding flow (#34)
* Fixed Type errors

* Organizing testing utilities

* Added Database checks to the onboarding flow

* Updated Onboarding flow
Changed type ChildrenExpectation so that it can be used for database verification

* Added compatibility page setup
Added more compatibility questions

* Fix

* .

* Fix: Typo

* Fix: Faker usernames can no longer generate symbols

* Fix: Changed how work area is verified

* .

* .

* Fix: Trying to work in headed mode

* Fix: Change back to headless

* Fix: Added timeout after workArea selection

* .

* Clean e2e

* Improve E2E setup

* Prettier

* Log

* Fix: should pull test account from unique identifier like email, username or id; not the display name

* Source env vars in playwright directly

* Clean e2e data

* Clean test account id to be the same for email and username

* Fix import warning

* Add error handling

* Add log

* Temp remove env load

* Update

* Add logs and safeguards against using remote supabase during e2e tests

* Fix playwright report path in C@

* Remove locale log

* Check if userInformationFromDb loading with name instead of username was the issue

* Remove login log

* Check if initial work area names were the issue

* Ignore if no files found

* Cache Firebase emulators in CI

* Reload env vars in playwright

* It did not break tests...

* Clean verifyWorkArea

* Add caching for node modules in CI

* Add caching for node modules in CI (2)

* Do not raise if emulator not running during db seed

* Do not raise if using firebase emulator

* Fix supabase cache in CI

* Add Cache Playwright browsers in CI

* Fix

* Test cache

* Turn off unused supabase services to speed things up

* Back to good one

* Set CI=true

* api is required for client connection

* Add safeguards for missing supabase env vars

* Remove echo

* Remove supabase cache

---------

Co-authored-by: Martin Braquet <martin.braquet@gmail.com>
2026-03-01 01:25:56 +01:00

88 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Change to project root
cd "$(dirname "$0")"/..
echo "📦 Copying migrations from backend/supabase/ to supabase/migrations/"
echo ""
# Create migrations directory if it doesn't exist
mkdir -p supabase/migrations
# Read migration.sql and extract all \i commands
if [ ! -f "backend/supabase/migration.sql" ]; then
echo "❌ Error: backend/supabase/migration.sql not found"
exit 1
fi
# Remove existing files (if any)
find supabase/migrations -name "*.sql" -type f -delete 2>/dev/null || true
# Extract file paths from \i commands
FILES=$(grep '\\i ' backend/supabase/migration.sql | sed 's/\\i //' | sed 's/;//' | tr -d '\r')
# Starting timestamp (you can adjust this)
TIMESTAMP=20250101000000
COUNTER=0
echo "Files to copy:"
echo "----------------------------------------"
# Copy each file with timestamp
while IFS= read -r file; do
# Remove leading/trailing whitespace
file=$(echo "$file" | xargs)
if [ -z "$file" ]; then
continue
fi
if [ ! -f "$file" ]; then
echo "⚠️ Warning: $file not found, skipping..."
continue
fi
# Calculate timestamp (increment by 1 minute for each file)
CURRENT_TIMESTAMP=$((TIMESTAMP + COUNTER))
# Get filename without path
BASENAME=$(basename "$file")
# Create descriptive name from path
# backend/supabase/users.sql -> users
# backend/supabase/migrations/20251106_add_message_actions.sql -> add_message_actions
if [[ "$file" == *"/migrations/"* ]]; then
# Already has a migration name
NAME=$(echo "$BASENAME" | sed 's/^[0-9_]*//;s/\.sql$//')
else
NAME=$(echo "$BASENAME" | sed 's/\.sql$//')
fi
# Output filename
OUTPUT="supabase/migrations/${CURRENT_TIMESTAMP}_${NAME}.sql"
# Add header comment to track source
{
echo "-- Migration: $NAME"
echo "-- Source: $file"
echo "-- Timestamp: $(date)"
echo ""
cat "$file"
} > "$OUTPUT"
# echo "✅ $file -> $OUTPUT"
COUNTER=$((COUNTER + 100))
done <<< "$FILES"
echo ""
echo "----------------------------------------"
echo "✅ Migration files copied to supabase/migrations/"
echo ""
echo "To apply migrations:"
echo " npx supabase db reset"
echo ""
echo "To view in Studio:"
echo " open http://127.0.0.1:54323"