tursodatabase / turso-driver-laravel

Turso Driver for Laravel with Native libSQL
https://turso.tech/sdk/php/guides/laravel
MIT License
62 stars 7 forks source link

[Bug]: error on migration on fresh insall laravel project #17

Closed johnqiuwan closed 2 months ago

johnqiuwan commented 2 months ago

What happened?

Fresh installed laravel project, and installed everything needed from the turso laravel doc link.

when run php artisan migrate, get the error:

Write delegation: `status: Unavailable, message: "grpc-status header missing, mapped from HTTP status code 502"

How to reproduce the bug

  1. fresh install laravel
  2. config libsql + laravel
  3. php artisan migrate

Package Version

1.0

PHP Version

8.2.0

Laravel Version

11.9

Which operating systems does with happen with?

macOS

Notes

this is the sample config currently using

DB_CONNECTION=libsql DB_DATABASE=database.sqlite DB_AUTH_TOKEN=token DB_SYNC_URL=database_url DB_SYNC_INTERVAL=5 DB_READ_YOUR_WRITES=true DB_ENCRYPTION_KEY= DB_REMOTE_ONLY=false

I have search online and someone has same issue , and they switch DB_REMOTE_ONLY=true and the issue gone.
In addition, I have tested DB_REMOTE_ONLY=true , and the issue is gone.

It seems there is something wrong on syncing remote. Please help!

darkterminal commented 2 months ago

Hi @johnqiuwan, you need to delete the local database first see this Embedded Replica - docs. Here is the types of Database Connection:

Local Connection

DB_CONNECTION=libsql
DB_DATABASE=database.sqlite
DB_AUTH_TOKEN= # empty
DB_SYNC_URL= # empty
DB_SYNC_INTERVAL=5
DB_READ_YOUR_WRITES=true
DB_ENCRYPTION_KEY=
DB_REMOTE_ONLY=false

Remote Connection

DB_CONNECTION=libsql
DB_DATABASE=database.sqlite
DB_AUTH_TOKEN=token
DB_SYNC_URL=database_url
DB_SYNC_INTERVAL=5
DB_READ_YOUR_WRITES=true
DB_ENCRYPTION_KEY=
DB_REMOTE_ONLY=true  # this should be set to true

Embedded Replica Connection

DB_CONNECTION=libsql
DB_DATABASE=database.sqlite
DB_AUTH_TOKEN=token
DB_SYNC_URL=database_url
DB_SYNC_INTERVAL=5
DB_READ_YOUR_WRITES=true
DB_ENCRYPTION_KEY=
DB_REMOTE_ONLY=false  # this should be set to false
johnqiuwan commented 2 months ago

Thank you for your reply! Thank you for creating this amazing tool @darkterminal !

When write data to database from turso dashboard, the data will sync to local successfully. However, when write data locally and sync to remote, the error popup

Write delegation: `status: Unavailable, message: "grpc-status header missing, mapped from HTTP status code 502"

I think the database connection setting such as .env variables has no issue. In addition, It seems the issue likely because the grpc request not be able to go through on the server side (using apache)

I have searched online to find solution and currently not found any solution related to this so far.

darkterminal commented 2 months ago

This is a DNS error... You can try to reach the Turso Discord server for more information.

This is already there. Fly DNS Error