laravel 如何为laravel设置默认的postgresql架构?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45242702/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:21:06  来源:igfitidea点击:

How to set default postgresql schema for laravel?

phppostgresqllaravellaravel-5.4

提问by Oto Shavadze

I created new postgresql user:

我创建了新的 postgresql 用户:

CREATE ROLE lara_user SUPERUSER LOGIN PASSWORD 'mypassword';

Then create schema which is owned by this user

然后创建该用户拥有的架构

CREATE schema lara AUTHORIZATION lara_user;

In Laravel's .envfile I have

在 Laravel 的.env文件中,我有

DB_DATABASE=postgres
DB_USERNAME=lara_user
DB_PASSWORD=mypassword

Laravel don't sees schema laraand still connected to publicschema.

Laravel 看不到架构lara并且仍然连接到public架构。

How can I change and set default schema larafor Laravel ?

如何更改和设置laraLaravel 的默认架构?

回答by Exprator

in app/config/database.php

app/config/database.php

'pgsql' => array(
            'driver'   => 'pgsql',
            'host'     => 'localhost',
            'database' => 'forge',
            'username' => 'forge',
            'password' => '',
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => 'public',
        ),