Skip to content

Commit

Permalink
chore: remove down migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Dec 11, 2024
1 parent 58e550b commit 28d90d8
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 148 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

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

class CreateUsersTable extends Migration
{
Expand Down Expand Up @@ -31,6 +31,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('users');
// Only up migrations are allowed
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

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

class CreatePasswordResetsTable extends Migration
{
Expand All @@ -27,6 +27,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('password_resets');
// Only up migrations are allowed
}
}
6 changes: 3 additions & 3 deletions src/database/migrations/2019_06_28_204410_posts.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

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

class Posts extends Migration
{
Expand Down Expand Up @@ -34,6 +34,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('posts');
// Only up migrations are allowed
}
}
6 changes: 3 additions & 3 deletions src/database/migrations/2019_06_28_211028_comments.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

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

class Comments extends Migration
{
Expand Down Expand Up @@ -30,6 +30,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('comments');
// Only up migrations are allowed
}
}
10 changes: 3 additions & 7 deletions src/database/migrations/2019_08_10_033153_photos.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

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

class Photos extends Migration
{
Expand Down Expand Up @@ -34,10 +34,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('photos');

Schema::table('posts', function (Blueprint $table) {
$table->dropColumn('banner_image_url');
});
// Only up migrations are allowed
}
}
13 changes: 3 additions & 10 deletions src/database/migrations/2019_08_12_024829_admin_and_settings.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

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

class AdminAndSettings extends Migration
{
Expand Down Expand Up @@ -44,13 +44,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('settings');
Schema::dropIfExists('categories');

Schema::table('users', function (Blueprint $table) {
$table->dropColumn('bio');
$table->dropColumn('profile_pic_id');
$table->dropColumn('role');
});
// Only up migrations are allowed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public function up()
*/
public function down()
{
User::truncate();
Setting::truncate();
Category::truncate();
// Only up migrations are allowed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ public function up()
*/
public function down()
{
// Split so SQLite via test suite can work since it doesn't support multiple actions at once when renaming
Schema::table('posts', function (Blueprint $table) {
$table->renameColumn('category_id', 'category');
});

Schema::table('posts', function (Blueprint $table) {
$table->dropColumn('published');
});

Schema::table('users', function (Blueprint $table) {
$table->dropSoftDeletes();
});
// Only up migrations are allowed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public function up()
*/
public function down()
{
Schema::table('categories', function (Blueprint $table) {
$table->string('category')->change();
});
// Only up migrations are allowed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('sessions');
// Only up migrations are allowed
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public function up()
*/
public function down()
{
Schema::table('posts', function (Blueprint $table) {
$table->string('reading_time')->nullable();
});
// Only up migrations are allowed
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public function up()
*/
public function down()
{
Schema::table('categories', function (Blueprint $table) {
$table->integer('user_id');
});
// Only up migrations are allowed
}
};
18 changes: 1 addition & 17 deletions src/database/migrations/2023_09_20_040645_add_indexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ public function up(): void
*/
public function down(): void
{
Schema::table('categories', function (Blueprint $table) {
$table->dropUnique(['category']);
$table->string('category')->nullable(true)->change();
});

Schema::table('comments', function (Blueprint $table) {
$table->dropIndex('comments_post_id_index');
});

Schema::table('posts', function (Blueprint $table) {
$table->dropIndex('posts_category_id_index');
$table->dropIndex('posts_user_id_index');
});

Schema::table('users', function (Blueprint $table) {
$table->dropIndex('users_name_index');
});
// Only up migrations are allowed
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public function up(): void
*/
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->string('category_id')->nullable()->change();
$table->text('keywords')->nullable()->change();
$table->longText('post')->change();
});
// Only up migrations are allowed
}
};
28 changes: 1 addition & 27 deletions src/database/migrations/2023_09_20_214931_add_foreign_keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@ public function up(): void
*/
public function down(): void
{
Schema::table('comments', function (Blueprint $table) {
$table->dropForeign('comments_user_id_foreign');
$table->dropForeign('comments_post_id_foreign');

$table->dropIndex('comments_user_id_foreign');
$table->renameIndex('comments_post_id_foreign', 'comments_post_id_index');
});

// Changes must be done separately from dropping indexes
Schema::table('comments', function (Blueprint $table) {
$table->integer('user_id')->change();
$table->integer('post_id')->change();
});

Schema::table('posts', function (Blueprint $table) {
$table->dropForeign('posts_user_id_foreign');
$table->dropForeign('posts_category_id_foreign');

$table->renameIndex('posts_category_id_foreign', 'posts_category_id_index');
$table->renameIndex('posts_user_id_foreign', 'posts_user_id_index');
});

// Changes must be done separately from dropping indexes
Schema::table('posts', function (Blueprint $table) {
$table->integer('user_id')->change();
$table->integer('category_id')->nullable()->change();
});
// Only up migrations are allowed
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,6 @@ public function up(): void
*/
public function down(): void
{
Schema::rename('images', 'photos');

Schema::table('photos', function (Blueprint $table) {
$table->integer('subdirectory')->change();
$table->integer('filename')->change();
$table->string('url');
});

// Split so SQLite via test suite can work since it doesn't support renaming multiple columns at once
Schema::table('photos', function (Blueprint $table) {
$table->renameColumn('subdirectory', 'user_id');
});

// Split so SQLite via test suite can work since it doesn't support renaming multiple columns at once
Schema::table('photos', function (Blueprint $table) {
$table->renameColumn('filename', 'post_id');
});

Schema::table('users', function (Blueprint $table) {
$table->dropForeign('users_image_id_foreign');
$table->dropIndex('users_image_id_foreign');
});

Schema::table('users', function (Blueprint $table) {
$table->integer('image_id')->nullable()->change();
});

// Split so SQLite via test suite can work since it doesn't support renaming multiple columns at once
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('image_id', 'profile_pic_id');
});

// Split so SQLite via test suite can work since it doesn't support renaming multiple columns at once
Schema::table('posts', function (Blueprint $table) {
$table->renameColumn('image_id', 'banner_image_url');
});

Schema::table('posts', function (Blueprint $table) {
$table->dropForeign('posts_image_id_foreign');
$table->dropIndex('posts_image_id_foreign');
});

Schema::table('posts', function (Blueprint $table) {
$table->string('banner_image_url')->change();
});
// Only up migrations are allowed
}
};

0 comments on commit 28d90d8

Please sign in to comment.