From 1b5f2b72d72654d6fcf50b2e9666ded0c8de1c69 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 21 Oct 2025 13:56:11 -0700 Subject: [PATCH] bin/setup detects when it needs to set up seeds --- bin/setup | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/setup b/bin/setup index f2a2d9737..153fd34de 100755 --- a/bin/setup +++ b/bin/setup @@ -34,6 +34,15 @@ step() { return $exit_code } +needs_seeding() { + has_tenant=$(bin/rails runner "pp ApplicationRecord.tenants.any? { ApplicationRecord.with_tenant(_1) { Account.sole } }" 2>/dev/null) + if [ "$has_tenant" = "true" ] ; then + return 1 + else + return 0 + fi +} + echo gum style --foreground 153 " ˚ ∘ ∘ ˚ " gum style --foreground 111 --bold " ∘˚˳°∘° 𝒻𝒾𝓏𝓏𝓎 °∘°˳˚∘ " @@ -60,6 +69,8 @@ fi if [[ $* == *--reset* ]]; then step "Resetting the database" rails db:reset +elif needs_seeding; then + step "Setting up the database" rails db:reset else step "Preparing the database" rails db:prepare fi