Development data is being preserved for production release. The --fresh flag now requires explicit confirmation before dropping all tables.
86 lines
3.0 KiB
PHP
86 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
class DevSetup extends Command
|
|
{
|
|
protected $signature = 'dev:setup
|
|
{--fresh : Drop all tables and re-run migrations (DESTRUCTIVE - requires confirmation)}
|
|
{--skip-seed : Skip seeding dev fixtures}';
|
|
|
|
protected $description = 'Set up local development environment with migrations and dev fixtures';
|
|
|
|
public function handle(): int
|
|
{
|
|
if (app()->environment('production')) {
|
|
$this->error('This command cannot be run in production!');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->info('Setting up development environment...');
|
|
$this->newLine();
|
|
|
|
// Run migrations
|
|
if ($this->option('fresh')) {
|
|
$this->newLine();
|
|
$this->error('WARNING: --fresh will DELETE ALL DATA in the database!');
|
|
$this->warn('This includes development data being preserved for production release.');
|
|
$this->newLine();
|
|
|
|
if (! $this->confirm('Are you SURE you want to drop all tables and lose all data?', false)) {
|
|
$this->info('Aborted. Running normal migrations instead...');
|
|
$this->call('migrate');
|
|
} else {
|
|
$this->warn('Dropping all tables and re-running migrations...');
|
|
$this->call('migrate:fresh');
|
|
}
|
|
} else {
|
|
$this->info('Running migrations...');
|
|
$this->call('migrate');
|
|
}
|
|
|
|
$this->newLine();
|
|
|
|
// Seed dev fixtures
|
|
if (! $this->option('skip-seed')) {
|
|
if ($this->confirm('Seed development fixtures (users, businesses, brands)?', true)) {
|
|
$this->info('Seeding development fixtures...');
|
|
$this->call('db:seed', ['--class' => 'ProductionSyncSeeder']);
|
|
|
|
$this->newLine();
|
|
$this->info('Seeding dev suites and plans...');
|
|
$this->call('db:seed', ['--class' => 'DevSuitesSeeder']);
|
|
|
|
$this->newLine();
|
|
$this->info('Seeding brand profiles...');
|
|
$this->call('db:seed', ['--class' => 'BrandProfilesSeeder']);
|
|
|
|
$this->newLine();
|
|
$this->info('Seeding orchestrator profiles...');
|
|
$this->call('orchestrator:seed-brand-profiles', ['--force' => true]);
|
|
}
|
|
}
|
|
|
|
$this->newLine();
|
|
$this->info('Development setup complete!');
|
|
$this->newLine();
|
|
|
|
$this->table(
|
|
['Credential', 'Email', 'Password'],
|
|
[
|
|
['Super Admin', 'admin@cannabrands.com', 'password'],
|
|
['Admin', 'admin@example.com', 'password'],
|
|
['Seller', 'seller@example.com', 'password'],
|
|
['Buyer', 'buyer@example.com', 'password'],
|
|
['Cannabrands Owner', 'cannabrands-owner@example.com', 'password'],
|
|
['Brand Manager', 'brand-manager@example.com', 'password'],
|
|
]
|
|
);
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|