commit 12.01
This commit is contained in:
@@ -1,35 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up() {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('bookingnumber');
|
||||
$table->string('booking_number')->unique();
|
||||
$table->unsignedBigInteger('client_id');
|
||||
$table->unsignedBigInteger('employee_id');
|
||||
$table->unsignedBigInteger('employee_id');
|
||||
$table->unsignedBigInteger('service_id');
|
||||
$table->date('bookingdate');
|
||||
$table->time('starttime');
|
||||
$table->time('endtime');
|
||||
$table->date('booking_date');
|
||||
$table->time('start_time');
|
||||
$table->time('end_time');
|
||||
$table->enum('status', ['confirmed', 'cancelled', 'completed'])->default('confirmed');
|
||||
$table->enum('cancelledby', ['client', 'admin'])->nullable();
|
||||
$table->text('cancelreason')->nullable();
|
||||
$table->enum('cancelled_by', ['client', 'admin'])->nullable();
|
||||
$table->text('cancel_reason')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Внешние ключи
|
||||
|
||||
$table->foreign('client_id')->references('id')->on('users');
|
||||
$table->foreign('employee_id')->references('id')->on('users');
|
||||
$table->foreign('employee_id')->references('id')->on('users');
|
||||
$table->foreign('service_id')->references('id')->on('services');
|
||||
|
||||
// УНИКАЛЬНЫЙ ИНДЕКС
|
||||
$table->unique(['employee_id', 'bookingdate', 'starttime'], 'unique_booking_slot');
|
||||
|
||||
$table->unique(['employee_id', 'booking_date', 'start_time']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down() {
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bookings');
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user