insertGetId([ 'username' => 'legacy-user', 'email' => 'legacy@example.test', 'password' => 'x', 'role' => 'user', ]); $filamentId = DB::table('filamentTracker')->insertGetId([ 'userId' => $userId, 'filamentName' => 'Legacy PLA', 'amazonUrl' => 'https://example.test/x', 'filamentWeight' => 1000, 'brand' => 'LegacyBrand', 'material' => 'PLA', 'color' => 'Black', 'itemDiameter' => 1.75, ]); DB::table('filamentPriceHistory')->insert([ 'filamentId' => $filamentId, 'price' => 19.99, 'recordedAt' => now(), ]); // Re-running migrate must be a no-op for already-applied migrations and // must not touch legacy rows that predate the project/costing tables. Artisan::call('migrate', ['--force' => true]); $this->assertDatabaseHas('filamentTracker', ['id' => $filamentId, 'filamentName' => 'Legacy PLA', 'userId' => $userId]); $this->assertDatabaseHas('filamentPriceHistory', ['filamentId' => $filamentId, 'price' => 19.99]); $this->assertDatabaseCount('filamentTracker', 1); } public function test_project_tables_are_additive_and_coexist_with_legacy_tables(): void { $this->assertTrue(Schema::hasTable('filamentTracker')); $this->assertTrue(Schema::hasTable('filamentPriceHistory')); $this->assertTrue(Schema::hasTable('bambuPrinters')); $this->assertTrue(Schema::hasTable('projects')); $this->assertTrue(Schema::hasTable('project_cost_snapshots')); } }