From: Alexander Smirnov Date: Mon, 11 Mar 2024 13:24:35 +0000 (+0300) Subject: add pgsql config to db.php X-Git-Tag: 1.1~181^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=00fdbe3d3038ba1df63371cd35c443c713ce0105;p=erp24_rep%2Fyii-erp24%2F.git add pgsql config to db.php --- diff --git a/docker-compose.yml b/docker-compose.yml index c7e71345..ba28e91b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,7 +41,8 @@ services: extra_hosts: - "host.docker.internal:host-gateway" env_file: - - docker/php/dev.php.env + - docker/php/dev.php. + - docker/db/dev.db-pgsql.env environment: MODE: 'dev' volumes: diff --git a/docker/db/dev.db-pgsql.env b/docker/db/dev.db-pgsql.env index 02b040b3..f6c696d6 100644 --- a/docker/db/dev.db-pgsql.env +++ b/docker/db/dev.db-pgsql.env @@ -2,4 +2,7 @@ POSTGRES_USER=root POSTGRES_PASSWORD=root PGADMIN_DEFAULT_EMAIL=admin@admin.com PGADMIN_DEFAULT_PASSWORD=admin -POSTGRES_DB=erp24 \ No newline at end of file +POSTGRES_DB=erp24 +POSTGRES_HOSTNAME=db-pgsql-yii_erp24 +POSTGRES_PORT=5432 +POSTGRES_SCHEMA=erp24 \ No newline at end of file diff --git a/erp24/config/db.php b/erp24/config/db.php index a1e430bc..1dde7260 100644 --- a/erp24/config/db.php +++ b/erp24/config/db.php @@ -1,6 +1,24 @@ yii\db\Connection::class, + 'dsn' => strtr('pgsql:host={host};port={port};dbname={dbname}', [ + '{host}' => getenv('POSTGRES_HOSTNAME') ?: '127.0.0.1', + '{port}' => getenv('POSTGRES_PORT') ?: 3306, + '{dbname}' => getenv('POSTGRES_SCHEMA') ?: 'erp24', + ]), + 'username' => getenv('POSTGRES_USER') ?: 'bazacvetov24', + 'password' => getenv('POSTGRES_PASSWORD') ?: 'JVJruro_Xdg456o3ir', + 'schemaMap' => [ + 'pgsql' => [ + 'class' => 'yii\db\pgsql\Schema', + 'defaultSchema' => 'erp24' //specify your schema here, public is the default schema + ] + ], // PostgreSQL +// 'charset' => 'utf8', +// 'enableSchemaCache' => true, +// 'schemaCacheDuration' => 300, +]: [ 'class' => yii\db\Connection::class, 'dsn' => strtr('mysql:host={host};port={port};dbname={dbname}', [ '{host}' => getenv('DB_HOST') ?: '127.0.0.1', diff --git a/erp24/web/index.php b/erp24/web/index.php index c13ebe82..c3ac62ee 100644 --- a/erp24/web/index.php +++ b/erp24/web/index.php @@ -15,6 +15,6 @@ Yii::setAlias('@dist', dirname(__DIR__) . '/dist'); $app = (new yii\web\Application($config)); $app->params['API2_TOKEN'] = $app->db->createCommand( - 'SELECT access_token FROM api_user WHERE login="erp" LIMIT 1;')->queryAll()[0]['access_token'] ?? null; + 'SELECT access_token FROM api_user WHERE "login"=\'erp\' LIMIT 1;')->queryAll()[0]['access_token'] ?? null; $app->run();