47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
||
|
return new class extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::create('groups', function(Blueprint $table)
|
||
|
{
|
||
|
$table->id();
|
||
|
$table->timestamps();
|
||
|
$table->integer('site_id')->unsigned();
|
||
|
$table->boolean('active')->default(false);
|
||
|
|
||
|
$table->dateTime('start_at')->nullable();
|
||
|
$table->dateTime('expire_at')->nullable();
|
||
|
|
||
|
$table->string('name',128)->unique();
|
||
|
$table->boolean('pricing')->default(false);
|
||
|
$table->text('notes')->nullable();
|
||
|
|
||
|
$table->foreign(['site_id'])->references(['id'])->on('sites');
|
||
|
|
||
|
$table->unique(['id','site_id']);
|
||
|
$table->integer('parent_id')->nullable();
|
||
|
$table->foreign(['parent_id','site_id'])->references(['id','site_id'])->on('groups');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
Schema::drop('groups');
|
||
|
}
|
||
|
};
|