Created
February 24, 2020 13:22
-
-
Save sonichandni/6c3d217f9168a35a0d014a297017d417 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/clear-user-data', function() { | |
Schema::disableForeignKeyConstraints(); | |
$tables = DB::select('SHOW TABLES'); | |
// echo "<pre>"; print_r($tables); exit; | |
// $cnt = 93; | |
$cnt = range(55,89); | |
// $cnt = range(87,91); | |
foreach($cnt as $c){ | |
foreach($tables as $table){ | |
if($table != 'users'){ | |
if (Schema::hasColumn($table->Tables_in_dbName, 'user_id')) { | |
$row = DB::table($table->Tables_in_dbName)->where('user_id', $c)->delete(); | |
// if($row){ | |
// $row->delete(); | |
// } | |
} | |
} | |
} | |
DB::table('users')->where('id', $c)->delete(); | |
} | |
Schema::enableForeignKeyConstraints(); | |
return 'cleared'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment