Reset Installation

This guide covers how to reset AutoCom to a fresh, out-of-box state so the installation wizard appears again.

Quick Reset (Recommended)

Kubernetes Deployment

# 1. Remove the .installed marker file
kubectl exec -n autocom deployment/api -- rm -f /var/www/html/storage/.installed

# 2. Truncate user data tables
kubectl exec -n autocom postgres-0 -- psql -U autocom -d autocom -c "
TRUNCATE users CASCADE;
TRUNCATE tenants CASCADE;
TRUNCATE roles CASCADE;
TRUNCATE permissions CASCADE;
TRUNCATE oauth_clients CASCADE;
"

# 3. Flush Redis cache
REDIS_PASS=$(kubectl get secret autocom-secrets -n autocom -o jsonpath='{.data.REDIS_PASSWORD}' | base64 -d)
kubectl exec -n autocom redis-0 -- redis-cli -a "$REDIS_PASS" FLUSHALL

# 4. Clear Laravel cache
kubectl exec -n autocom deployment/api -- php artisan cache:clear
kubectl exec -n autocom deployment/api -- php artisan config:clear

# 5. Verify reset
curl -s http://localhost:5350/api/v1/install/check
# Should show: {"installed":false,...}

Docker Compose Deployment

# 1. Remove the .installed marker file
docker compose exec app rm -f /var/www/html/storage/.installed

# 2. Truncate user data tables
docker compose exec postgres psql -U autocom -d autocom -c "
TRUNCATE users CASCADE;
TRUNCATE tenants CASCADE;
TRUNCATE roles CASCADE;
TRUNCATE permissions CASCADE;
TRUNCATE oauth_clients CASCADE;
"

# 3. Flush Redis cache
docker compose exec redis redis-cli -a your_redis_password FLUSHALL

# 4. Clear Laravel cache
docker compose exec app php artisan cache:clear
docker compose exec app php artisan config:clear

# 5. Verify reset
curl -s http://localhost:8000/api/v1/install/check
# Should show: {"installed":false,...}

Full Reset (Complete Wipe)

For a complete database wipe including all migrations:

Kubernetes

# 1. Scale down all services
kubectl scale deployment api horizon nginx frontend -n autocom --replicas=0
sleep 5

# 2. Terminate database connections
kubectl exec -n autocom postgres-0 -- psql -U autocom -d postgres -c "
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname = 'autocom' AND pid <> pg_backend_pid();"

# 3. Drop and recreate database
kubectl exec -n autocom postgres-0 -- psql -U autocom -d postgres -c "DROP DATABASE autocom;"
kubectl exec -n autocom postgres-0 -- psql -U autocom -d postgres -c "CREATE DATABASE autocom OWNER autocom;"

# 4. Flush Redis
REDIS_PASS=$(kubectl get secret autocom-secrets -n autocom -o jsonpath='{.data.REDIS_PASSWORD}' | base64 -d)
kubectl exec -n autocom redis-0 -- redis-cli -a "$REDIS_PASS" FLUSHALL

# 5. Scale services back up (migrations run automatically)
kubectl scale deployment api -n autocom --replicas=2
kubectl scale deployment nginx frontend -n autocom --replicas=2
kubectl scale deployment horizon -n autocom --replicas=1

# 6. Wait for services
kubectl rollout status deployment/api -n autocom --timeout=120s

Docker Compose

# 1. Stop services
docker compose stop app horizon

# 2. Drop and recreate database
docker compose exec postgres psql -U autocom -d postgres -c "DROP DATABASE autocom;"
docker compose exec postgres psql -U autocom -d postgres -c "CREATE DATABASE autocom OWNER autocom;"

# 3. Flush Redis
docker compose exec redis redis-cli -a your_redis_password FLUSHALL

# 4. Start services (migrations run automatically)
docker compose up -d app horizon

# 5. Wait and verify
sleep 10
curl -s http://localhost:8000/api/v1/install/check

Reset Script

Create a reset script for convenience:

scripts/reset-install.sh

#!/bin/bash
set -e

NAMESPACE=${1:-autocom}
DEPLOYMENT_TYPE=${2:-kubernetes}  # kubernetes or docker

echo "Resetting AutoCom installation..."

