fix: migrations not passing on pgsql (#242)
* fix: migration not passing on pgsql * pin postgres version
This commit is contained in:
parent
c51d7397fa
commit
0960af0373
|
@ -12,7 +12,7 @@ jobs:
|
|||
services:
|
||||
postgres:
|
||||
# Docker Hub image
|
||||
image: postgres
|
||||
image: postgres:14
|
||||
# Provide the password for postgres
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFormsTable extends Migration
|
||||
|
@ -14,7 +15,9 @@ class CreateFormsTable extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('forms', function (Blueprint $table) {
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::create('forms', function (Blueprint $table) use ($driver) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Workspace::class,'workspace_id');
|
||||
$table->string('title');
|
||||
|
@ -52,7 +55,11 @@ class CreateFormsTable extends Migration
|
|||
$table->boolean('can_be_indexed')->default(true);
|
||||
$table->string('password')->nullable()->default(null);
|
||||
$table->string('notification_sender')->default("OpenForm");
|
||||
$table->jsonb('tags')->default(new Expression('(JSON_ARRAY())'));
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('tags')->default(new Expression('(JSON_ARRAY())'));
|
||||
} else {
|
||||
$table->jsonb('tags')->default('[]');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFormSubmissionsTable extends Migration
|
||||
|
@ -14,10 +15,16 @@ class CreateFormSubmissionsTable extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('form_submissions', function (Blueprint $table) {
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::create('form_submissions', function (Blueprint $table) use ($driver) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Forms\Form::class,'form_id');
|
||||
$table->jsonb('data')->default(new Expression("(JSON_OBJECT())"));
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('data')->default(new Expression("(JSON_OBJECT())"));
|
||||
} else {
|
||||
$table->jsonb('data')->default("{}");
|
||||
}
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
@ -14,10 +15,16 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('form_statistics', function (Blueprint $table) {
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::create('form_statistics', function (Blueprint $table) use ($driver) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(\App\Models\Forms\Form::class,'form_id');
|
||||
$table->jsonb('data')->default(new Expression("(JSON_OBJECT())"));
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('data')->default(new Expression("(JSON_OBJECT())"));
|
||||
} else {
|
||||
$table->jsonb('data')->default("{}");
|
||||
}
|
||||
$table->date('date');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
@ -14,8 +15,14 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->jsonb('removed_properties')->default(new Expression("(JSON_ARRAY())"));
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::table('forms', function (Blueprint $table) use ($driver) {
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('removed_properties')->default(new Expression("(JSON_ARRAY())"));
|
||||
} else {
|
||||
$table->jsonb('removed_properties')->default("[]");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
@ -14,14 +15,20 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('templates', function (Blueprint $table) {
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::create('templates', function (Blueprint $table) use ($driver) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string('name');
|
||||
$table->string('slug');
|
||||
$table->text('description');
|
||||
$table->string('image_url');
|
||||
$table->jsonb('structure')->default(new Expression("(JSON_OBJECT())"));
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('structure')->default(new Expression("(JSON_OBJECT())"));
|
||||
} else {
|
||||
$table->jsonb('structure')->default('{}');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
@ -14,8 +15,14 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
$table->jsonb('questions')->default(new Expression("(JSON_ARRAY())"));
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::table('templates', function (Blueprint $table) use ($driver) {
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('questions')->default(new Expression("(JSON_ARRAY())"));
|
||||
} else {
|
||||
$table->jsonb('questions')->default('[]');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
@ -14,8 +15,14 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->json('seo_meta')->default(new Expression("(JSON_OBJECT())"));
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::table('forms', function (Blueprint $table) use ($driver) {
|
||||
if ($driver === 'mysql') {
|
||||
$table->json('seo_meta')->default(new Expression("(JSON_OBJECT())"));
|
||||
} else {
|
||||
$table->json('seo_meta')->default("{}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
@ -14,8 +15,14 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->json('notification_settings')->default(new Expression("(JSON_OBJECT())"))->nullable(true);
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::table('forms', function (Blueprint $table) use ($driver) {
|
||||
if ($driver === 'mysql') {
|
||||
$table->json('notification_settings')->default(new Expression("(JSON_OBJECT())"))->nullable(true);
|
||||
} else {
|
||||
$table->json('notification_settings')->default('{}')->nullable(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Query\Expression;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
|
@ -14,12 +15,31 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('templates', function (Blueprint $table) {
|
||||
$driver = DB::getDriverName();
|
||||
|
||||
Schema::table('templates', function (Blueprint $table) use ($driver) {
|
||||
$table->boolean('publicly_listed')->default(false);
|
||||
$table->jsonb('industries')->default(new Expression("(JSON_ARRAY())"));
|
||||
$table->jsonb('types')->default(new Expression("(JSON_ARRAY())"));
|
||||
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('industries')->default(new Expression("(JSON_ARRAY())"));
|
||||
} else {
|
||||
$table->jsonb('industries')->default('[]');
|
||||
}
|
||||
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('types')->default(new Expression("(JSON_ARRAY())"));
|
||||
} else {
|
||||
$table->jsonb('types')->default('[]');
|
||||
}
|
||||
|
||||
$table->string('short_description')->nullable();
|
||||
$table->jsonb('related_templates')->default(new Expression("(JSON_ARRAY())"));
|
||||
|
||||
if ($driver === 'mysql') {
|
||||
$table->jsonb('related_templates')->default(new Expression("(JSON_ARRAY())"));
|
||||
} else {
|
||||
$table->jsonb('related_templates')->default('[]');
|
||||
}
|
||||
|
||||
$table->string('image_url',500)->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue