Skip to content

Commit cb2a354

Browse files
committed
fix duplicated migrations
1 parent f00ccd5 commit cb2a354

9 files changed

+43
-0
lines changed

database/migrations/2024_01_01_00000_create_users_table.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\DB;
56
use Illuminate\Support\Facades\Schema;
67

78
return new class extends Migration {
@@ -10,6 +11,10 @@
1011
*/
1112
public function up(): void
1213
{
14+
if (DB::table('migrations')->where('migration', '1_create_users_table')->exists()) {
15+
return;
16+
}
17+
1318
Schema::create('users', function (Blueprint $table) {
1419
$table->id();
1520
$table->string('oauth_id')->nullable();

database/migrations/2024_01_01_00001_create_layouts_table.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\DB;
56
use Illuminate\Support\Facades\Schema;
67

78
return new class extends Migration {
@@ -10,6 +11,10 @@
1011
*/
1112
public function up(): void
1213
{
14+
if (DB::table('migrations')->where('migration', '2_create_layouts_table')->exists()) {
15+
return;
16+
}
17+
1318
Schema::create('layouts', function (Blueprint $table) {
1419
$table->id();
1520

database/migrations/2024_01_01_00002_create_templates_table.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\DB;
56
use Illuminate\Support\Facades\Schema;
67

78
return new class extends Migration {
@@ -10,6 +11,10 @@
1011
*/
1112
public function up(): void
1213
{
14+
if (DB::table('migrations')->where('migration', '3_create_templates_table')->exists()) {
15+
return;
16+
}
17+
1318
Schema::create('templates', function (Blueprint $table) {
1419
$table->id();
1520

database/migrations/2024_01_01_00003_create_logs_table.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\DB;
56
use Illuminate\Support\Facades\Schema;
67
use MailCarrier\Models\Template;
78

@@ -11,6 +12,10 @@
1112
*/
1213
public function up(): void
1314
{
15+
if (DB::table('migrations')->where('migration', '4_create_logs_table')->exists()) {
16+
return;
17+
}
18+
1419
Schema::create('logs', function (Blueprint $table) {
1520
$table->uuid('id')->primary();
1621

database/migrations/2024_01_01_00004_create_attachments_table.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\DB;
56
use Illuminate\Support\Facades\Schema;
67
use MailCarrier\Models\Log;
78

@@ -11,6 +12,10 @@
1112
*/
1213
public function up(): void
1314
{
15+
if (DB::table('migrations')->where('migration', '5_create_attachments_table')->exists()) {
16+
return;
17+
}
18+
1419
Schema::create('attachments', function (Blueprint $table) {
1520
$table->uuid('id')->primary();
1621

database/migrations/2024_01_01_00005_transform_logs_cc_bcc_array.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
*/
1111
public function up(): void
1212
{
13+
if (DB::table('migrations')->where('migration', '6_transform_logs_cc_bcc_array')->exists()) {
14+
return;
15+
}
16+
1317
$tableName = (new Log)->getTable();
1418

1519
DB::table($tableName)

database/migrations/2024_01_01_00006_add_tries_to_logs_table.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
*/
1313
public function up(): void
1414
{
15+
if (DB::table('migrations')->where('migration', '7_add_tries_to_logs_table')->exists()) {
16+
return;
17+
}
18+
1519
Schema::table('logs', function (Blueprint $table) {
1620
$table->unsignedSmallInteger('tries')->default(0);
1721
$table->timestamp('last_try_at')->nullable();

database/migrations/2024_01_01_00007_add_tags_metadata_to_logs_table.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\DB;
56
use Illuminate\Support\Facades\Schema;
67

78
return new class extends Migration {
@@ -10,6 +11,10 @@
1011
*/
1112
public function up(): void
1213
{
14+
if (DB::table('migrations')->where('migration', '8_add_tags_metadata_to_logs_table')->exists()) {
15+
return;
16+
}
17+
1318
Schema::table('logs', function (Blueprint $table) {
1419
$table->json('tags')->nullable();
1520
$table->json('metadata')->nullable();

database/migrations/2024_01_01_00008_add_tags_to_templates_table.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\DB;
56
use Illuminate\Support\Facades\Schema;
67

78
return new class extends Migration {
@@ -10,6 +11,10 @@
1011
*/
1112
public function up(): void
1213
{
14+
if (DB::table('migrations')->where('migration', '9_add_tags_to_templates_table')->exists()) {
15+
return;
16+
}
17+
1318
Schema::table('templates', function (Blueprint $table) {
1419
$table->json('tags')->nullable();
1520
});

0 commit comments

Comments
 (0)