$table->string('name')->unique();

This commit is contained in:
Julian Prieber 2023-03-08 19:30:08 +01:00
parent 19c6097a1c
commit 1abcf14b5a
2 changed files with 5 additions and 22 deletions

View File

@ -15,7 +15,7 @@ class CreateUsersTable extends Migration
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');

View File

@ -146,27 +146,10 @@ use Illuminate\Support\Facades\File;
} catch (exception $e) {}
// Remove unique constrain from user names
class UpdateNameColumnInUsersTable extends Migration
{
public function up()
{
try {
Schema::table('users', function (Blueprint $table) {
$table->dropUnique('users_name_unique');
$table->string('name')->unique(false)->change();
});
} catch (\Throwable $th) {}
}
public function down()
{
try {
Schema::table('users', function (Blueprint $table) {
$table->string('name')->unique()->change();
});
} catch (\Throwable $th) {}
}
}
try {
$affected_rows = DB::delete(DB::raw("DELETE FROM users WHERE id NOT IN (SELECT MIN(id) FROM users GROUP BY name)"));
$message = "Duplicate rows removed successfully. $affected_rows rows were affected.";
} catch (\Exception $e) {}
// Changes saved profile images from littlelink_name to IDs.
// This runs every time the updater runs.