2022-09-20 19:59:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2023-11-15 09:55:31 +00:00
|
|
|
use Illuminate\Database\Query\Expression;
|
2022-09-20 19:59:52 +00:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
2023-11-16 11:28:04 +00:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2022-09-20 19:59:52 +00:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
|
|
|
class CreateFormSubmissionsTable extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
2023-11-16 11:28:04 +00:00
|
|
|
$driver = DB::getDriverName();
|
|
|
|
|
|
|
|
Schema::create('form_submissions', function (Blueprint $table) use ($driver) {
|
2022-09-20 19:59:52 +00:00
|
|
|
$table->id();
|
|
|
|
$table->foreignIdFor(\App\Models\Forms\Form::class,'form_id');
|
2023-11-16 11:28:04 +00:00
|
|
|
if ($driver === 'mysql') {
|
|
|
|
$table->jsonb('data')->default(new Expression("(JSON_OBJECT())"));
|
|
|
|
} else {
|
|
|
|
$table->jsonb('data')->default("{}");
|
|
|
|
}
|
2022-09-20 19:59:52 +00:00
|
|
|
$table->timestamps();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::dropIfExists('form_submissions');
|
|
|
|
}
|
|
|
|
}
|