-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from Kharhamel/lockFile
added a schema lock file to tdbm
- Loading branch information
Showing
18 changed files
with
203 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ vendor/* | |
.phpunit.result.cache | ||
/phpbench.sh | ||
/xdebug/ | ||
.php_cs.cache | ||
tdbm.lock.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace TheCodingMachine\TDBM\Utils; | ||
|
||
use Doctrine\DBAL\Schema\Column; | ||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\DBAL\Types\Type; | ||
|
||
class ImmutableCaster | ||
{ | ||
public static function castSchemaToImmutable(Schema $schema): void | ||
{ | ||
foreach ($schema->getTables() as $table) { | ||
foreach ($table->getColumns() as $column) { | ||
self::toImmutableType($column); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Changes the type of a column to an immutable date type if the type is a date. | ||
* This is needed because by default, when reading a Schema, Doctrine assumes a mutable datetime. | ||
*/ | ||
private static function toImmutableType(Column $column): void | ||
{ | ||
$mapping = [ | ||
Type::DATE => Type::DATE_IMMUTABLE, | ||
Type::DATETIME => Type::DATETIME_IMMUTABLE, | ||
Type::DATETIMETZ => Type::DATETIMETZ_IMMUTABLE, | ||
Type::TIME => Type::TIME_IMMUTABLE | ||
]; | ||
|
||
$typeName = $column->getType()->getName(); | ||
if (isset($mapping[$typeName])) { | ||
$column->setType(Type::getType($mapping[$typeName])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
|
||
namespace TheCodingMachine\TDBM\Utils; | ||
|
||
class RootProjectLocator | ||
{ | ||
public static function getRootLocationPath(): string | ||
{ | ||
$reflection = new \ReflectionClass(\Composer\Autoload\ClassLoader::class); | ||
return dirname($reflection->getFileName(), 3).'/'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.