josiah / doctrine-schema-builder
提供构建 Doctrine DBAL Schema 的声明性接口。
1.0.0
2013-07-07 01:02 UTC
Requires
- doctrine/dbal: ~2.1
Requires (Dev)
- phpunit/phpunit: ~3.7
This package is not auto-updated.
Last update: 2024-09-23 14:44:59 UTC
README
提供围绕 Doctrine DBAL Schema 类的声明性包装器,允许您以期望的方案定义方案,而不是以现有的方案定义。
示例
行动胜于言语,以下是一个构建器使用的示例
use Doctrine\DBAL\Schema\Builder; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; $schema = new Schema(); $builder = new Builder($schema); $builder // Create table if it doesn't exist, do nothing if it does ->createTable('foo', function (Table $table) { $table->addColumn('id', 'integer') ->setNotNull(true) ->setUnsigned(true) ->setAutoIncrement(true) ->setComment("Unique Identifier, DUH!"); $table->addColumn('name', 'string') ->setNotNull(true); $table->setPrimaryKey(['id']); // ... you get the picture. }) // Overwrite table if it exists, create it if it doesnt ->defineTable('bar', function (Table $table) { // ... more definition like before }) // Drop table if it exists, do nothing if it doesnt ->dropTable('baz');
许可证
许可协议为 MIT 许可证。如果您觉得不合适,请联系我。