Fix migration rollback

This commit is contained in:
Philipp Lang 2023-06-29 12:57:06 +02:00
parent 6fd16a7dfe
commit e37219b1ca
10 changed files with 34 additions and 13 deletions

View File

@ -44,6 +44,8 @@ class CreateActivitiesTable extends Migration
*/
public function down()
{
Schema::dropIfExists('activity_subactivity');
Schema::dropIfExists('subactivities');
Schema::dropIfExists('activities');
}
}

View File

@ -44,5 +44,6 @@ class CreatePaymentsTable extends Migration
public function down()
{
Schema::dropIfExists('payments');
Schema::dropIfExists('statuses');
}
}

View File

@ -37,6 +37,7 @@ class CreateCoursesTable extends Migration
*/
public function down()
{
Schema::dropIfExists('course_members');
Schema::dropIfExists('courses');
}
}

View File

@ -22,4 +22,9 @@ class CreateSettingsTable extends Migration
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('settings');
}
}

View File

@ -26,8 +26,8 @@ class CreateGroupsParentIdColumn extends Migration
public function down()
{
Schema::table('groups', function (Blueprint $table) {
$table->dropForeign(['group_id']);
$table->dropColumn('group_id');
$table->dropForeign(['parent_id']);
$table->dropColumn('parent_id');
});
}
}

View File

@ -32,6 +32,14 @@ return new class() extends Migration {
public function down()
{
Schema::table('members', function (Blueprint $table) {
$table->dropColumn('ps_at');
$table->dropColumn('more_ps_at');
$table->dropColumn('without_education_at');
$table->dropColumn('without_efz_at');
$table->dropColumn('has_svk');
$table->dropColumn('has_vk');
$table->dropColumn('multiply_pv');
$table->dropColumn('multiply_more_pv');
});
}
};

View File

@ -27,6 +27,9 @@ return new class() extends Migration {
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropUnique(['email']);
$table->dropColumn('email_verified_at');
$table->dropColumn('remember_token');
});
}
};

View File

@ -24,5 +24,8 @@ return new class() extends Migration {
*/
public function down()
{
Schema::table('members', function (Blueprint $table) {
$table->dropColumn('slug');
});
}
};

View File

@ -24,5 +24,8 @@ return new class() extends Migration {
*/
public function down()
{
Schema::table('memberships', function (Blueprint $table) {
$table->dropColumn('promised_at');
});
}
};

View File

@ -1,6 +1,5 @@
<?php
use App\Payment\SubscriptionChild;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -13,8 +12,6 @@ return new class() extends Migration {
*/
public function up()
{
$subscriptions = DB::table('subscriptions')->get();
Schema::table('subscriptions', function (Blueprint $table) {
$table->dropColumn('amount');
$table->boolean('split')->default(false);
@ -27,14 +24,6 @@ return new class() extends Migration {
$table->string('name');
$table->unsignedInteger('amount');
});
foreach ($subscriptions as $subscription) {
SubscriptionChild::create([
'parent_id' => $subscription->id,
'name' => 'name',
'amount' => $subscription->amount,
]);
}
}
/**
@ -44,5 +33,11 @@ return new class() extends Migration {
*/
public function down()
{
Schema::dropIfExists('subscription_children');
Schema::table('subscriptions', function (Blueprint $table) {
$table->unsignedInteger('amount');
$table->dropColumn('split');
$table->dropColumn('for_promise');
});
}
};