tpetry / laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features
MIT License
746 stars 32 forks source link

I got Call to undefined method createFunctionOrReplace ? #35

Closed sergeynilov closed 2 years ago

sergeynilov commented 2 years ago

I added laravel-postgresql-enhanced 0.19 into my laravel 9 app

I create new migration with definition from the sample with similar defintion :

<?php

use Illuminate\Database\Migrations\Migration;
//use Illuminate\Database\Schema\Blueprint;
//use Illuminate\Support\Facades\Schema;

use Illuminate\Database\Query\Builder;
use Tpetry\PostgresqlEnhanced\Schema\Blueprint;
use Tpetry\PostgresqlEnhanced\Schema\Concerns\ZeroDowntimeMigration;
use Tpetry\PostgresqlEnhanced\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //         Schema::createFunction('getTsCategories', ['sort_field' => 'string'], 'numeric', 'plpgsql', '
        Schema::createFunctionOrReplace('getTsCategories', ['sort_field' => 'string'], 'numeric', 'plpgsql', '
  BEGIN
    RETURN subtotal * 0.06;
  END;

');
    }

    public function down()
    {
        Schema::dropIfExists('ts_categories');
    }
};

But I got error :

  Call to undefined method Tpetry\PostgresqlEnhanced\Schema\Builder::createFunctionOrReplace()

  at vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:338
    334▕         if (! $instance) {
    335▕             throw new RuntimeException('A facade root has not been set.');
    336▕         }
    337▕ 
  ➜ 338▕         return $instance->$method(...$args);
    339▕     }
    340▕ }
    341▕ 

  1   database/migrations/2022_08_24_130039_create_ts_categories_crud_funcs.php:26
      Illuminate\Support\Facades\Facade::__callStatic()

      +37 vendor frames 
  39  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

It seems that I added all facades from the docs. If to uncomment line with createFunction, i got error Call to undefined method Tpetry\PostgresqlEnhanced\Schema\Builder::createFunction() What is wrong ?

Thanks

tpetry commented 2 years ago

You need to upgrade to version 0.20.0