if [ "$DEPLOYMENT_TYPE" = "kubernetes" ]; then
    # Kubernetes reset
    echo "Removing .installed file..."
    kubectl exec -n $NAMESPACE deployment/api -- rm -f /var/www/html/storage/.installed 2>/dev/null || true

    echo "Truncating user data..."
    kubectl exec -n $NAMESPACE postgres-0 -- psql -U autocom -d autocom -c "
    TRUNCATE users CASCADE;
    TRUNCATE tenants CASCADE;
    TRUNCATE roles CASCADE;
    TRUNCATE permissions CASCADE;
    TRUNCATE oauth_clients CASCADE;
    "

    echo "Flushing Redis..."
    REDIS_PASS=$(kubectl get secret autocom-secrets -n $NAMESPACE -o jsonpath='{.data.REDIS_PASSWORD}' | base64 -d)
    kubectl exec -n $NAMESPACE redis-0 -- redis-cli -a "$REDIS_PASS" FLUSHALL 2>/dev/null

    echo "Clearing Laravel cache..."
    kubectl exec -n $NAMESPACE deployment/api -- php artisan cache:clear 2>/dev/null || true
    kubectl exec -n $NAMESPACE deployment/api -- php artisan config:clear 2>/dev/null || true

else
    # Docker Compose reset
    echo "Removing .installed file..."
    docker compose exec app rm -f /var/www/html/storage/.installed 2>/dev/null || true

    echo "Truncating user data..."
    docker compose exec postgres psql -U autocom -d autocom -c "
    TRUNCATE users CASCADE;
    TRUNCATE tenants CASCADE;
    TRUNCATE roles CASCADE;
    TRUNCATE permissions CASCADE;
    TRUNCATE oauth_clients CASCADE;
    "

    echo "Flushing Redis..."
    docker compose exec redis redis-cli FLUSHALL 2>/dev/null || true

    echo "Clearing Laravel cache..."
    docker compose exec app php artisan cache:clear 2>/dev/null || true
    docker compose exec app php artisan config:clear 2>/dev/null || true
fi

echo ""
echo "Reset complete! Visit the application to see the installer."

Usage:

# Kubernetes
./scripts/reset-install.sh autocom kubernetes

# Docker Compose
./scripts/reset-install.sh autocom docker

What Gets Reset

Component Quick Reset Full Reset
.installed file Removed Removed
Users table Truncated Dropped
Tenants table Truncated Dropped
Roles/Permissions Truncated Dropped
OAuth clients Truncated Dropped
Redis cache Flushed Flushed
Laravel cache Cleared Cleared
Migrations Preserved Re-run
Other tables Preserved Dropped

How Installation Detection Works

AutoCom determines if it's installed by checking:

  1. .installed file - Located at storage/.installed
  2. Database state - Checks if users AND tenants tables have records
private function isInstalled(): bool
{
    // Check for .installed file
    if (file_exists(storage_path('.installed'))) {
        return true;
    }

    // Check if users and tenants exist
    if (Schema::hasTable('users') && Schema::hasTable('tenants')) {
        return User::exists() && Tenant::exists();
    }

    return false;
}

Troubleshooting

Reset doesn't work

  1. Check all API pods - The .installed file needs to be removed from all pods:

    kubectl get pods -n autocom -l app.kubernetes.io/component=api -o name | \
      xargs -I {} kubectl exec -n autocom {} -- rm -f /var/www/html/storage/.installed
    
  2. Verify database is cleared:

    kubectl exec -n autocom postgres-0 -- psql -U autocom -d autocom -c "SELECT COUNT(*) FROM users;"
    # Should return 0
    
  3. Check Redis is flushed:

    kubectl exec -n autocom redis-0 -- redis-cli -a $REDIS_PASS DBSIZE
    # Should return 0 or very low number
    

Database connection errors during reset

Scale down services first to release connections:

kubectl scale deployment api horizon -n autocom --replicas=0
sleep 5
# Then run reset commands

Installer still shows "already installed"

Clear browser cache and cookies, or try incognito mode. The frontend may have cached the installation state.

Next Steps

After reset, access the application at your configured URL to start the installation wizard:

  1. Requirements Check - Verifies system requirements
  2. Database Setup - Runs migrations (usually auto-completed)
  3. Initial Data - Seeds required data (roles, permissions)
  4. Create Owner - Create the first admin user and tenant
  5. Module Selection - Enable/disable modules
  6. Additional Tenants - Optionally create more tenants