Skip to content

Commit a48ba34

Browse files
committed
Check for indexes before dropping them
1 parent 22f0d6a commit a48ba34

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

database/migrations/increase_redirect_error_table_url_length.php.stub

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ class IncreaseRedirectErrorTableUrlLength extends Migration
99
{
1010
public function up(): void
1111
{
12-
Schema::table('errors', function (Blueprint $table): void {
13-
$table->dropIndex('errors_url_index');
14-
});
12+
if (Schema::hasIndex('errors', 'errors_url_index')) {
13+
Schema::table('errors', function (Blueprint $table): void {
14+
$table->dropIndex('errors_url_index');
15+
});
16+
}
1517

1618
Schema::table('errors', function (Blueprint $table): void {
1719
$table->string('url', 2048)->change();

database/migrations/increase_redirect_redirects_table_url_length.php.stub

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ class IncreaseRedirectRedirectsTableUrlLength extends Migration
99
{
1010
public function up(): void
1111
{
12-
Schema::table('redirects', function (Blueprint $table): void {
13-
$table->dropIndex('redirects_source_index');
14-
});
12+
if (Schema::hasIndex('redirects', 'redirects_source_index')) {
13+
Schema::table('redirects', function (Blueprint $table): void {
14+
$table->dropIndex('redirects_source_index');
15+
});
16+
}
1517

1618
Schema::table('redirects', function (Blueprint $table): void {
1719
$table->string('source', 2048)->change();

0 commit comments

Comments
 (0)