freescout-customers-groups/Database/Migrations/2024_07_16_115310_create_customers_groups_table.php

42 lines
1 KiB
PHP

<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCustomersGroupsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::create('customers_groups', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
// Include a "mailbox_id" column in the customers groups table, linking each group entry to a specific mailbox.
$table
->integer('mailbox_id')
->unsigned();
$table
->foreign('mailbox_id')
->references('id')
->on('mailboxes')
// On mailbox deletion, delete all customers group entries that are linked to it.
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::dropIfExists('customers_groups');
}
}