2022-10-02 18:38:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2023-11-15 09:55:31 +00:00
|
|
|
use Illuminate\Database\Query\Expression;
|
2022-10-02 18:38:41 +00:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
2023-11-16 11:28:04 +00:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2022-10-02 18:38:41 +00:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
|
|
|
return new class extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
2023-11-16 11:28:04 +00:00
|
|
|
$driver = DB::getDriverName();
|
|
|
|
|
|
|
|
Schema::create('templates', function (Blueprint $table) use ($driver) {
|
2022-10-02 18:38:41 +00:00
|
|
|
$table->id();
|
|
|
|
$table->timestamps();
|
|
|
|
$table->string('name');
|
|
|
|
$table->string('slug');
|
|
|
|
$table->text('description');
|
|
|
|
$table->string('image_url');
|
2023-11-16 11:28:04 +00:00
|
|
|
if ($driver === 'mysql') {
|
|
|
|
$table->jsonb('structure')->default(new Expression("(JSON_OBJECT())"));
|
|
|
|
} else {
|
|
|
|
$table->jsonb('structure')->default('{}');
|
|
|
|
}
|
2022-10-02 18:38:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::dropIfExists('templates');
|
|
|
|
}
|
|
|
|
};
|