How would I set Laravel 5.3 to use VARCHAR over NVARCHAR for migrations on mssql? Is there even a way to do this?
This question also applies to SMALLDATETIME over DATETIME.
How would I set Laravel 5.3 to use VARCHAR over NVARCHAR for migrations on mssql? Is there even a way to do this?
This question also applies to SMALLDATETIME over DATETIME.
I created a package that lets you do custom migrations without all the hassle of extending everything yourself.
https://github.com/shiftonelabs/laravel-nomad
Once you install the package, you just change your migration to use the new passthru
method, and you can give it the definition you want for your field.
// pass definition as third parameter
$table->passthru('string', 'username', 'varchar(60)');
$table->passthru('datetime', 'expires_at', 'smalldatetime');
// or use fluent definition method
$table->passthru('string', 'username')->definition('varchar(60)');
$table->passthru('datetime', 'expires_at')->definition('smalldatetime');
// if there is no defintion, it defaults to the first parameter
$table->passthru('smalldatetime', 'expires_at');
It's doable, but you'll probably have to create a new database driver yourself, which involves in the creation of
DatabaseManager
Connection
ConnectionFactory
Schema Builder
Schema Grammar
...
The good part is that you probably can extend all those guys from Laravel and only change the grammar class:
/**
* Create the column definition for a string type.
*
* @param \Illuminate\Support\Fluent $column
* @return string
*/
protected function typeString(Fluent $column)
{
return 'NVARCHAR ('.$column->length.')';
}
An example of it in this package:
https://github.com/jacquestvanzuydam/laravel-firebird/tree/5.3-support/src/Firebird