Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DaveSalazar's avatar

migrate from mysql to sql server

I have migrations from a mysql database, and all works fine. Now I want to migrate those tables to a sql server database, I reconfigue the .env and app/database file, but when i run php artisan migrate get this error:

[Illuminate\Database\QueryException] SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near the keyword 'RESTRICT'. (SQL: alter table "alumno" add constraint "alumno_ibfk_2" foreign key ("id_proyecto") references "proyecto" ("id") on delete RESTRICT on update RESTRICT)

[PDOException] SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near the keyword 'RESTRICT'.

this error shows when create the tables with foreing keys.

0 likes
2 replies
DaveSalazar's avatar

there are 11 migrations, each one get the same mistake with different fields

one of then is this:


<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddForeignKeysToAlumnoTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('alumno', function(Blueprint $table)
        {
            $table->foreign('id_proyecto', 'alumno_ibfk_2')->references('id')->on('proyecto')->onUpdate('RESTRICT')->onDelete('RESTRICT');
            $table->foreign('id', 'alumno_ibfk_3')->references('id')->on('datos_personales')->onUpdate('RESTRICT')->onDelete('RESTRICT');
        });
    }


    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('alumno', function(Blueprint $table)
        {
            $table->dropForeign('alumno_ibfk_2');
            $table->dropForeign('alumno_ibfk_3');
        });
    }

}

Please or to participate in this conversation.