Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel更改列不工作_Php_Postgresql_Laravel_Migration - Fatal编程技术网

Php Laravel更改列不工作

Php Laravel更改列不工作,php,postgresql,laravel,migration,Php,Postgresql,Laravel,Migration,拉威尔:5.4 数据库驱动程序:Postgres 我有多个Laravel模式,我想在这些模式上迁移一些迁移。我的迁移之一如下所示: <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class EditColumnPaymentMethodLengthOnRecurring

拉威尔:5.4

数据库驱动程序:Postgres

我有多个Laravel模式,我想在这些模式上迁移一些迁移。我的迁移之一如下所示:

<?php

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

class EditColumnPaymentMethodLengthOnRecurringPaymentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('recurring_payments', function (Blueprint $table) {
            $table->string('payment_method', 150)->nullable()->change();
            $table->text('test')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('recurring_payments', function (Blueprint $table) {
            $table->string('payment_method', 18)->nullable()->change();
            $table->dropColumn('test');
        });
    }
}

使用--假装并检查生成的SQL查询以更新列。@jedrzej.kurylo如果我运行--假装我得到一个异常:
[doctor\DBAL\Schema\SchemaException]表“recurtive\u payments”上没有名为“payment\u method”的列那么您想如何更改一个不存在的列?@jedrzej.kurylo您不认为如果这么简单,我会检查它吗。桌子是否在那里不是问题。这可能是由于条令没有找到正确的模式配置,因此使用公共模式配置的问题。在公共模式中,表不存在,但我不想使用公共模式。我做错了什么?我也有类似的问题。试图从文本改为长文本,它说一切都迁移得很好,但当我检查MySql工作台中的元素时,它说“文本”
<?php

namespace App\Console\Commands;

use App\Account;
use App\Support\Schema;
use Illuminate\Console\Command;

class MigrateTenantsCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'tenant:migrate {--force : Force the operation to run when in production.}
                {--pretend : Dump the SQL queries that would be run.}
                {--seed : Indicates if the seed task should be re-run.}
                {--step : Force the migrations to be run so they can be rolled back individually.}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Migrate all tenants';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $tenants = Account::all();
        foreach($tenants as $tenant)
        {
            $schema = new Schema;

            // Migrate into the new schema
            $schema->migrate(
                $tenant->schema,
                $this->getOptionsFromArgs()
            );
        }
    }

    private function getOptionsFromArgs()
    {
        $options = [
            '--path' => 'database/migrations/tenants/schema'
        ];

        if($this->option('force'))
        {
            $options['--force'] = true;
        }
        if($this->option('pretend'))
        {
            $options['--pretend'] = true;
        }
        if($this->option('seed'))
        {
            $options['--seed'] = true;
        }
        if($this->option('step'))
        {
            $options['--step'] = true;
        }
        return $options;
    }
}
public function __construct(
        array $tables = array(),
        array $sequences = array(),
        SchemaConfig $schemaConfig = null,
        array $namespaces = array()
    ) {
        if ($schemaConfig == null) {
            $schemaConfig = new SchemaConfig();
        }
        $this->_schemaConfig = $schemaConfig;

        $this->_setName($schemaConfig->getName() ?: 'public');

        foreach ($namespaces as $namespace) {
            $this->createNamespace($namespace);
        }

        foreach ($tables as $table) {
            $this->_addTable($table);
        }

        foreach ($sequences as $sequence) {
            $this->_addSequence($sequence);
        }
    }