Answer the question
In order to leave comments, you need to log in
Why doesn't Yii2 use defaultSchema in PostgreSQL?
There are VPS: Debian 8.3 , NGINX 1.8 , FPM , PHP7 , PostgreSQL 9.4 , Yii2 .
There is a website and a copy on a subdomain: site.io , dev.site.io
There are 2 schemes in the database: public and developer . The main site works on the public
scheme , everything is super. I created a dev
subdomain and there was an urgent need
to delete all data from the database. I created a developer scheme
with a similar structure as on public
In the Yii config I wrote:
db => [
...
'schemaMap' => [
'pgsql'=> [
'class'=>'yii\db\pgsql\Schema',
'defaultSchema' => 'developer',
]
],
];
$table->fullName
in yii/db/pgsql/schema
outputs developer.tablename
, i.e. requests must go explicitly to the desired schemaAnswer the question
In order to leave comments, you need to log in
The base plans weren't made for that.
Make for dev exactly a separate user and a separate database.
in config
'db'=>[
'class' => 'yii\db\Connection',
.....
'schemaMap' => [
'pgsql' => [
'class' => 'yii\db\pgsql\Schema',
'defaultSchema' => 'myschema', //specify your schema here
]
],
'on afterOpen' => function ($event) {
$event->sender->createCommand("SET search_path TO myschema")->execute();
}
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question