<?php

declare(strict_types=1);

use Hypervel\Support\Str;

return [
    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for database operations. This is
    | the connection which will be utilized unless another connection
    | is explicitly specified when you execute a query / statement.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    'connections' => [
        'postgres' => [
            'driver' => 'pgsql',
            'host' => env('DB_PG_HOST', 'host.docker.internal'),
            'port' => env('DB_PG_PORT', default: 5555),
            'database' => env('DB_PG_DATABASE', 'bukid'),
            'username' => env('DB_PG_USERNAME', 'postgres'),
            'password' => env('DB_PG_PASSWORD', 'UMX0aCpOvcAeDA6fWPznWlAdKrtTUBjVWznCYDnYSJ6NsRV5WqT2CB9KWRkYRrF1'),
            'charset' => env('DB_PG_CHARSET', 'utf8'),
            'prefix' => env('DB_PG_PREFIX', ''),
            'schema' => env('DB_PG_SCHEMA', 'bukidbounty'),
            'sslmode' => env('DB_PG_SSLMODE', 'prefer'),
            'pool' => [
                'min_connections' => 1,
                'max_connections' => 25,
                'connect_timeout' => 10.0,
                'wait_timeout' => 3.0,
                'heartbeat' => -1,
                'max_idle_time' => 60.0,
            ],
        ],

        'mysql' => [
            'driver' => env('DB_DRIVER', 'mysql'),
            'host' => env('DB_HOST', 'og4wkgsokkscgswssoswk08s'),
            'database' => env('DB_DATABASE', 'bukid'),
            'port' => env('DB_PORT', 3306),
            'username' => env('DB_USERNAME', 'bukid'),
            'password' => env('DB_PASSWORD', 'aPAS62RYKwfg4Ddjifn2idIUDNoSQTUIjcFMMOK6CcNCp0devK9ODBiv3KpGwWu'), //TODO Change this password and Update Server coolify and also dbeaver
            'charset' => env('DB_CHARSET', 'utf8mb4'),
            'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
            'prefix' => env('DB_PREFIX', ''),
            'pool' => [
                'min_connections' => 1,
                'max_connections' => 20,
                'connect_timeout' => 10.0,
                'wait_timeout' => 3.0,
                'heartbeat' => -1,
                'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
            ],
        ],

        'mysql_testing' => [
            'driver' => env('DB_DRIVER', 'mysql'),
            'host' => env('DB_HOST','ywskgowos4w4484og4k0s0os'),
            'database' => env('DB_DATABASE', 'bukid'),
            'port' => env('DB_PORT', 3306),
            'username' => env('DB_USERNAME', 'bukid'),
            'password' => env('DB_PASSWORD', 'FhhEImM9dKc4O9U7dIu7d5Ga2DcxMHA2ZvUqrg8Y6Ga60Lq3C7ji9GiqJ464nszh'), //TODO Change this password and Update Server coolify and also dbeaver
            'charset' => env('DB_CHARSET', 'utf8mb4'),
            'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
            'prefix' => env('DB_PREFIX', ''),
            'pool' => [
                'min_connections' => 1,
                'max_connections' => 20,
                'connect_timeout' => 10.0,
                'wait_timeout' => 3.0,
                'heartbeat' => -1,
                'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
            ],
        ],


        'sqlite' => [
            'driver' => 'sqlite',
            'url' => env('DATABASE_URL'),
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ],

        'sqlite_testing' => [
            'driver' => 'sqlite',
            'database' => ':memory:',
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run on the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer body of commands than a typical key-value system
    | such as Memcached. You may define your connection settings here.
    |
    */

    'redis' => [
        'options' => [
            'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'BukidBountyApp'), '_') . '_database_'),
        ],

        'default' => [
            'host' => env('REDIS_HOST', 'host.docker.internal'),
            'auth' => (env('REDIS_AUTH') ?: env('REDIS_PASSWORD')) ?: null,
            'port' => (int) env('REDIS_PORT', 5433),
            'db' => (int) env('REDIS_DB', 0),
            'pool' => [
                'min_connections' => 1,
                'max_connections' => 10,
                'connect_timeout' => 10.0,
                'wait_timeout' => 3.0,
                'heartbeat' => -1,
                'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60),
            ],
        ],

        'queue' => [
            'host' => env('REDIS_HOST', 'host.docker.internal'),
            'auth' => (env('REDIS_AUTH') ?: env('REDIS_PASSWORD')) ?: null,
            'port' => (int) env('REDIS_PORT', 5433),
            'db' => (int) env('REDIS_DB', 0),
            'pool' => [
                'min_connections' => 1,
                'max_connections' => 10,
                'connect_timeout' => 10.0,
                'wait_timeout' => 3.0,
                'heartbeat' => -1,
                'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60),
            ],
        ],
    ],
];
