Skip to content

Commit daae495

Browse files
committed
Fixes Docker image is missing fields
Fixes #143
1 parent 3b0e900 commit daae495

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ class User extends Authenticatable
191191

192192
protected $fillable = [
193193
'name',
194+
'formatted',
194195
'email',
195196
'password',
197+
'active',
198+
196199
];
197200

198201
protected $hidden = [
@@ -202,6 +205,8 @@ class User extends Authenticatable
202205

203206
protected $casts = [
204207
'email_verified_at' => 'datetime',
208+
'active' => 'boolean',
209+
205210
];
206211

207212
public function groups(): BelongsToMany
@@ -235,6 +240,53 @@ class DemoSeeder extends Seeder
235240
}
236241
EOM
237242

243+
# Add migration to add SCIM fields to users table
244+
RUN cat > /example/database/migrations/2021_01_01_000003_add_scim_fields_to_users_table.php <<'EOM'
245+
<?php
246+
247+
use Illuminate\Database\Migrations\Migration;
248+
use Illuminate\Database\Schema\Blueprint;
249+
use Illuminate\Support\Facades\Schema;
250+
251+
return new class extends Migration {
252+
public function up(): void
253+
{
254+
Schema::table('users', function (Blueprint $table) {
255+
if (!Schema::hasColumn('users', 'formatted')) {
256+
$table->string('formatted')->nullable();
257+
}
258+
if (!Schema::hasColumn('users', 'displayName')) {
259+
$table->string('displayName')->nullable();
260+
}
261+
if (!Schema::hasColumn('users', 'active')) {
262+
$table->boolean('active')->default(false);
263+
}
264+
if (!Schema::hasColumn('users', 'roles')) {
265+
$table->json('roles')->nullable();
266+
}
267+
});
268+
}
269+
270+
public function down(): void
271+
{
272+
Schema::table('users', function (Blueprint $table) {
273+
if (Schema::hasColumn('users', 'formatted')) {
274+
$table->dropColumn('formatted');
275+
}
276+
if (Schema::hasColumn('users', 'displayName')) {
277+
$table->dropColumn('displayName');
278+
}
279+
if (Schema::hasColumn('users', 'active')) {
280+
$table->dropColumn('active');
281+
}
282+
if (Schema::hasColumn('users', 'roles')) {
283+
$table->dropColumn('roles');
284+
}
285+
});
286+
}
287+
};
288+
EOM
289+
238290
# Run migrations and seed demo data
239291
RUN php artisan migrate && php artisan db:seed --class=Database\\Seeders\\DemoSeeder
240292

database/factories/UserFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
'formatted' => $faker->name,
1010
'name' => $faker->name,
1111
'password'=>'test',
12-
'active' => $faker->boolean
12+
'active' => $faker->boolean,
1313
];
1414
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
public function up(): void
9+
{
10+
if (Schema::hasTable('users')) {
11+
Schema::table('users', function (Blueprint $table) {
12+
if (!Schema::hasColumn('users', 'formatted')) {
13+
$table->string('formatted')->nullable();
14+
}
15+
if (!Schema::hasColumn('users', 'active')) {
16+
$table->boolean('active')->default(false);
17+
}
18+
});
19+
}
20+
}
21+
22+
public function down(): void
23+
{
24+
if (Schema::hasTable('users')) {
25+
Schema::table('users', function (Blueprint $table) {
26+
if (Schema::hasColumn('users', 'formatted')) {
27+
$table->dropColumn('formatted');
28+
}
29+
if (Schema::hasColumn('users', 'active')) {
30+
$table->dropColumn('active');
31+
}
32+
});
33+
}
34+
}
35+
};

0 commit comments

Comments
 (0)