diff --git a/ghost/tinybird/scripts/unsafe_redeploy.sh b/ghost/tinybird/scripts/unsafe_redeploy.sh old mode 100644 new mode 100755 index 59d447f2b8..6e490dab9a --- a/ghost/tinybird/scripts/unsafe_redeploy.sh +++ b/ghost/tinybird/scripts/unsafe_redeploy.sh @@ -1,3 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Check if --force flag is provided +force=false +if [[ "$@" == *"--force"* ]]; then + force=true +fi + +# Get current branch info +branch_info=$(tb branch current) + +# Check if 'main' and 'production_stats' are both present in the output +if echo "$branch_info" | grep -q "main" && echo "$branch_info" | grep -q "production_stats"; then + if [ "$force" = false ]; then + echo "🚨 ERROR: Attempting to run unsafe_redeploy on main branch in production_stats workspace." + echo "If you're sure you want to do this, run the script with the --force flag." + exit 1 + else + echo "⚠️ WARNING: Running unsafe_redeploy on main branch in production_stats workspace with --force flag." + fi +fi + +echo "Proceeding with unsafe redeploy..." + # Remove our materialized views and their pipes tb datasource rm analytics_pages_mv --yes tb datasource rm analytics_sessions_mv --yes @@ -17,4 +42,4 @@ tb pipe rm pipes/top_sources.pipe --yes tb pipe rm pipes/trend.pipe --yes # Push all the changes -tb push --only-changes --force --populate +tb push --force --populate