String as Primary Key in Laravel migration

May 29, 2017, at 03:00 AM

I've had to change a table in my database so that the primary key isn't the standard increments.

Here's the migration,

public function up()
    Schema::create('settings', function (Blueprint $table) {
        $table->text('code', 30)->primary();

However, MySQL keeps returning with,

Syntax error or access violation: 1170 BLOB/TEXT column 'code' used in key specification without a key length (SQL: alter table settings add primary key settings_code_primary(code)

I've tried leaving the normal increments id in there and modifying the table in a different migration but the same thing happens.

Any ideas of what I'm doing wrong?

Laveral Version 5.4.23

Answer 1

Change it to string.

$table->string('code', 30)->primary();
Rent Charter Buses Company
Receive post data ajax with php

Receive post data ajax with php

I'm trying to receive post data with php from ajax in same page but seems like i have some issues that i have no idea to solve them

Codeingiter - acces session with some_name

Codeingiter - acces session with some_name

I'am trying to access an index in my CI session with some_nameIn CI documentation there's a point that tell CI could save some_value in some_name

GET form data from array in php file [duplicate]

GET form data from array in php file [duplicate]

This question already has an answer here:

Separate portfolio items. wordpress

Separate portfolio items. wordpress

I want to seperste all the portfolio items into different pages,to get, let say, one page with one Portfolio Categories, next one with another Portfolio Categories