From 3be5e2292790f2c77276f48484d438e12d857ba5 Mon Sep 17 00:00:00 2001 From: Alexander Pankratov Date: Sat, 3 Oct 2020 02:50:56 +0300 Subject: [PATCH] Support all db providers from madeline --- .env.docker.example | 16 ++++++++-------- .env.example | 16 ++++++++-------- bootstrap.php | 3 +++ composer.json | 2 +- composer.lock | 12 ++++++------ config.php | 18 +++++++++--------- src/Migrations/EnvUpgrade.php | 16 ++++++++++++++++ 7 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 src/Migrations/EnvUpgrade.php diff --git a/.env.docker.example b/.env.docker.example index 37a4a1d..1c22de5 100644 --- a/.env.docker.example +++ b/.env.docker.example @@ -39,12 +39,12 @@ TELEGRAM_PROXY_PASSWORD= # Change this type to convert session: DB_TYPE=mysql # MYSQL Settings. Required, when DB_TYPE=mysql -MYSQL_HOST=mysql -MYSQL_PORT=3306 -MYSQL_USER=root -MYSQL_PASSWORD= -MYSQL_DATABASE=MadelineProto -MYSQL_MAX_CONNECTIONS=10 -MYSQL_IDLE_TIMEOUT=60 +DB_HOST=mysql +DB_PORT=3306 +DB_USER=root +DB_PASSWORD= +DB_DATABASE=MadelineProto +DB_MAX_CONNECTIONS=10 +DB_IDLE_TIMEOUT=60 # Recent data will be stored in memory this amount of time: -MYSQL_CACHE_TTL="+5 minutes" \ No newline at end of file +DB_CACHE_TTL="+5 minutes" \ No newline at end of file diff --git a/.env.example b/.env.example index b2d9ae3..1a1a1b2 100644 --- a/.env.example +++ b/.env.example @@ -39,12 +39,12 @@ TELEGRAM_PROXY_PASSWORD= # Change this type to convert session: DB_TYPE=memory # MYSQL Settings. Required, when DB_TYPE=mysql -MYSQL_HOST=127.0.0.1 -MYSQL_PORT=3306 -MYSQL_USER=root -MYSQL_PASSWORD= -MYSQL_DATABASE=MadelineProto -MYSQL_MAX_CONNECTIONS=10 -MYSQL_IDLE_TIMEOUT=60 +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_USER=root +DB_PASSWORD= +DB_DATABASE=MadelineProto +DB_MAX_CONNECTIONS=10 +DB_IDLE_TIMEOUT=60 # Recent data will be stored in memory this amount of time: -MYSQL_CACHE_TTL="+5 minutes" \ No newline at end of file +DB_CACHE_TTL="+5 minutes" \ No newline at end of file diff --git a/bootstrap.php b/bootstrap.php index 136b96b..ced925d 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,6 +1,7 @@ [ 'type' => getenv('DB_TYPE'), - 'mysql' => [ - 'host' => getenv('MYSQL_HOST'), - 'port' => (int) getenv('MYSQL_PORT'), - 'user' => getenv('MYSQL_USER'), - 'password' => getenv('MYSQL_PASSWORD'), - 'database' => getenv('MYSQL_DATABASE'), - 'max_connections' => (int) getenv('MYSQL_MAX_CONNECTIONS'), - 'idle_timeout' => (int) getenv('MYSQL_IDLE_TIMEOUT'), - 'cache_ttl' => getenv('MYSQL_CACHE_TTL'), + getenv('DB_TYPE') => [ + 'host' => getenv('DB_HOST'), + 'port' => (int) getenv('DB_PORT'), + 'user' => getenv('DB_USER'), + 'password' => getenv('DB_PASSWORD'), + 'database' => getenv('DB_DATABASE'), + 'max_connections' => (int) getenv('DB_MAX_CONNECTIONS'), + 'idle_timeout' => (int) getenv('DB_IDLE_TIMEOUT'), + 'cache_ttl' => getenv('DB_CACHE_TTL'), ] ], 'download'=>[ diff --git a/src/Migrations/EnvUpgrade.php b/src/Migrations/EnvUpgrade.php new file mode 100644 index 0000000..e4c6e76 --- /dev/null +++ b/src/Migrations/EnvUpgrade.php @@ -0,0 +1,16 @@ +