RethinkDB- 无法在 Laravel 5.5 中迁移
RethinkDB- unable to migrate in Laravel 5.5
我正在尝试创建一个 RethinkDB + Laravel 的演示 git repo,但我在迁移迁移过程中遇到了困难。当我尝试使用 php artisan migrate
进行迁移时,出现此错误
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: Argument 1 passed to Users::{closure}() must be an instance of duxet\Rethinkdb\Schema\Blueprint, instance of Illuminate\Database\Sc
hema\Blueprint given, called in /opt/lampp/htdocs/xyzz-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php on line 164
我在回购协议中调查了这个问题,但它列在错误中并且没有得到妥善解决。有没有人遇到过这个问题并且知道如何修复这个错误?
这是我所做的迁移。
<?php
use Illuminate\Support\Facades\Schema;
use duxet\Rethinkdb\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Users extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users',function (Blueprint $table){
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
提前致谢:)
通过此命令修复此问题
php artisan migrate --database=rethinkdb
因为我的 database.php
文件中有 DB_CONNECTION='rethinkdb
当你通过这个错误时你也会发现其他问题,为此我已经 fork this repo 并请求了一个 pull request .到那时你可以自己修复它。
repo
的第 1 期 和 Issue#39
为此,您需要在迁移时指定数据库名称,如果您有多个数据库,默认情况下它将像这样 Illuminate\Database\Schema\Blueprint
php artisan migrate --database=rethinkdb
然后你会在Blueprint.php
中得到另一个错误
[ErrorException]
Declaration of duxet\RethinkDB\Schema\Blueprint::index($column,
$options = NULL) should be compatible with
Illuminate\Database\Schema\Blueprint::index($columns, $name =
NULL, $algorithm = NULL)
您可以通过替换
在 Blueprint.php
中进行编辑来解决此问题
public function index($column, $options = null)
来自
public function index($columns, $name = NULL, $algorithm = NULL)
问题 #2 和 Issue#41 声明为
[Symfony\Component\Debug\Exception\FatalErrorException]
Access level to duxet\Rethinkdb\Query\Builder::$operators must be
public (as in class Illuminate\Database\Query\Builder)
要解决此问题,您必须在 Builder.php
中进行编辑
将 $operator
访问类型从 protected
更改为 public
public $operators = [
'=', '<', '>', '<=', '>=', '<>', '!=',
'like', 'not like', 'between', 'ilike',
'&', '|', '^', '<<', '>>',
'rlike', 'regexp', 'not regexp',
'~', '~*', '!~', '!~*',
'contains', 'exists', 'type', 'mod', 'size',
];
第 3 期
之后你会发现另一个 issue 也有 repo as Issue#42
为此,您必须编辑 Builder.php
并替换
public function groupBy()
来自
public function groupBy(...$groups)
第 4 期
现在,在解决所有这些问题后,您将遇到我今天在解决所有这些问题时发现的另一个问题。
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function supportsSchemaTransactions() on null
要解决此问题,您需要按照以下步骤操作。
1. 在 src/Schema
命名空间中创建文件 Grammar.php
并粘贴此代码。
<?php
namespace duxet\RethinkDB\Schema;
use Illuminate\Database\Schema\Grammars\Grammar as BaseGrammar;
/**
* Class Grammar
*
* @package Moloquent\Schema
*/
class Grammar extends BaseGrammar {
}
- 现在需要修改
Connection.php
首先,添加这个
use duxet\Rethinkdb\Schema\Grammar;
然后在public function __construct(array $config)
里面添加这个
$this->schemaGrammar = new Grammar();
以上所有内容我都已在 forked version 中修复并提出了拉取请求。希望这会对你有所帮助,你不需要像我一样挠头:)
更新
11月13日,pull request被接受,现在不需要再做下面的步骤了,如果有什么问题可以继续尝试。
我正在尝试创建一个 RethinkDB + Laravel 的演示 git repo,但我在迁移迁移过程中遇到了困难。当我尝试使用 php artisan migrate
进行迁移时,出现此错误
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: Argument 1 passed to Users::{closure}() must be an instance of duxet\Rethinkdb\Schema\Blueprint, instance of Illuminate\Database\Sc
hema\Blueprint given, called in /opt/lampp/htdocs/xyzz-laravel/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php on line 164
我在回购协议中调查了这个问题,但它列在错误中并且没有得到妥善解决。有没有人遇到过这个问题并且知道如何修复这个错误?
这是我所做的迁移。
<?php
use Illuminate\Support\Facades\Schema;
use duxet\Rethinkdb\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Users extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users',function (Blueprint $table){
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
提前致谢:)
通过此命令修复此问题
php artisan migrate --database=rethinkdb
因为我的 database.php
文件中有 DB_CONNECTION='rethinkdb
当你通过这个错误时你也会发现其他问题,为此我已经 fork this repo 并请求了一个 pull request .到那时你可以自己修复它。
repo
的第 1 期 和 Issue#39为此,您需要在迁移时指定数据库名称,如果您有多个数据库,默认情况下它将像这样 Illuminate\Database\Schema\Blueprint
php artisan migrate --database=rethinkdb
然后你会在Blueprint.php
中得到另一个错误
[ErrorException]
Declaration of duxet\RethinkDB\Schema\Blueprint::index($column, $options = NULL) should be compatible with Illuminate\Database\Schema\Blueprint::index($columns, $name = NULL, $algorithm = NULL)
您可以通过替换
在Blueprint.php
中进行编辑来解决此问题
public function index($column, $options = null)
来自
public function index($columns, $name = NULL, $algorithm = NULL)
问题 #2 和 Issue#41 声明为
[Symfony\Component\Debug\Exception\FatalErrorException]
Access level to duxet\Rethinkdb\Query\Builder::$operators must be public (as in class Illuminate\Database\Query\Builder)
要解决此问题,您必须在 Builder.php
将 $operator
访问类型从 protected
public
public $operators = [
'=', '<', '>', '<=', '>=', '<>', '!=',
'like', 'not like', 'between', 'ilike',
'&', '|', '^', '<<', '>>',
'rlike', 'regexp', 'not regexp',
'~', '~*', '!~', '!~*',
'contains', 'exists', 'type', 'mod', 'size',
];
第 3 期
之后你会发现另一个 issue 也有 repo as Issue#42
为此,您必须编辑 Builder.php
并替换
public function groupBy()
来自
public function groupBy(...$groups)
第 4 期
现在,在解决所有这些问题后,您将遇到我今天在解决所有这些问题时发现的另一个问题。
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function supportsSchemaTransactions() on null
要解决此问题,您需要按照以下步骤操作。
1. 在 src/Schema
命名空间中创建文件 Grammar.php
并粘贴此代码。
<?php
namespace duxet\RethinkDB\Schema;
use Illuminate\Database\Schema\Grammars\Grammar as BaseGrammar;
/**
* Class Grammar
*
* @package Moloquent\Schema
*/
class Grammar extends BaseGrammar {
}
- 现在需要修改
Connection.php
首先,添加这个
use duxet\Rethinkdb\Schema\Grammar;
然后在public function __construct(array $config)
里面添加这个
$this->schemaGrammar = new Grammar();
以上所有内容我都已在 forked version 中修复并提出了拉取请求。希望这会对你有所帮助,你不需要像我一样挠头:)
更新
11月13日,pull request被接受,现在不需要再做下面的步骤了,如果有什么问题可以继续尝试。