From 63816a7993ceb8e2688f468d4b28126ae43a13b7 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 28 Jan 2026 22:03:06 +0000 Subject: [PATCH] Remove migrate:begin/commit/rollback references, unify to migrate command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/RSpade/Commands/Database/Seed_Command.php | 13 +++++--- app/RSpade/Commands/Migrate/Maint_Migrate.php | 2 +- .../Migrate_Normalize_Schema_Command.php | 20 ++++++------ .../Migrate/Migrate_Status_Command.php | 16 ++++------ .../Commands/Restricted/Reset_Command.php | 13 ++++---- .../Manifest/_Manifest_Database_Helper.php | 4 +-- app/RSpade/man/model_normalization.txt | 32 +++++++++---------- app/RSpade/man/rspade.txt | 17 ++++++---- 8 files changed, 59 insertions(+), 58 deletions(-) diff --git a/app/RSpade/Commands/Database/Seed_Command.php b/app/RSpade/Commands/Database/Seed_Command.php index 1036778bb..a7b6f8110 100644 --- a/app/RSpade/Commands/Database/Seed_Command.php +++ b/app/RSpade/Commands/Database/Seed_Command.php @@ -37,18 +37,21 @@ class Seed_Command extends LaravelSeedCommand // Check for migration mode if we require it if ($require_migration_mode) { if (!file_exists($this->flag_file)) { - $this->error('❌ Migration mode not active!'); + $this->error('[ERROR] Migration mode not active!'); $this->error(''); - $this->line('In development mode, you must create a database snapshot before running seeders.'); + $this->line('In development mode, seeders must be run within a migration session.'); $this->line('This prevents data corruption if seeding fails.'); $this->info(''); - $this->line('To begin a migration session:'); - $this->line(' php artisan migrate:begin'); + $this->line('To seed the database, use the --seed flag with migrate:'); + $this->line(' php artisan migrate --seed'); + $this->info(''); + $this->line('Or use the --production flag to skip snapshot protection:'); + $this->line(' php artisan db:seed --production'); return 1; } - $this->info('✅ Migration mode active - snapshot available for rollback'); + $this->info('[OK] Migration mode active - snapshot available for rollback'); $this->info(''); } diff --git a/app/RSpade/Commands/Migrate/Maint_Migrate.php b/app/RSpade/Commands/Migrate/Maint_Migrate.php index a465507a5..701b294ef 100644 --- a/app/RSpade/Commands/Migrate/Maint_Migrate.php +++ b/app/RSpade/Commands/Migrate/Maint_Migrate.php @@ -78,7 +78,7 @@ class Maint_Migrate extends Command $this->info(' Development mode: Using automatic snapshot protection'); $this->info(''); - // Step 1: Create snapshot (migrate:begin logic) + // Step 1: Create snapshot $this->info('[1/4] Creating database snapshot...'); if (!$this->create_snapshot()) { return 1; diff --git a/app/RSpade/Commands/Migrate/Migrate_Normalize_Schema_Command.php b/app/RSpade/Commands/Migrate/Migrate_Normalize_Schema_Command.php index 97eb024ab..da97db887 100644 --- a/app/RSpade/Commands/Migrate/Migrate_Normalize_Schema_Command.php +++ b/app/RSpade/Commands/Migrate/Migrate_Normalize_Schema_Command.php @@ -106,11 +106,14 @@ class Migrate_Normalize_Schema_Command extends Command if (!file_exists($flag_file)) { $this->error('[ERROR] Migration mode not active!'); $this->error(''); - $this->line('In development mode, you must create a database snapshot before running this command.'); - $this->line('This prevents partial migrations from corrupting your database.'); + $this->line('In development mode, this command should be run via "php artisan migrate"'); + $this->line('which handles snapshots automatically.'); $this->info(''); - $this->line('To begin a migration session:'); - $this->line(' php artisan migrate:begin'); + $this->line('To run with snapshot protection:'); + $this->line(' php artisan migrate'); + $this->info(''); + $this->line('Or use the --production flag to skip snapshot protection:'); + $this->line(' php artisan migrate:normalize_schema --production'); return 1; } @@ -298,15 +301,12 @@ class Migrate_Normalize_Schema_Command extends Command $this->info(''); $this->info('[OK] Database rolled back successfully!'); $this->info(''); - $this->warn('[WARNING] You are still in migration mode.'); - $this->line('Your options:'); - $this->line(' 1. Fix the issue mentioned in the error above'); - $this->line(' 2. Run "php artisan migrate" to try again'); - $this->line(' 3. Run "php artisan migrate:commit" to exit migration mode'); + $this->line('Fix the issue mentioned in the error above, then run:'); + $this->line(' php artisan migrate'); } else { $this->error('[ERROR] Automatic rollback failed!'); - $this->error('Run "php artisan migrate:rollback" manually.'); $this->warn('[WARNING] The database may be in an inconsistent state!'); + $this->line('You may need to manually restore from backup.'); } } diff --git a/app/RSpade/Commands/Migrate/Migrate_Status_Command.php b/app/RSpade/Commands/Migrate/Migrate_Status_Command.php index 929e24beb..b987efc10 100644 --- a/app/RSpade/Commands/Migrate/Migrate_Status_Command.php +++ b/app/RSpade/Commands/Migrate/Migrate_Status_Command.php @@ -25,12 +25,11 @@ class Migrate_Status_Command extends Command $this->info('[OK] No migration session in progress'); $this->info(''); + $this->line('To run migrations:'); + $this->line(' php artisan migrate'); if ($environment !== 'production') { - $this->line('To start a migration session:'); - $this->line(' php artisan migrate:begin'); - } else { - $this->line('In production, run migrations directly:'); - $this->line(' php artisan migrate'); + $this->line(''); + $this->line('In development mode, snapshots are created automatically.'); } return 0; @@ -57,10 +56,9 @@ class Migrate_Status_Command extends Command } $this->info(''); - $this->line('Available Commands:'); - $this->line(' • php artisan migrate - Run pending migrations'); - $this->line(' • php artisan migrate:commit - Keep changes and end session'); - $this->line(' • php artisan migrate:rollback - Restore backup and end session'); + $this->line('Migration Mode:'); + $this->line(' This indicates the migrate command is running with snapshot protection.'); + $this->line(' The snapshot will be auto-committed on success or auto-rolled back on failure.'); // Check database connection $this->info(''); diff --git a/app/RSpade/Commands/Restricted/Reset_Command.php b/app/RSpade/Commands/Restricted/Reset_Command.php index 496cd0afe..a13b6e7d1 100644 --- a/app/RSpade/Commands/Restricted/Reset_Command.php +++ b/app/RSpade/Commands/Restricted/Reset_Command.php @@ -14,7 +14,7 @@ use Illuminate\Support\Facades\DB; * - Always allowed if IS_FRAMEWORK_DEVELOPER=true * - In development mode: allowed for manual execution, blocked for Claude Code * - In production mode: always blocked - * - Must be in migration mode (migrate:begin) unless IS_FRAMEWORK_DEVELOPER=true + * - Must be in migration mode unless IS_FRAMEWORK_DEVELOPER=true */ class Reset_Command extends Command { @@ -67,17 +67,16 @@ class Reset_Command extends Command // Require migration mode for non-framework developers if (!$in_migration_mode) { - $this->error('❌ migrate:reset requires migration mode to be active.'); + $this->error('[ERROR] migrate:reset requires migration mode to be active.'); $this->newLine(); $this->warn('Database reset protection:'); $this->line('This command can only be run within a migration session to ensure'); $this->line('you have a snapshot to restore if something goes wrong.'); $this->newLine(); - $this->info('To reset the database:'); - $this->line('1. Start migration mode: php artisan migrate:begin'); - $this->line('2. Reset database: php artisan migrate:reset'); - $this->line('3. Run migrations: php artisan migrate'); - $this->line('4. Commit or rollback: php artisan migrate:commit'); + $this->info('Note:'); + $this->line('In development mode, "php artisan migrate" automatically creates'); + $this->line('snapshots and manages rollback. This command is only needed for'); + $this->line('full database drops, which is rarely necessary.'); $this->newLine(); return 1; } diff --git a/app/RSpade/Core/Manifest/_Manifest_Database_Helper.php b/app/RSpade/Core/Manifest/_Manifest_Database_Helper.php index 929813abf..bf5548cef 100755 --- a/app/RSpade/Core/Manifest/_Manifest_Database_Helper.php +++ b/app/RSpade/Core/Manifest/_Manifest_Database_Helper.php @@ -137,14 +137,12 @@ class _Manifest_Database_Helper // Commands that should skip code quality checks $migration_commands = [ 'migrate', - 'migrate:begin', - 'migrate:commit', 'migrate:fresh', 'migrate:install', 'migrate:refresh', 'migrate:reset', - 'migrate:rollback', 'migrate:status', + 'migrate:normalize_schema', 'make:migration', 'make:migration:safe', 'db:seed', diff --git a/app/RSpade/man/model_normalization.txt b/app/RSpade/man/model_normalization.txt index 5ab5bc4ad..46218b1e7 100755 --- a/app/RSpade/man/model_normalization.txt +++ b/app/RSpade/man/model_normalization.txt @@ -393,17 +393,14 @@ COMMANDS Main migration command. Runs the full cycle: pre-normalize → migrations → post-normalize → regenerate constants (dev) -### php artisan migrate:begin - Creates MySQL snapshot before migrations (dev mode only). - Required for safety in development. + In development mode: + - Automatically creates database snapshot before migrations + - On success: commits changes, removes snapshot, regenerates constants/bundles + - On failure: automatically rolls back to snapshot -### php artisan migrate:commit - Deletes snapshot and exits migration mode. - Runs schema quality checks before committing. - -### php artisan migrate:rollback - Restores database to snapshot state. - Stays in migration mode for retry. + In debug/production mode: + - Runs migrations directly without snapshot protection + - Does NOT update source code (constants, bundles) ### php artisan migrate:normalize_schema Manually run normalization (rarely needed). @@ -415,15 +412,16 @@ COMMANDS SNAPSHOT-BASED DEVELOPMENT -------------------------- -Development migrations require snapshots for safety: +In development mode, the migrate command handles snapshots automatically: -1. `php artisan migrate:begin` - Create snapshot -2. `php artisan migrate` - Run migrations -3. `php artisan migrate:commit` - Keep changes, delete snapshot - OR - `php artisan migrate:rollback` - Discard changes, restore snapshot +1. `php artisan migrate` - Does everything: + - Creates snapshot before running + - Runs all pending migrations + - On success: commits snapshot, regenerates constants + - On failure: rolls back to snapshot automatically -Production migrations skip snapshots and run directly. +No manual snapshot management is needed. Just run `migrate` and the framework +handles safety automatically. WHY NO FOREIGN KEY DROP/RECREATE? --------------------------------- diff --git a/app/RSpade/man/rspade.txt b/app/RSpade/man/rspade.txt index 8b9b8c9a2..400be4f26 100755 --- a/app/RSpade/man/rspade.txt +++ b/app/RSpade/man/rspade.txt @@ -266,13 +266,18 @@ DATABASE ARCHITECTURE created_at, updated_at (with proper defaults) Migration Safety: - Development workflow uses database snapshots: - - migrate:begin Creates snapshot before changes - - migrate Runs migrations with validation - - migrate:commit Commits changes and removes snapshot - - migrate:rollback Restores snapshot if problems occur + The migrate command handles snapshots automatically: - Production workflow skips snapshots (test thoroughly first). + Development mode: + - php artisan migrate + - Automatically creates snapshot before running + - On success: commits and regenerates constants/bundles + - On failure: automatically rolls back to snapshot + + Production mode: + - php artisan migrate + - Runs directly without snapshot protection + - Test thoroughly in development first Site-Based Multi-Tenancy: Models extend one of two base classes: