Skip to content
Advertisement

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; Error making a migration table

I’m trying to make a webshop using php, laravel, mysql and css. But when i try to make a migration table using foreign keys for products and orders i get this error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'unsigned not null, `description` text unsigned not null, `price` decimal(8, 2...' at line 1 (SQL: create table `orders` (`id` int unsigned not null auto_increment primary key, `user_id` int unsigned not null, `product_id` int unsigned not null, `name` varchar(255) unsigned not null, `description` text unsigned not null, `price` decimal(8, 2) unsigned not null, `totalAmount` decimal(8, 2) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

This is how my migration table looks like as of this moment:

JavaScript

Anyone that can help me solve this problem?

Advertisement

Answer

Instead of :

JavaScript

you could simply do this:

JavaScript

(At least for Laravel 7+)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement