osb/database/migrations/0210-create_charges.php

61 lines
1.7 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('charges', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->boolean('processed')->default(false);
$table->integer('sweep_type')->nullable();
$table->integer('type')->nullable();
$table->float('amount', 10, 0)->nullable();
$table->float('quantity', 10, 0)->nullable();
$table->boolean('taxable')->default(true);
$table->binary('attributes', 65535)->nullable();
$table->string('description', 128)->nullable();
$table->date('start_at')->nullable();
$table->date('stop_at')->nullable();
$table->date('charge_at')->nullable();
$table->integer('account_id')->unsigned();
$table->foreign(['account_id','site_id'])->references(['id','site_id'])->on('accounts');
$table->integer('product_id')->unsigned()->nullable();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->integer('service_id')->unsigned()->nullable();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->integer('user_id')->unsigned()->nullable();
$table->foreign(['user_id','site_id'])->references(['id','site_id'])->on('users');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('charges');
}
};