Skip to content

Commit 9250f86

Browse files
committed
Update database structure
1 parent b033130 commit 9250f86

10 files changed

+135
-120
lines changed

database/migrations/2014_10_12_000000_create_users_table.php renamed to database/migrations/0001_01_01_000000_create_users_table.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
return new class extends Migration
8-
{
7+
return new class extends Migration {
98
/**
109
* Run the migrations.
1110
*/
@@ -22,6 +21,21 @@ public function up(): void
2221
$table->rememberToken();
2322
$table->timestamps();
2423
});
24+
25+
Schema::create('password_reset_tokens', function (Blueprint $table) {
26+
$table->string('email')->primary();
27+
$table->string('token');
28+
$table->timestamp('created_at')->nullable();
29+
});
30+
31+
Schema::create('sessions', function (Blueprint $table) {
32+
$table->string('id')->primary();
33+
$table->foreignId('user_id')->nullable()->index();
34+
$table->string('ip_address', 45)->nullable();
35+
$table->text('user_agent')->nullable();
36+
$table->longText('payload');
37+
$table->integer('last_activity')->index();
38+
});
2539
}
2640

2741
/**
@@ -30,5 +44,7 @@ public function up(): void
3044
public function down(): void
3145
{
3246
Schema::dropIfExists('users');
47+
Schema::dropIfExists('password_reset_tokens');
48+
Schema::dropIfExists('sessions');
3349
}
3450
};
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+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('cache', function (Blueprint $table) {
15+
$table->string('key')->primary();
16+
$table->mediumText('value');
17+
$table->integer('expiration');
18+
});
19+
20+
Schema::create('cache_locks', function (Blueprint $table) {
21+
$table->string('key')->primary();
22+
$table->string('owner');
23+
$table->integer('expiration');
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*/
30+
public function down(): void
31+
{
32+
Schema::dropIfExists('cache');
33+
Schema::dropIfExists('cache_locks');
34+
}
35+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('jobs', function (Blueprint $table) {
15+
$table->id();
16+
$table->string('queue')->index();
17+
$table->longText('payload');
18+
$table->unsignedTinyInteger('attempts');
19+
$table->unsignedInteger('reserved_at')->nullable();
20+
$table->unsignedInteger('available_at');
21+
$table->unsignedInteger('created_at');
22+
});
23+
24+
Schema::create('job_batches', function (Blueprint $table) {
25+
$table->string('id')->primary();
26+
$table->string('name');
27+
$table->integer('total_jobs');
28+
$table->integer('pending_jobs');
29+
$table->integer('failed_jobs');
30+
$table->longText('failed_job_ids');
31+
$table->mediumText('options')->nullable();
32+
$table->integer('cancelled_at')->nullable();
33+
$table->integer('created_at');
34+
$table->integer('finished_at')->nullable();
35+
});
36+
37+
Schema::create('failed_jobs', function (Blueprint $table) {
38+
$table->id();
39+
$table->string('uuid')->unique();
40+
$table->text('connection');
41+
$table->text('queue');
42+
$table->longText('payload');
43+
$table->longText('exception');
44+
$table->timestamp('failed_at')->useCurrent();
45+
});
46+
}
47+
48+
/**
49+
* Reverse the migrations.
50+
*/
51+
public function down(): void
52+
{
53+
Schema::dropIfExists('jobs');
54+
Schema::dropIfExists('job_batches');
55+
Schema::dropIfExists('failed_jobs');
56+
}
57+
};

database/migrations/2014_10_12_100000_create_password_resets_table.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
6+
use Laravel\Fortify\Fortify;
67

78
return new class extends Migration
89
{
@@ -19,6 +20,12 @@ public function up(): void
1920
$table->text('two_factor_recovery_codes')
2021
->after('two_factor_secret')
2122
->nullable();
23+
24+
if (Fortify::confirmsTwoFactorAuthentication()) {
25+
$table->timestamp('two_factor_confirmed_at')
26+
->after('two_factor_recovery_codes')
27+
->nullable();
28+
}
2229
});
2330
}
2431

@@ -28,7 +35,12 @@ public function up(): void
2835
public function down(): void
2936
{
3037
Schema::table('users', function (Blueprint $table) {
31-
$table->dropColumn('two_factor_secret', 'two_factor_recovery_codes');
38+
$table->dropColumn(array_merge([
39+
'two_factor_secret',
40+
'two_factor_recovery_codes',
41+
], Fortify::confirmsTwoFactorAuthentication() ? [
42+
'two_factor_confirmed_at',
43+
] : []));
3244
});
3345
}
3446
};

database/migrations/2019_08_19_000000_create_failed_jobs_table.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

database/migrations/2023_10_07_114319_create_media_table.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
return new class extends Migration
88
{
9+
/**
10+
* Run the migrations.
11+
*/
912
public function up(): void
1013
{
1114
Schema::create('media', function (Blueprint $table) {
@@ -29,4 +32,12 @@ public function up(): void
2932
$table->nullableTimestamps();
3033
});
3134
}
35+
36+
/**
37+
* Reverse the migrations.
38+
*/
39+
public function down()
40+
{
41+
Schema::dropIfExists('media');
42+
}
3243
};

database/migrations/2024_06_02_000000_rename_password_resets_table.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)