Skip to content
Merged
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
10 changes: 7 additions & 3 deletions superset-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ WORKSPACE_NAME="${SUPERSET_WORKSPACE_NAME:-$(basename "$PWD")}"
NEON_OUTPUT=$(neonctl branches create \
--project-id tiny-cherry-82420694 \
--name "$WORKSPACE_NAME" \
--output json)
--output json 2>&1 | grep -v "^WARNING:")

# Parse connection strings and create .env
# Parse connection strings from create output
DATABASE_URL=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_uri')
DATABASE_POOLED_URL=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[1].connection_uri // empty')
POOLER_HOST=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.pooler_host')
PASSWORD=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.password')
ROLE=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.role')
DATABASE=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.database')
DATABASE_POOLED_URL="postgresql://${ROLE}:${PASSWORD}@${POOLER_HOST}/${DATABASE}?sslmode=require"

cat > .env << EOF
DATABASE_URL=$DATABASE_URL
Expand Down
47 changes: 9 additions & 38 deletions superset-teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,19 @@ NC='\033[0m'
error() { echo -e "${RED}✗${NC} $1"; exit 1; }
success() { echo -e "${GREEN}✓${NC} $1"; }

echo "🚀 Setting up Superset workspace..."
echo "🧹 Tearing down Superset workspace..."

# Check dependencies
command -v bun &> /dev/null || error "Bun not installed. Install from https://bun.sh"
command -v neonctl &> /dev/null || error "Neon CLI not installed. Run: npm install -g neonctl"
command -v jq &> /dev/null || error "jq not installed. Run: brew install jq"

# Install dependencies
echo "📥 Installing dependencies..."
bun install
success "Dependencies installed"

# Link direnv config from root repo if it exists
if [ -n "$SUPERSET_ROOT_PATH" ] && [ -f "$SUPERSET_ROOT_PATH/.envrc" ]; then
echo "🔧 Linking .envrc..."
ln -sf "$SUPERSET_ROOT_PATH/.envrc" .envrc
if command -v direnv &> /dev/null; then
direnv allow
fi
success "direnv configured"
fi

# Create Neon branch for this workspace
echo "🗄️ Creating Neon branch..."
# Delete Neon branch for this workspace
WORKSPACE_NAME="${SUPERSET_WORKSPACE_NAME:-$(basename "$PWD")}"
NEON_OUTPUT=$(neonctl branches create \
--project-id tiny-cherry-82420694 \
--name "$WORKSPACE_NAME" \
--output json 2>&1 | grep -v "^WARNING:")

# Parse connection strings from create output
DATABASE_URL=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_uri')
POOLER_HOST=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.pooler_host')
PASSWORD=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.password')
ROLE=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.role')
DATABASE=$(echo "$NEON_OUTPUT" | jq -r '.connection_uris[0].connection_parameters.database')
DATABASE_POOLED_URL="postgresql://${ROLE}:${PASSWORD}@${POOLER_HOST}/${DATABASE}?sslmode=require"

cat > .env << EOF
DATABASE_URL=$DATABASE_URL
DATABASE_POOLED_URL=$DATABASE_POOLED_URL
EOF
echo "🗄️ Deleting Neon branch: $WORKSPACE_NAME"
if neonctl branches delete "$WORKSPACE_NAME" --project-id tiny-cherry-82420694 --force 2>/dev/null; then
success "Neon branch deleted: $WORKSPACE_NAME"
else
echo "⚠️ Neon branch '$WORKSPACE_NAME' not found or already deleted"
fi

success "Neon branch created: $WORKSPACE_NAME"
echo "✨ Done!"
echo "✨ Teardown complete!"