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?
php laravel migration size
add a comment |
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?
php laravel migration size
May I see your migration code?
– Fil
Nov 9 at 11:43
add a comment |
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?
php laravel migration size
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
php laravel migration size
asked Nov 9 at 10:54
Kashif Ahmed
357
357
May I see your migration code?
– Fil
Nov 9 at 11:43
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
Try this $table->index('column','index_name')
add a comment |
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.
but I was not using the default name.
– Kashif Ahmed
Nov 14 at 10:53
@KashifAhmed so you manually named your foreign keyport_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
add a comment |
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')
add a comment |
up vote
2
down vote
Try this $table->index('column','index_name')
add a comment |
up vote
2
down vote
up vote
2
down vote
Try this $table->index('column','index_name')
Try this $table->index('column','index_name')
answered Nov 9 at 11:09
Osama Alvi
1368
1368
add a comment |
add a comment |
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.
but I was not using the default name.
– Kashif Ahmed
Nov 14 at 10:53
@KashifAhmed so you manually named your foreign keyport_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
add a comment |
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.
but I was not using the default name.
– Kashif Ahmed
Nov 14 at 10:53
@KashifAhmed so you manually named your foreign keyport_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
add a comment |
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.
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.
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 keyport_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
add a comment |
but I was not using the default name.
– Kashif Ahmed
Nov 14 at 10:53
@KashifAhmed so you manually named your foreign keyport_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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
May I see your migration code?
– Fil
Nov 9 at 11:43