Issues (71)

app/bin/schema-create.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
require __DIR__.'./../vendor/autoload.php';
6
7
use App\Kernel;
8
use Doctrine\ORM\Tools\SchemaTool;
0 ignored issues
show
The type Doctrine\ORM\Tools\SchemaTool was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
$kernel = new Kernel('test', true);
11
$kernel->boot();
12
$container = $kernel->getContainer();
13
14
$manager = $container->get('doctrine')->getManager();
15
$metadatas = $manager->getMetadataFactory()->getAllMetadata();
16
$schemaTool = new SchemaTool($manager);
17
$sqls = $schemaTool->getCreateSchemaSql($metadatas);
18
echo "Schema creating.... \n";
19
$schemaTool->createSchema($metadatas);
20
/** @var \Doctrine\DBAL\Connection $connection */
21
$connection = $container->get('doctrine')->getConnection();
22
$connection->beginTransaction();
23
$connection->query('DROP TABLE IF EXISTS `event_streams`;
24
CREATE TABLE `event_streams` (
25
  `no` bigint(20) NOT NULL AUTO_INCREMENT,
26
  `real_stream_name` varchar(150) COLLATE utf8_bin NOT NULL,
27
  `stream_name` char(41) COLLATE utf8_bin NOT NULL,
28
  `metadata` json DEFAULT NULL,
29
  `category` varchar(150) COLLATE utf8_bin DEFAULT NULL,
30
  PRIMARY KEY (`no`),
31
  UNIQUE KEY `ix_rsn` (`real_stream_name`),
32
  KEY `ix_cat` (`category`)
33
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
34
 ');
35
$connection->commit();
36
$connection->close();
37
if (empty($sqls)) {
38
    echo "Nothing to Create \n";
39
40
    return 0;
41
}
42
echo "Schema Created \n";
43