osb/database/migrations/0210-create_charges.php

61 lines
1.6 KiB
PHP
Raw Normal View History

2024-06-21 07:43:32 +00:00
<?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();
2024-07-25 04:08:26 +00:00
$table->integer('type');
$table->float('amount', 10, 0);
$table->float('quantity', 10, 0);
2024-06-21 07:43:32 +00:00
$table->boolean('taxable')->default(true);
$table->jsonb('attributes')->nullable();
2024-06-21 07:43:32 +00:00
$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');
}
};