Aby kolumna nie była nullable w migracji Laravel
Piszę migrację, aby utworzyć pewne kolumny w tabeli nullable
właśnie teraz. Dla funkcji down, oczywiście chcę jeszcze raz zrobić te kolumny not nullable
. Przejrzałem schema builder docs, ale nie widziałem, jak to zrobić.
78
2 answers
Przed laravelem 5 nie było natywnego sposobu zmiany istniejącej kolumny tabeli za pomocą konstruktora schematu. Musisz użyć do tego surowych zapytań.
Jednak od Laravel 5 możesz użyć:
$table->...->nullable(false)->change();
136
Author: TLGreg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-17 21:29:21
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-17 21:29:21
Od Laravel 5, możliwe jest odwrócenie tego natywnie - wystarczy przekazać false jako argument do nullable ().
Np.
$table -> string('foo') -> nullable(false) -> change();
30
Author: Matt McDonald,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-01-27 09:54:20
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-01-27 09:54:20