forked from eventum/eventum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphinx.php
81 lines (66 loc) · 2.5 KB
/
phinx.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/*
* This file is part of the Eventum (Issue Tracking System) package.
*
* @copyright (c) Eventum Team
* @license GNU General Public License, version 2 or later (GPL-2+)
*
* For the full copyright and license information,
* please see the COPYING and AUTHORS files
* that were distributed with this source code.
*/
use Eventum\Db\AbstractMigration;
use Eventum\Event\SystemEvents;
use Eventum\ServiceContainer;
use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Configuration proxy for phinx
*
* @see http://docs.phinx.org/en/latest/commands.html#configuration-file-parameter
*/
require_once __DIR__ . '/autoload.php';
// TODO: use "connection" => $pdo_instance once PEAR DB support is dropped
// http://docs.phinx.org/en/latest/commands.html#configuration-file-parameter
$config = DB_Helper::getConfig();
$phinx = [
'paths' => [
'migrations' => [
'db/migrations',
],
'seeds' => [
'db/seeds',
],
],
// http://docs.phinx.org/en/latest/configuration.html#custom-migration-base
'migration_base_class' => AbstractMigration::class,
'environments' => [
'default_migration_table' => 'phinxlog',
'default_environment' => 'production',
'production' => [
'adapter' => 'mysql',
'host' => $config['hostname'],
'name' => $config['database'],
'user' => $config['username'],
'pass' => $config['password'],
'port' => $config['port'],
'unix_socket' => $config['socket'] ?? null,
// Specify MySQL storage engine
// if not specified mysql server default will be used
// Examples: 'MyISAM', 'InnoDB'
'engine' => 'MyISAM',
// charset and collation must be utf8 compatible
'charset' => $config['charset'],
'collation' => $config['collation'] ?? 'utf8_general_ci',
// set SQL_MODE
// http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html
// https://github.com/robmorgan/phinx/blob/v0.8.0/src/Phinx/Db/Adapter/MysqlAdapter.php#L104-L110
'mysql_attr_init_command' => "SET SQL_MODE = ''",
],
],
];
// create "test" environment
$phinx['environments']['test'] = $phinx['environments']['production'];
$phinx['environments']['test']['name'] = getenv('MYSQL_DATABASE') ?: 'e_test';
$event = new GenericEvent(null, $phinx);
ServiceContainer::dispatch(SystemEvents::PHINX_CONFIG, $event);
return $event->getArguments();