['type' => 'uTinyint', 'title' => '分类', 'remark' => "1 关系数据库 2 非关系数据库"], 'type' => ['type' => 'string_20', 'title' => '数据库类型'], // sqlite mysql pgsql sqlsrv tidb file redis elasticsearch mongodb 'title' => ['type' => 'string', 'title' => '标题'], 'config_json' => ['type' => 'json', 'title' => '数据库配置json'], 'is_default' => ['type' => 'tinyint', 'title' => '是否是默认数据库 0是 1不是'], 'is_system' => ['type' => 'tinyint', 'default' => 0, 'title' => '是否是系统默认 0是 1不是'], ]; } public function init() { DB::table($this->schema)->insert([ [ 'mid' => Str::random(12), 'category_type' => 1, 'type' => 'pgsql', 'title' => 'pgsql', 'config_json' => json_encode([ 'driver' => 'pgsql', 'url' => '', 'host' => ['env' => 'DB_HOST', 'default' => '127.0.0.1'], 'port' => ['DB_PORT', '5432'], 'database' => ['DB_DATABASE', 'forge'], 'username' => ['DB_USERNAME', 'forge'], 'password' => ['DB_PASSWORD', ''], 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, 'schema' => 'public', 'sslmode' => 'prefer', ]), 'is_default' => 0, 'is_system' => 0, 'created_at' => time(), 'updated_at' => time() ], [ 'mid' => Str::random(12), 'category_type' => 1, 'type' => 'mysql', 'title' => 'mysql', 'config_json' => json_encode([ 'driver' => 'mysql', 'url' => ['DATABASE_URL'], 'host' => ['env' => 'DB_HOST', 'default' => '127.0.0.1'], 'port' => ['DB_PORT', '3306'], 'database' => ['DB_DATABASE', 'forge'], 'username' => ['DB_USERNAME', 'forge'], 'password' => ['DB_PASSWORD', ''], 'unix_socket' => ['DB_SOCKET', ''], 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => [ \PDO::ATTR_STRINGIFY_FETCHES => false, \PDO::ATTR_EMULATE_PREPARES => false ], ]), 'is_default' => 1, 'is_system' => 0, 'created_at' => time(), 'updated_at' => time() ], [ 'mid' => Str::random(12), 'category_type' => 1, 'type' => 'sqlite', 'title' => 'sqlite', 'config_json' => json_encode([ 'driver' => 'sqlite', 'url' => ['DATABASE_URL'], 'database' => ['DB_DATABASE', database_path('database.sqlite')], 'prefix' => '', 'foreign_key_constraints' => ['DB_FOREIGN_KEYS', true], ]), 'is_default' => 1, 'is_system' => 0, 'created_at' => time(), 'updated_at' => time() ], [ 'mid' => Str::random(12), 'category_type' => 1, 'type' => 'sqlsrv', 'title' => 'sqlsrv', 'config_json' => json_encode([ 'driver' => 'sqlsrv', 'url' => ['DATABASE_URL'], 'host' => ['DB_HOST', 'localhost'], 'port' => ['DB_PORT', '1433'], 'database' => ['DB_DATABASE', 'forge'], 'username' => ['DB_USERNAME', 'forge'], 'password' => ['DB_PASSWORD', ''], 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, ]), 'is_default' => 1, 'is_system' => 0, 'created_at' => time(), 'updated_at' => time() ], [ 'mid' => Str::random(12), 'category_type' => 2, 'type' => 'redis', 'title' => 'redis', 'config_json' => json_encode([ 'host' => ['REDIS_HOST', '127.0.0.1'], 'password' => ['REDIS_PASSWORD'], 'port' => ['REDIS_PORT', 6379], 'database' => ['REDIS_DB', 0], ]), 'is_default' => 1, 'is_system' => 0, 'created_at' => time(), 'updated_at' => time() ], [ 'mid' => Str::random(12), 'category_type' => 2, 'type' => 'elasticsearch', 'title' => 'elasticsearch', 'config_json' => json_encode([ 'driver' => 'default', 'prefix' => ['ELASTICSEARCH_PREFIX', 'txj'], 'host' => [ ['ELASTICSEARCH_HOST', '127.0.0.1:9200'], ], 'username' => ['ELASTICSEARCH_USERNAME', 'elastic'], 'password' => ['ELASTICSEARCH_PASSWORD', '123456'], 'cert' => ['ELASTICSEARCH_CERT', '/etc/elasticsearch/certs/http_ca.crt'], 'settings' => [ 'number_of_shards' => ['ELASTICSEARCH_NUMBER_OF_SHARDS', 1], // 数据分片数,默认为5,有时候设置为3 'number_of_replicas' => ['ELASTICSEARCH_NUMBER_OF_REPLICAS', 0], // 数据备份数,如果只有一台机器,设置为0 ], 'client' => [ 'ignore' => [400, 404, 405, 500], // 忽略异常 'verbose' => false, //true 返回详细信息 'timeout' => 60, 'connect_timeout' => 60, 'future' => false, // 值为lazy,则开启future模式 ], 'logger' => 'elasticsearch', // 使用laravel日志驱动,”名称“为文件config/logging.php里面的驱动 'retries' => 5, // 设置重连次数 'max_handles' => 100, //需要开启 future 默认的批量值为 100 个,这意味着在客户端强制 future 对象解析前(执行 curl_multi 调用),队列可以容纳 100 个请求。 'repository_name' => env('ELASTICSEARCH_REPOSITORY_NAME', 'txj_es_backup'), // 快照的存储路径 'repository_location' => env('ELASTICSEARCH_REPOSITORY_LOCATION', '/mnt/backups'), // 快照的存储路径 ]), 'is_default' => 1, 'is_system' => 0, 'created_at' => time(), 'updated_at' => time() ], [ 'mid' => Str::random(12), 'category_type' => 2, 'type' => 'mongodb', 'title' => 'mongodb', 'config_json' => json_encode([]), 'is_default' => 1, 'is_system' => 0, 'created_at' => time(), 'updated_at' => time() ], ] ); } /** * Run the database seeds. * * @return void */ public function run() { $this->schema = 'dep_config_connect_db'; $this->title = '数据库配置表'; $this->start(); } }