Link tenant packages to events and show usage in billing
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('event_packages')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('event_packages', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('event_packages', 'tenant_package_id')) {
|
||||
$table->foreignId('tenant_package_id')
|
||||
->nullable()
|
||||
->after('package_id')
|
||||
->constrained('tenant_packages')
|
||||
->nullOnDelete();
|
||||
$table->index('tenant_package_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('event_packages')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('event_packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('event_packages', 'tenant_package_id')) {
|
||||
$table->dropForeign(['tenant_package_id']);
|
||||
$table->dropIndex(['tenant_package_id']);
|
||||
$table->dropColumn('tenant_package_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user