-
-
Save elchappo/8db7fb44270da911610e2e1430685014 to your computer and use it in GitHub Desktop.
Just in case anyone was wondering how set allow a column to be nullable with Doctrine DBAL's Schema later.
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
<?php | |
use Doctrine\DBAL\Schema\Schema; | |
// assuming you're using composer... | |
$loader = require __DIR__ . '/vendor/autoload.php'; | |
$schema = new Schema(); | |
$users = $schema->createTable('users'); | |
// doctrine calls methods of Doctrine\DBAL\Column based on options, the third argument of addColumn | |
// Eg. if you add a length. Doctrine does something like this. | |
// $col = new \Doctrine\DBAL\Column('colname') | |
// $col->setLength(255); | |
// Doctrine\DBAL\Column::setNotNull(bool $notnull) is the method call you want to make | |
// so just include notnull in your options! True will make the column NOT NULL, false will make it nullable. | |
$users->addColumn('reset_token', 'string', array('length' => 255, 'default' => null, 'notnull' => false)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment