osb/database/migrations/0210-create_charges.php
Deon George 67824d4ab5
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s
Remove binary attributes from DB, should be json columns
2024-07-07 19:10:00 +10:00

61 lines
1.6 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->jsonb('attributes')->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');
}
};