1 | <?php |
||
39 | class SchemaGenerator |
||
40 | { |
||
41 | /** |
||
42 | * @var \Doctrine\DBAL\Schema\AbstractSchemaManager |
||
43 | */ |
||
44 | private $schema; |
||
45 | |||
46 | /** |
||
47 | * @var FieldGenerator |
||
48 | */ |
||
49 | private $fieldGenerator; |
||
50 | |||
51 | /** |
||
52 | * @var ForeignKeyGenerator |
||
53 | */ |
||
54 | private $foreignKeyGenerator; |
||
55 | |||
56 | private $indexGenerator; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $database; |
||
62 | |||
63 | /** |
||
64 | * @var bool |
||
65 | */ |
||
66 | private $ignoreIndexNames; |
||
67 | |||
68 | /** |
||
69 | * @var bool |
||
70 | */ |
||
71 | private $ignoreForeignKeyNames; |
||
72 | |||
73 | /** |
||
74 | * Custom doctrine type |
||
75 | * ['class', 'name', 'type'] |
||
76 | * @see registerCustomDoctrineType() |
||
77 | * |
||
78 | * @var array |
||
79 | */ |
||
80 | private static $customDoctrineTypes = [ |
||
81 | [DoubleType::class, 'double', 'double'], |
||
82 | [EnumType::class, 'enum', 'enum'], |
||
83 | [GeometryType::class, 'geometry', 'geometry'], |
||
84 | [GeometryCollectionType::class, 'geometrycollection', 'geometrycollection'], |
||
85 | [LineStringType::class, 'linestring', 'linestring'], |
||
86 | [LongTextType::class, 'longtext', 'longtext'], |
||
87 | [MediumIntegerType::class, 'mediumint', 'mediumint'], |
||
88 | [MediumTextType::class, 'mediumtext', 'mediumtext'], |
||
89 | [MultiLineStringType::class, 'multilinestring', 'multilinestring'], |
||
90 | [MultiPointType::class, 'multipoint', 'multipoint'], |
||
91 | [MultiPolygonType::class, 'multipolygon', 'multipolygon'], |
||
92 | [PointType::class, 'point', 'point'], |
||
93 | [PolygonType::class, 'polygon', 'polygon'], |
||
94 | [SetType::class, 'set', 'set'], |
||
95 | [TimestampType::class, 'timestamp', 'timestamp'], |
||
96 | [TinyIntegerType::class, 'tinyint', 'tinyint'], |
||
97 | [UUIDType::class, 'uuid', 'uuid'], |
||
98 | [YearType::class, 'year', 'year'], |
||
99 | |||
100 | // Postgres types |
||
101 | [IpAddressType::class, 'ipaddress', 'inet'], |
||
102 | [JsonbType::class, 'jsonb', 'jsonb'], |
||
103 | [MacAddressType::class, 'macaddress', 'macaddr'], |
||
104 | [TimeTzType::class, 'timetz', 'timetz'], |
||
105 | [TimestampTzType::class, 'timestamptz', 'timestamptz'], |
||
106 | ]; |
||
107 | |||
108 | public function __construct( |
||
117 | |||
118 | /** |
||
119 | * @param string $database |
||
120 | * @param bool $ignoreIndexNames |
||
121 | * @param bool $ignoreForeignKeyNames |
||
122 | * @throws \Doctrine\DBAL\DBALException |
||
123 | */ |
||
124 | public function initialize(string $database, bool $ignoreIndexNames, bool $ignoreForeignKeyNames) |
||
154 | |||
155 | /** |
||
156 | * @return string[] |
||
157 | */ |
||
158 | public function getTables(): array |
||
162 | |||
163 | public function getTable(string $tableName): Table |
||
167 | |||
168 | /** |
||
169 | * @param Table $table |
||
170 | * @return array|\Illuminate\Support\Collection[] |
||
171 | * [ |
||
172 | * 'single' => Collection of single column indexes, with column name as key |
||
173 | * 'multi' => Collection of multi columns indexes |
||
174 | * ] |
||
175 | */ |
||
176 | public function getIndexes(Table $table): array |
||
180 | |||
181 | public function getFields(Table $table, Collection $singleColIndexes): array |
||
185 | |||
186 | public function getForeignKeyConstraints(string $table): array |
||
190 | |||
191 | /** |
||
192 | * Register custom doctrineType |
||
193 | * Will override if exists |
||
194 | * |
||
195 | * @param $class |
||
196 | * @param $name |
||
197 | * @param $type |
||
198 | * @throws \Doctrine\DBAL\DBALException |
||
199 | */ |
||
200 | public function registerCustomDoctrineType($class, $name, $type) |
||
214 | } |
||
215 |