Page MenuHomePhorge

2020_03_30_100000_create_discounts.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

2020_03_30_100000_create_discounts.php

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
// phpcs:ignore
class CreateDiscounts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create(
'discounts',
function (Blueprint $table) {
$table->string('id', 36);
$table->tinyInteger('discount')->unsigned();
// was json, but mariadb
$table->text('description');
// end of
$table->string('code', 32)->nullable();
$table->boolean('active')->default(false);
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
$table->primary('id');
}
);
Schema::table(
'wallets',
function (Blueprint $table) {
$table->string('discount_id', 36)->nullable();
$table->foreign('discount_id')->references('id')
->on('discounts')->onDelete('set null');
}
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table(
'wallets',
function (Blueprint $table) {
$table->dropForeign(['discount_id']);
$table->dropColumn('discount_id');
}
);
Schema::dropIfExists('discounts');
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Sep 28, 8:49 PM (2 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1414609
Default Alt Text
2020_03_30_100000_create_discounts.php (1 KB)

Event Timeline