-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphinx.php
More file actions
72 lines (65 loc) · 2.24 KB
/
phinx.php
File metadata and controls
72 lines (65 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
declare(strict_types=1);
use Dotenv\Dotenv;
require_once __DIR__ . '/vendor/autoload.php';
// Load environment variables
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
// Parse DB_HOST to extract host and port
$dbHost = $_ENV['DB_HOST'] ?? 'localhost';
$dbPort = 3306;
if (str_contains($dbHost, ':')) {
[$dbHost, $dbPort] = explode(':', $dbHost, 2);
$dbPort = (int) $dbPort;
}
return [
'paths' => [
'migrations' => '%%PHINX_CONFIG_DIR%%/db/migrations',
'seeds' => '%%PHINX_CONFIG_DIR%%/db/seeds',
],
'environments' => [
'default_migration_table' => 'phinxlog',
'default_environment' => $_ENV['APP_ENV'] ?? 'production',
'production' => [
'adapter' => 'mysql',
'host' => $dbHost,
'port' => $dbPort,
'name' => $_ENV['DB_NAME'] ?? '',
'user' => $_ENV['DB_USERNAME'] ?? '',
'pass' => $_ENV['DB_PASSWORD'] ?? '',
'charset' => $_ENV['DB_CHARSET'] ?? 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
],
'local' => [
'adapter' => 'mysql',
'host' => $dbHost,
'port' => $dbPort,
'name' => $_ENV['DB_NAME'] ?? '',
'user' => $_ENV['DB_USERNAME'] ?? '',
'pass' => $_ENV['DB_PASSWORD'] ?? '',
'charset' => $_ENV['DB_CHARSET'] ?? 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
],
'development' => [
'adapter' => 'mysql',
'host' => $dbHost,
'port' => $dbPort,
'name' => $_ENV['DB_NAME'] ?? '',
'user' => $_ENV['DB_USERNAME'] ?? '',
'pass' => $_ENV['DB_PASSWORD'] ?? '',
'charset' => $_ENV['DB_CHARSET'] ?? 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
],
'testing' => [
'adapter' => 'mysql',
'host' => $dbHost,
'port' => $dbPort,
'name' => ($_ENV['DB_NAME'] ?? '') . '_test',
'user' => $_ENV['DB_USERNAME'] ?? '',
'pass' => $_ENV['DB_PASSWORD'] ?? '',
'charset' => $_ENV['DB_CHARSET'] ?? 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
],
],
'version_order' => 'creation',
];