简体   繁体   中英

Change column type Laravel 5

Why did I get the following errors

 SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL  
   COLLATE utf8mb4_unicode_ci' at line 1 (SQL: ALTER TABLE questions CHANGE category_id category_id INT DEFAULT  NOT NULL COLLATE utf8mb4_unicode_ci)

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL  
   COLLATE utf8mb4_unicode_ci' at line 1 

By executing the following code:

Schema::table('questions', function(Blueprint $table) {
     $table->integer('category_id')->unsigned()->change();
});

Use unsignedInteger instead

Schema::table('questions', function(Blueprint $table) {
   $table->unsignedInteger('category_id')->change();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM