Skip to content

Commit 1abcf14

Browse files
committed
$table->string('name')->unique();
1 parent 19c6097 commit 1abcf14

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

database/migrations/2014_10_12_000000_create_users_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function up()
1515
{
1616
Schema::create('users', function (Blueprint $table) {
1717
$table->id();
18-
$table->string('name')->unique();
18+
$table->string('name');
1919
$table->string('email')->unique();
2020
$table->timestamp('email_verified_at')->nullable();
2121
$table->string('password');

resources/views/components/finishing.blade.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,10 @@ function getStringBetween($string, $start, $end) {
146146
} catch (exception $e) {}
147147
148148
// Remove unique constrain from user names
149-
class UpdateNameColumnInUsersTable extends Migration
150-
{
151-
public function up()
152-
{
153-
try {
154-
Schema::table('users', function (Blueprint $table) {
155-
$table->dropUnique('users_name_unique');
156-
$table->string('name')->unique(false)->change();
157-
});
158-
} catch (\Throwable $th) {}
159-
}
160-
161-
public function down()
162-
{
163-
try {
164-
Schema::table('users', function (Blueprint $table) {
165-
$table->string('name')->unique()->change();
166-
});
167-
} catch (\Throwable $th) {}
168-
}
169-
}
149+
try {
150+
$affected_rows = DB::delete(DB::raw("DELETE FROM users WHERE id NOT IN (SELECT MIN(id) FROM users GROUP BY name)"));
151+
$message = "Duplicate rows removed successfully. $affected_rows rows were affected.";
152+
} catch (\Exception $e) {}
170153
171154
// Changes saved profile images from littlelink_name to IDs.
172155
// This runs every time the updater runs.

0 commit comments

Comments
 (0)