lmsqueezy / laravel

A package to easily integrate your Laravel application with Lemon Squeezy.
https://lemonsqueezy.com
MIT License
503 stars 50 forks source link

Syntax error or access violation: 1067 Invalid default value for 'ordered_at' #93

Closed smell-of-curry closed 3 months ago

smell-of-curry commented 3 months ago

Lemon Squeezy for Laravel Version

1.5.4

Laravel Version

10.48.7

PHP Version

8.1

Description

After installing lmsqueezy, I run the migrations and I get an error when creating the orders table

SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'ordered_at' (Connection: mysql, SQL: create table `lemon_squeezy_orders` (`id` bigint unsigned not null auto_increment primary key, `billable_type` varchar(191) not null, `billable_id` bigint unsigned not null, `lemon_squeezy_id` varchar(191) not null, `customer_id` varchar(191) not null, `identifier` char(36) not null, `product_id` 
not null, `tax_name` varchar(191) null, `status` varchar(191) not null, `receipt_url` varchar(191) null, `refunded` tinyint(1) not null, `refunded_at` timestamp null, `ordered_at` timestamp not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

image

So I commented out the line for ordered_at and it fixed it. But I feel like this might break things. image

Steps To Reproduce

Install a fresh install, and run migrations.

heyjorgedev commented 3 months ago

Hi, I answered to an issue similar to this one recently, can you see if it helps?

https://github.com/lmsqueezy/laravel/issues/84

smell-of-curry commented 3 months ago

Thank you @heyjorgedev however in that post, no solution was sent?

heyjorgedev commented 3 months ago

Like I mentioned on the other issue, this message is weird since we are creating a table (so no data exists) and mysql is complaining about a default value on a non-nullable column, but since we are not inserting data it doesn't make any sense.

@Rijoanul-Shanto did you end up understanding what the problem was on your issue?

driesvints commented 3 months ago

Can't reproduce. Happy to have a new look with clear steps to reproduce.

valeryalexeev commented 3 months ago

I have the same problem on the fresh install on Laravel. Solved by customizing built-in migraiton:

php artisan vendor:publish --tag="lemon-squeezy-migrations"

and modified the ordered_at definition in lemon_squeezy_orders table

$table->timestamp('ordered_at')->nullable()->default(DB::raw('CURRENT_TIMESTAMP'));

also can't understand why this happens on table creation, but needed some solution to start working live

Rijoanul-Shanto commented 3 months ago

Like I mentioned on the other issue, this message is weird since we are creating a table (so no data exists) and mysql is complaining about a default value on a non-nullable column, but since we are not inserting data it doesn't make any sense.

@Rijoanul-Shanto did you end up understanding what the problem was on your issue?

I didn't have a chance to look into the issue later, but I'll definitely look into it and try to reproduce.