| @@ 333-354 (lines=22) @@ | ||
| 330 | * @param bool $createIndexes |
|
| 331 | * @return SchemaBuilder |
|
| 332 | */ |
|
| 333 | public function updateSchema(SchemaBuilder $builder = null, $createIndexes = false) |
|
| 334 | { |
|
| 335 | if (empty($builder)) { |
|
| 336 | $builder = $this->schemaBuilder(); |
|
| 337 | } |
|
| 338 | ||
| 339 | //We will create all required indexes now |
|
| 340 | if ($createIndexes) { |
|
| 341 | $builder->createIndexes(); |
|
| 342 | } |
|
| 343 | ||
| 344 | //Getting cached/normalized schema |
|
| 345 | $this->schema = $builder->normalizeSchema(); |
|
| 346 | ||
| 347 | //Saving |
|
| 348 | $this->memory->saveData(static::MEMORY, $this->schema); |
|
| 349 | ||
| 350 | //Let's reinitialize models |
|
| 351 | DataEntity::resetInitiated(); |
|
| 352 | ||
| 353 | return $builder; |
|
| 354 | } |
|
| 355 | ||
| 356 | /** |
|
| 357 | * Get instance of ODM SchemaBuilder. |
|
| @@ 337-358 (lines=22) @@ | ||
| 334 | * @param bool $syncronize Create all required tables and columns |
|
| 335 | * @return SchemaBuilder |
|
| 336 | */ |
|
| 337 | public function updateSchema(SchemaBuilder $builder = null, $syncronize = false) |
|
| 338 | { |
|
| 339 | if (empty($builder)) { |
|
| 340 | $builder = $this->schemaBuilder(); |
|
| 341 | } |
|
| 342 | ||
| 343 | //Create all required tables and columns |
|
| 344 | if ($syncronize) { |
|
| 345 | $builder->synchronizeSchema(); |
|
| 346 | } |
|
| 347 | ||
| 348 | //Getting normalized (cached) version of schema |
|
| 349 | $this->schema = $builder->normalizeSchema(); |
|
| 350 | ||
| 351 | //Saving |
|
| 352 | $this->memory->saveData(static::MEMORY, $this->schema); |
|
| 353 | ||
| 354 | //Let's reinitialize records |
|
| 355 | DataEntity::resetInitiated(); |
|
| 356 | ||
| 357 | return $builder; |
|
| 358 | } |
|
| 359 | ||
| 360 | /** |
|
| 361 | * Get instance of ORM SchemaBuilder. |
|