Foregin key Index name Size error in php laravel migration











up vote
0
down vote

favorite












I'm getting an error during migration which is mention below:



SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'port_call_departure_time_readings_port_call_departure_time_condition_id_foreign' is too long (SQL: alter table port_call_departure_time_readings add index port_call_departure_time_readings_port_call_departure_time_condition_id_foreign(port_call_departure_time_condition_id)):



Allowing size for FK index name is 59 and I have tested this during migration.
But orignal FK index name size is 79.



Can you please explain to me what would be the best solution to assign the FK index name in the port_call_departure_time_readings table for a port_call_departure_time_condition_id field?










share|improve this question






















  • May I see your migration code?
    – Fil
    Nov 9 at 11:43















up vote
0
down vote

favorite












I'm getting an error during migration which is mention below:



SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'port_call_departure_time_readings_port_call_departure_time_condition_id_foreign' is too long (SQL: alter table port_call_departure_time_readings add index port_call_departure_time_readings_port_call_departure_time_condition_id_foreign(port_call_departure_time_condition_id)):



Allowing size for FK index name is 59 and I have tested this during migration.
But orignal FK index name size is 79.



Can you please explain to me what would be the best solution to assign the FK index name in the port_call_departure_time_readings table for a port_call_departure_time_condition_id field?










share|improve this question






















  • May I see your migration code?
    – Fil
    Nov 9 at 11:43













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm getting an error during migration which is mention below:



SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'port_call_departure_time_readings_port_call_departure_time_condition_id_foreign' is too long (SQL: alter table port_call_departure_time_readings add index port_call_departure_time_readings_port_call_departure_time_condition_id_foreign(port_call_departure_time_condition_id)):



Allowing size for FK index name is 59 and I have tested this during migration.
But orignal FK index name size is 79.



Can you please explain to me what would be the best solution to assign the FK index name in the port_call_departure_time_readings table for a port_call_departure_time_condition_id field?










share|improve this question













I'm getting an error during migration which is mention below:



SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'port_call_departure_time_readings_port_call_departure_time_condition_id_foreign' is too long (SQL: alter table port_call_departure_time_readings add index port_call_departure_time_readings_port_call_departure_time_condition_id_foreign(port_call_departure_time_condition_id)):



Allowing size for FK index name is 59 and I have tested this during migration.
But orignal FK index name size is 79.



Can you please explain to me what would be the best solution to assign the FK index name in the port_call_departure_time_readings table for a port_call_departure_time_condition_id field?







php laravel migration size






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 10:54









Kashif Ahmed

357




357












  • May I see your migration code?
    – Fil
    Nov 9 at 11:43


















  • May I see your migration code?
    – Fil
    Nov 9 at 11:43
















May I see your migration code?
– Fil
Nov 9 at 11:43




May I see your migration code?
– Fil
Nov 9 at 11:43












2 Answers
2






active

oldest

votes

















up vote
2
down vote













Try this $table->index('column','index_name')






share|improve this answer




























    up vote
    0
    down vote













    The foreign() method accepts an index name as its second parameter. For example:



    $table->foreign('user_id', 'your_index_name_foreign')
    ->references('id')->on('users');


    When you don't specify a name, Laravel defaults to concatenating the table and column names. In some cases, the default name is longer than your database allows for an index.






    share|improve this answer























    • but I was not using the default name.
      – Kashif Ahmed
      Nov 14 at 10:53












    • @KashifAhmed so you manually named your foreign key port_call_departure_time_readings_port_call_departure_time_condition_id_foreign ? It would help if you include the migration code
      – Travis Britz
      Nov 14 at 10:56













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224343%2fforegin-key-index-name-size-error-in-php-laravel-migration%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    Try this $table->index('column','index_name')






    share|improve this answer

























      up vote
      2
      down vote













      Try this $table->index('column','index_name')






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        Try this $table->index('column','index_name')






        share|improve this answer












        Try this $table->index('column','index_name')







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 at 11:09









        Osama Alvi

        1368




        1368
























            up vote
            0
            down vote













            The foreign() method accepts an index name as its second parameter. For example:



            $table->foreign('user_id', 'your_index_name_foreign')
            ->references('id')->on('users');


            When you don't specify a name, Laravel defaults to concatenating the table and column names. In some cases, the default name is longer than your database allows for an index.






            share|improve this answer























            • but I was not using the default name.
              – Kashif Ahmed
              Nov 14 at 10:53












            • @KashifAhmed so you manually named your foreign key port_call_departure_time_readings_port_call_departure_time_condition_id_foreign ? It would help if you include the migration code
              – Travis Britz
              Nov 14 at 10:56

















            up vote
            0
            down vote













            The foreign() method accepts an index name as its second parameter. For example:



            $table->foreign('user_id', 'your_index_name_foreign')
            ->references('id')->on('users');


            When you don't specify a name, Laravel defaults to concatenating the table and column names. In some cases, the default name is longer than your database allows for an index.






            share|improve this answer























            • but I was not using the default name.
              – Kashif Ahmed
              Nov 14 at 10:53












            • @KashifAhmed so you manually named your foreign key port_call_departure_time_readings_port_call_departure_time_condition_id_foreign ? It would help if you include the migration code
              – Travis Britz
              Nov 14 at 10:56















            up vote
            0
            down vote










            up vote
            0
            down vote









            The foreign() method accepts an index name as its second parameter. For example:



            $table->foreign('user_id', 'your_index_name_foreign')
            ->references('id')->on('users');


            When you don't specify a name, Laravel defaults to concatenating the table and column names. In some cases, the default name is longer than your database allows for an index.






            share|improve this answer














            The foreign() method accepts an index name as its second parameter. For example:



            $table->foreign('user_id', 'your_index_name_foreign')
            ->references('id')->on('users');


            When you don't specify a name, Laravel defaults to concatenating the table and column names. In some cases, the default name is longer than your database allows for an index.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 9 at 12:23

























            answered Nov 9 at 12:16









            Travis Britz

            1,01946




            1,01946












            • but I was not using the default name.
              – Kashif Ahmed
              Nov 14 at 10:53












            • @KashifAhmed so you manually named your foreign key port_call_departure_time_readings_port_call_departure_time_condition_id_foreign ? It would help if you include the migration code
              – Travis Britz
              Nov 14 at 10:56




















            • but I was not using the default name.
              – Kashif Ahmed
              Nov 14 at 10:53












            • @KashifAhmed so you manually named your foreign key port_call_departure_time_readings_port_call_departure_time_condition_id_foreign ? It would help if you include the migration code
              – Travis Britz
              Nov 14 at 10:56


















            but I was not using the default name.
            – Kashif Ahmed
            Nov 14 at 10:53






            but I was not using the default name.
            – Kashif Ahmed
            Nov 14 at 10:53














            @KashifAhmed so you manually named your foreign key port_call_departure_time_readings_port_call_departure_time_condition_id_foreign ? It would help if you include the migration code
            – Travis Britz
            Nov 14 at 10:56






            @KashifAhmed so you manually named your foreign key port_call_departure_time_readings_port_call_departure_time_condition_id_foreign ? It would help if you include the migration code
            – Travis Britz
            Nov 14 at 10:56




















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224343%2fforegin-key-index-name-size-error-in-php-laravel-migration%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Schultheiß

            Verwaltungsgliederung Dänemarks

            Liste der Kulturdenkmale in Wilsdruff