# Quick Setup Guide

## Problem
When running `php artisan dev:install` in the admin app, it calls the tenant app API which needs the `taskco_saas_app` database to exist.

## Solution
Two new commands added to the **tenant app** (`/home/shakib/Dev/projects/saas-docker/app`):

### 1. `php artisan db:ensure`
Checks if the `taskco_saas_app` database exists, creates it if not.

### 2. `php artisan dev:setup [--fresh]`
Complete setup: ensures database exists + runs migrations (+ seeders with --fresh).

## Usage

### Setup Tenant App (One Time)
```bash
cd /home/shakib/Dev/projects/saas-docker
docker compose exec app php artisan dev:setup --fresh
```

### Setup Admin App
```bash
cd /home/shakib/Dev/projects/saas-admin-docker/app
php artisan dev:install
```

## What Changed

1. **Admin App** - Now shows helpful message if tenant app is not ready:
   ```
   ⚠️  Cannot reach tenant app
   Run: cd /home/shakib/Dev/projects/saas-docker && docker compose exec app php artisan dev:setup --fresh
   ```

2. **Tenant App** - New commands to ensure database exists before anything else

## Files Created

- `/home/shakib/Dev/projects/saas-docker/app/app/Console/Commands/EnsureDatabaseExists.php`
- `/home/shakib/Dev/projects/saas-docker/app/app/Console/Commands/DevSetup.php`

## Complete Workflow

```bash
# 1. Setup tenant app (one time)
cd /home/shakib/Dev/projects/saas-docker
docker compose up -d
docker compose exec app php artisan db:ensure
# Fix migration issues in tenant app, then:
docker compose exec app php artisan migrate --force

# 2. Setup admin app
cd /home/shakib/Dev/projects/saas-admin-docker/app
php artisan dev:install
```

## Note on Tenant App Migrations

The tenant app has a migration issue where `notes` table references `users` table that doesn't exist yet. This needs to be fixed in the tenant app's migration files.
