| @@ 182-203 (lines=22) @@ | ||
| 179 | * |
|
| 180 | * @return SchemaBuilder |
|
| 181 | */ |
|
| 182 | public function updateSchema(SchemaBuilder $builder = null, $createIndexes = false) |
|
| 183 | { |
|
| 184 | if (empty($builder)) { |
|
| 185 | $builder = $this->schemaBuilder(); |
|
| 186 | } |
|
| 187 | ||
| 188 | //We will create all required indexes now |
|
| 189 | if ($createIndexes) { |
|
| 190 | $builder->createIndexes(); |
|
| 191 | } |
|
| 192 | ||
| 193 | //Getting cached/normalized schema |
|
| 194 | $this->schema = $builder->normalizeSchema(); |
|
| 195 | ||
| 196 | //Saving |
|
| 197 | $this->memory->saveData(static::MEMORY, $this->schema); |
|
| 198 | ||
| 199 | //Let's reinitialize models (todo, make sure not harm can be made) |
|
| 200 | MutableObject::resetInitiated(); |
|
| 201 | ||
| 202 | return $builder; |
|
| 203 | } |
|
| 204 | ||
| 205 | /** |
|
| 206 | * Get instance of ODM SchemaBuilder. |
|
| @@ 120-141 (lines=22) @@ | ||
| 117 | * @param bool $syncronize Create all required tables and columns |
|
| 118 | * @return SchemaBuilder |
|
| 119 | */ |
|
| 120 | public function updateSchema(SchemaBuilder $builder = null, $syncronize = false) |
|
| 121 | { |
|
| 122 | if (empty($builder)) { |
|
| 123 | $builder = $this->schemaBuilder(); |
|
| 124 | } |
|
| 125 | ||
| 126 | //Create all required tables and columns |
|
| 127 | if ($syncronize) { |
|
| 128 | $builder->synchronizeSchema(); |
|
| 129 | } |
|
| 130 | ||
| 131 | //Getting normalized (cached) version of schema |
|
| 132 | $this->schema = $builder->normalizeSchema(); |
|
| 133 | ||
| 134 | //Saving |
|
| 135 | $this->memory->saveData(static::MEMORY, $this->schema); |
|
| 136 | ||
| 137 | //Let's reinitialize records |
|
| 138 | DataEntity::resetInitiated(); |
|
| 139 | ||
| 140 | return $builder; |
|
| 141 | } |
|
| 142 | ||
| 143 | /** |
|
| 144 | * Get instance of ORM SchemaBuilder. |
|