assertFalse(Schema::hasTable('assets')); $this->assertFalse(Schema::hasTable('asset_prices')); $this->assertFalse(Schema::hasColumn('trackers', 'asset_id')); $this->assertFalse(Schema::hasColumn('trackers', 'price_tracking_enabled')); } public function test_down_restores_the_tables_and_columns(): void { $this->migration()->down(); $this->assertTrue(Schema::hasTable('assets')); $this->assertTrue(Schema::hasTable('asset_prices')); $this->assertTrue(Schema::hasColumn('trackers', 'asset_id')); $this->assertTrue(Schema::hasColumn('trackers', 'price_tracking_enabled')); } public function test_up_drops_them_again_respecting_foreign_keys(): void { $this->migration()->down(); $this->migration()->up(); $this->assertFalse(Schema::hasTable('assets')); $this->assertFalse(Schema::hasTable('asset_prices')); $this->assertFalse(Schema::hasColumn('trackers', 'asset_id')); $this->assertFalse(Schema::hasColumn('trackers', 'price_tracking_enabled')); } public function test_dropping_assets_does_not_disturb_the_counter(): void { $this->migration()->down(); $userId = DB::table('users')->insertGetId([ 'name' => 'Test', 'email' => 'assets@example.test', 'password' => 'x', 'created_at' => now(), 'updated_at' => now(), ]); $trackerId = DB::table('trackers')->insertGetId([ 'user_id' => $userId, 'label' => 'Counter', 'unit' => 'units', 'count' => 31, 'created_at' => now(), 'updated_at' => now(), ]); $this->migration()->up(); $this->assertSame(31, (int) DB::table('trackers')->where('id', $trackerId)->value('count')); } }