我正在使用一个没有超级用户权限的角色在postgressql服务器上设置一个新的Laravel安装(test)。我正在使用Manjaro进行测试,我已经安装了php8,并在/etc/ php /php.ini中启用/安装了带有pgsql和pdo_pgsql扩展的php-pgsql
Laravel似乎确实检测到了表,但它不能运行迁移。以下是我正在使用的命令:
php artisan migrate:install (此方法有效)
php artisan migrate:状态(这个不起作用,它找不到迁移表)
这也是我的.env (相关的部分):
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=test
DB_USERNAME=test
DB_PASSWORD=这是我从laravel中的测试用户那里得到的:
test=> \l
postgres | postgres | UTF8 | es_CL.utf8 | es_CL.utf8 |
template0 | postgres | UTF8 | es_CL.utf8 | es_CL.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | es_CL.utf8 | es_CL.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
test | test | UTF8 | es_CL.utf8 | es_CL.utf8 | 发布于 2021-08-03 22:32:30
对于命令migrate:status,Laravel在命名空间Illuminate\Database\Schema\Grammars的内部类PostgresGrammar中调用此方法。
/**
* Compile the query to determine if a table exists.
*
* @return string
*/
public function compileTableExists()
{
return "select * from information_schema.tables where table_schema = ? and table_name = ? and table_type = 'BASE TABLE'";
}如果看到,请从information_schema中选择需要适当权限才能工作的记录。用户(在本例中为test )需要是模式的所有者(在本例中为test ),才能从information_schema.tables获取与您的模式相关的任何行。
运行以下命令以更改架构的所有者:
alter schema `test` owner to `test`;或者用户需要是拥有该架构的组的成员。
注意:使用授权是不够的。用户不需要是超级用户。用户可以在模式中拥有一个表,但这也是不够的。
参考:
https://stackoverflow.com/questions/68642671
复制相似问题