File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -873,6 +873,7 @@ Edit in phpunit.xml constants:
873
873
<env name =" CLICKHOUSE_HOST" value =" 127.0.0.1" />
874
874
<env name =" CLICKHOUSE_PORT" value =" 8123" />
875
875
<env name =" CLICKHOUSE_USER" value =" default" />
876
+ <env name =" CLICKHOUSE_DATABASE" value =" phpChTestDefault" />
876
877
<env name =" CLICKHOUSE_PASSWORD" value =" " />
877
878
<env name =" CLICKHOUSE_TMPPATH" value =" /tmp" />
878
879
</php >
Original file line number Diff line number Diff line change 20
20
"php" : " ^7.1" ,
21
21
"doctrine/coding-standard" : " ^4.0" ,
22
22
"phpstan/phpstan" : " ^0.9.2" ,
23
- "phpunit/phpunit" : " ^7.0"
23
+ "phpunit/phpunit" : " ^7" ,
24
+ "sebastian/comparator" : " ~3.0"
24
25
},
25
26
"autoload" : {
26
27
"psr-4" : {
Original file line number Diff line number Diff line change @@ -33,10 +33,18 @@ public function restartClickHouseClient()
33
33
'password ' => getenv ('CLICKHOUSE_PASSWORD ' ),
34
34
35
35
];
36
+
36
37
$ this ->client = new Client ($ config );
37
38
$ databaseName = getenv ('CLICKHOUSE_DATABASE ' );
38
- $ this ->client ->write (sprintf ('DROP DATABASE IF EXISTS "%s" ' , $ databaseName ));
39
- $ this ->client ->write (sprintf ('CREATE DATABASE "%s" ' , $ databaseName ));
39
+ if (!$ databaseName || $ databaseName ==='default ' ) {
40
+ throw new \Exception ('Change CLICKHOUSE_DATABASE, not use default ' );
41
+ }
42
+ if (empty ($ GLOBALS ['phpCH_needFirstCreateDB ' ])) { // hack use Global VAR, for once create DB
43
+ $ GLOBALS ['phpCH_needFirstCreateDB ' ]=true ;
44
+ $ this ->client ->write (sprintf ('DROP DATABASE IF EXISTS "%s" ' , $ databaseName ));
45
+ $ this ->client ->write (sprintf ('CREATE DATABASE "%s" ' , $ databaseName ));
46
+ }
47
+ // Change Database
40
48
$ this ->client ->database ($ databaseName );
41
49
}
42
50
}
You can’t perform that action at this time.
0 commit comments