Skip to content
Snippets Groups Projects
Unverified Commit a040b018 authored by Maxime FRIESS's avatar Maxime FRIESS :blue_heart:
Browse files

[db] Fixed migrations

parent e0c63770
Branches
Tags
No related merge requests found
......@@ -5,6 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use Illuminate\Support\Facades\DB;
class CreateUsersTable extends Migration
{
......@@ -28,13 +29,13 @@ class CreateUsersTable extends Migration
$table->timestamp('password_changed_at')->nullable()->default(null);
});
$user = User::create([
DB::table('users')->insert([
'username' => 'root',
'firstname' => 'Chuck',
'lastname' => 'NORRIS',
'email' => 'root@localhost',
'password' => Hash::make('rootroot'),
'permissions' => ["*.*"]
'permissions' => '["*.*"]'
]);
// Ensure next IDs are > 1000.
......
......@@ -27,6 +27,17 @@ class AddPeopleUser extends Migration
->where('firstname', $user->firstname)
->where('lastname', $user->lastname)->first();
if ($person == null) {
$person = DB::table('people')->insert([
'firstname' => $user->firstname,
'lastname' => $user->lastname
]);
$person = DB::table('people')
->where('firstname', $user->firstname)
->where('lastname', $user->lastname)->first();
}
DB::table('users')->where('id', $user->id)->update(['person_id' => $person->id]);
}
});
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment