Skip to content

Commit

Permalink
wrap the creates with hasTable to make sure they don't exist before…
Browse files Browse the repository at this point in the history
… trying to create them, otherwise it will error if tables are created outside migrations with no way of avoiding previously
  • Loading branch information
chrispelzer committed Nov 2, 2022
1 parent caf46cb commit 7550295
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions database/migrations/create_ckeditor_attachment_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@
*/
public function up()
{
Schema::create('nova_pending_ckeditor_attachments', function (Blueprint $table) {
$table->increments('id');
$table->string('draft_id')->index();
$table->string('attachment');
$table->string('disk');
$table->timestamps();
});
if(!Schema::hasTable('nova_pending_ckeditor_attachments')) {
Schema::create('nova_pending_ckeditor_attachments', function (Blueprint $table) {
$table->increments('id');
$table->string('draft_id')->index();
$table->string('attachment');
$table->string('disk');
$table->timestamps();
});
}

Schema::create('nova_ckeditor_attachments', function (Blueprint $table) {
$table->increments('id');
$table->string('attachable_type');
$table->unsignedInteger('attachable_id');
$table->string('attachment');
$table->string('disk');
$table->string('url')->index();
$table->timestamps();
if(!Schema::hasTable('nova_ckeditor_attachments')) {
Schema::create('nova_ckeditor_attachments', function (Blueprint $table) {
$table->increments('id');
$table->string('attachable_type');
$table->unsignedInteger('attachable_id');
$table->string('attachment');
$table->string('disk');
$table->string('url')->index();
$table->timestamps();

$table->index(['attachable_type', 'attachable_id']);
});
$table->index(['attachable_type', 'attachable_id']);
});
}
}

/**
Expand Down

0 comments on commit 7550295

Please sign in to comment.