Skip to content

Commit

Permalink
fix duplicated migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
danilopolani committed Aug 27, 2024
1 parent f00ccd5 commit cb2a354
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions database/migrations/2024_01_01_00000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
Expand All @@ -10,6 +11,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '1_create_users_table')->exists()) {
return;
}

Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('oauth_id')->nullable();
Expand Down
5 changes: 5 additions & 0 deletions database/migrations/2024_01_01_00001_create_layouts_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
Expand All @@ -10,6 +11,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '2_create_layouts_table')->exists()) {
return;
}

Schema::create('layouts', function (Blueprint $table) {
$table->id();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
Expand All @@ -10,6 +11,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '3_create_templates_table')->exists()) {
return;
}

Schema::create('templates', function (Blueprint $table) {
$table->id();

Expand Down
5 changes: 5 additions & 0 deletions database/migrations/2024_01_01_00003_create_logs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use MailCarrier\Models\Template;

Expand All @@ -11,6 +12,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '4_create_logs_table')->exists()) {
return;
}

Schema::create('logs', function (Blueprint $table) {
$table->uuid('id')->primary();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use MailCarrier\Models\Log;

Expand All @@ -11,6 +12,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '5_create_attachments_table')->exists()) {
return;
}

Schema::create('attachments', function (Blueprint $table) {
$table->uuid('id')->primary();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '6_transform_logs_cc_bcc_array')->exists()) {
return;
}

$tableName = (new Log)->getTable();

DB::table($tableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '7_add_tries_to_logs_table')->exists()) {
return;
}

Schema::table('logs', function (Blueprint $table) {
$table->unsignedSmallInteger('tries')->default(0);
$table->timestamp('last_try_at')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
Expand All @@ -10,6 +11,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '8_add_tags_metadata_to_logs_table')->exists()) {
return;
}

Schema::table('logs', function (Blueprint $table) {
$table->json('tags')->nullable();
$table->json('metadata')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
Expand All @@ -10,6 +11,10 @@
*/
public function up(): void
{
if (DB::table('migrations')->where('migration', '9_add_tags_to_templates_table')->exists()) {
return;
}

Schema::table('templates', function (Blueprint $table) {
$table->json('tags')->nullable();
});
Expand Down

0 comments on commit cb2a354

Please sign in to comment.