laravel-permission
laravel-permission copied to clipboard
Timestamps in migration for sql server
Hi,
generating the migration and running in sql server leads to an error when trying to register a permission, because Laravel timestamps are needed to be registered with timestamps2
datatype.
When detecting sql server as the database,
the fields in the migration should be written as $table->timestamps(2);
My commands
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan optimize:clear
php artisan permission:create-permission "admin"
My version
"laravel/framework": "^10.10",
"spatie/laravel-permission": "^6.3"
Error
# php artisan permission:create-permission "admin"
Illuminate\Database\QueryException
SQLSTATE[22007]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]La conversione di un tipo di dati nvarchar in datetime ha generato un valore non compreso nell'intervallo dei valori consentiti. (Connection: sqlsrv, SQL: insert into [permissions] ([guard_name], [name], [updated_at], [created_at]) values (web, admin, 2024-02-19 15:04:35.936, 2024-02-19 15:04:35.936))
(The conversion of a varchar data type to a datetime data type resulted in an out-of-range value)