Closed Jacobs63 closed 1 week ago
I think rawColumn
would be a more fitting name as @morloderex notes. Please mark as ready for review when the requested changes have been made.
Not sure that I'm a fan of using the callback as I feel like it doesn't really have added value. The connection is already accessible via DB::connection()
.
Requested changes have been applied, feel free to re-check.
This PR introduces a new column method when creating/updating table schema.
Currently, when trying to create columns which are not natively supported by any of the grammars, we have to instead use database statements. This creates a rather big inconvenience as we cannot use a single table creation callback, because database statements are fired immediately and therefore cannot be used in
Schema::create(<table>, <callback>)
.Imagine a scenario, where we would like to create a:
posts
id
1
namedlegacy_boolean
with a default value of0
The example code to solve this would likely be as follows:
This PR introduces a new column creation method which supports directly specifiying the column type definition used for creating a column:
This however has one possible drawback - this is not grammar-agnostic and therefore would be specific to the database driver used, even though, by-default, working with columns is grammar-agnostic as the underlying column definitions are compiled by the grammar implementation used by the driver. On the other hand, the previous solution using database statements is also not grammar-agnostic and therefore we're just moving the drawback from one place to another, meaning, this should not be an issue after all, as we were already facing it elsewhere.