From 34b952c1de0ff1f28ae22912ec18cf098813145e Mon Sep 17 00:00:00 2001 From: Aboozar Ghaffari <502961+samuraee@users.noreply.github.com> Date: Sun, 3 Dec 2023 13:59:18 +0330 Subject: [PATCH] Fixed default value for json field in MySql in migration files --- .../create_larapay_transaction_table.php.stub | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/database/migrations/create_larapay_transaction_table.php.stub b/database/migrations/create_larapay_transaction_table.php.stub index 5fb7f20..3181328 100644 --- a/database/migrations/create_larapay_transaction_table.php.stub +++ b/database/migrations/create_larapay_transaction_table.php.stub @@ -39,9 +39,16 @@ class CreateLarapayTransactionTable extends Migration $table->text('description')->nullable(); $table->bigInteger('amount')->default(0); - $table->jsonb('extra_params')->nullable()->default('{}'); - $table->jsonb('additional_data')->nullable()->default('{}'); - $table->jsonb('sharing')->nullable()->default('{}'); + + if (env('DB_CONNECTION') == 'pgsql') { // for POSTGRESQL + $table->jsonb('extra_params')->nullable()->default('{}'); + $table->jsonb('additional_data')->nullable()->default('{}'); + $table->jsonb('sharing')->nullable()->default('{}'); + } else { // for MYSQL + $table->jsonb('extra_params')->nullable(); + $table->jsonb('additional_data')->nullable(); + $table->jsonb('sharing')->nullable(); + } $table->dateTime('paid_at')->nullable(); $table->timestamps();