-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phinx-adapter.php
50 lines (43 loc) · 1.26 KB
/
phinx-adapter.php
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
<?php
/**
* MultiFlexi - Phinx database adapter.
*
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
* @copyright 2021-2024 Vitex Software
*/
if (file_exists('./vendor/autoload.php')) {
include_once './vendor/autoload.php';
} else {
include_once '../vendor/autoload.php';
}
$shared = \Ease\Shared::instanced();
if (file_exists('../.env')) {
$shared->loadConfig('../.env', true);
}
$prefix = file_exists('./db/') ? './db/' : '../db/';
$sqlOptions = [];
if (strstr(\Ease\Shared::cfg('DB_CONNECTION'), 'sqlite')) {
$sqlOptions['database'] = $prefix . basename(\Ease\Shared::cfg('DB_DATABASE'));
}
$engine = new \Ease\SQL\Engine(null, $sqlOptions);
$cfg = [
'paths' => [
'migrations' => [$prefix . 'migrations'],
'seeds' => [$prefix . 'seeds']
],
'environments' =>
[
'default_environment' => 'production',
'development' => [
'adapter' => \Ease\Shared::cfg('DB_CONNECTION'),
'name' => $engine->database,
'connection' => $engine->getPdo($sqlOptions)
],
'production' => [
'adapter' => \Ease\Shared::cfg('DB_CONNECTION'),
'name' => $engine->database,
'connection' => $engine->getPdo($sqlOptions)
],
]
];
return $cfg;