Redo database migrations for pgsql
This commit is contained in:
47
database/migrations/0108-create_group.php
Normal file
47
database/migrations/0108-create_group.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user