You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When migrating a table with a very long primary key name (usually a set of 2 or more keys) Laravel generates a very long primary key name. This results in an exception in SingleStore saying it can't save a long primary key name.
But the thing is, the name is never used. It always defaults to be named PRIMARY.
When I run php artisan migrate I get the following exception:
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'redacted_redacted_1_id_very_long_column_name_that_is_redacted_2_id_primary' is too long (Connection: singlestore, SQL: create table `redacted` (`redacted_1_id` char(26) not null, `very_long_column_name_that_is_redacted_2_id` char(26) not null, `created_at` timestamp null, `updated_at` timestamp null, primary key `redacted_redacted_1_id_very_long_column_name_that_is_redacted_2_id_primary`(`redacted_1_id`, `very_long_column_name_that_is_redacted_2_id`), sort key(`redacted_1_id` asc, `very_long_column_name_that_is_redacted_2_id` asc)) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:795
791▕ // If an exception occurs when attempting to run a query, we'll format the error
792▕ // message to include the bindings with SQL, which will make this exception a
793▕ // lot more helpful to the developer instead of just the database's errors.
794▕ catch (Exception $e) {
➜ 795▕ throw new QueryException(
796▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
797▕ );
798▕ }
799▕ }
The way I solve it now is to add "placeholder" as the second paramater in the $table->primary() method.
It now migrates and when I look at the table I can see that "placeholder" isn't used but it's named PRIMARY:
On another note, I'm not sure where the redacted_1_id index comes from, is that the sort key name?
If so, might be better to name it _SORTKEY or something for the sake of consistency.
The text was updated successfully, but these errors were encountered:
When migrating a table with a very long primary key name (usually a set of 2 or more keys) Laravel generates a very long primary key name. This results in an exception in SingleStore saying it can't save a long primary key name.
But the thing is, the name is never used. It always defaults to be named
PRIMARY
.Example
I've go the following migration:
When I run
php artisan migrate
I get the following exception:The way I solve it now is to add
"placeholder"
as the second paramater in the$table->primary()
method.It now migrates and when I look at the table I can see that
![image](https://private-user-images.githubusercontent.com/8629456/259331690-085b1496-d07a-4f20-9213-5127e84ee75b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwNDIzNTgsIm5iZiI6MTcyNDA0MjA1OCwicGF0aCI6Ii84NjI5NDU2LzI1OTMzMTY5MC0wODViMTQ5Ni1kMDdhLTRmMjAtOTIxMy01MTI3ZTg0ZWU3NWIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTlUMDQzNDE4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDRhNDcxNDYzOTQzZDNkYmE5MmFjOGJhNzQ2N2I1NzM0ZjhmZTVkYmVhNDc5NzYwNTMyYzJhNTc3YmQxNDg4MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.WnjtWujL2ntXyf6jJpH2rDtoS5EpQPkMMrm1QqU6LI4)
"placeholder"
isn't used but it's namedPRIMARY
:On another note, I'm not sure where the
redacted_1_id
index comes from, is that the sort key name?If so, might be better to name it
_SORTKEY
or something for the sake of consistency.The text was updated successfully, but these errors were encountered: