我将如何覆盖Laravel 5.3 SQL语法 [英] How would I override Laravel 5.3 sql grammar
本文介绍了我将如何覆盖Laravel 5.3 SQL语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何将Laravel 5.3设置为通过VARCHAR而不是NVARCHAR来在mssql上进行迁移?甚至有办法做到这一点吗?
How would I set Laravel 5.3 to use VARCHAR over NVARCHAR for migrations on mssql? Is there even a way to do this?
此问题也适用于DATETIME的SMALLDATETIME.
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
安装该软件包后,只需更改迁移即可使用新的passthru
方法,然后可以为其指定字段所需的定义.
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');
这篇关于我将如何覆盖Laravel 5.3 SQL语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文