Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Migrate from sql dump file fails (Laravel squashed migration import) #8

Open
BrandonDR opened this issue May 28, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@BrandonDR
Copy link

What happened?

I tried testing importing from an sql dump using Laravel's squash migrations feature.
https://laravel.com/docs/11.x/migrations#squashing-migrations

I get this error:

   Symfony\Component\Process\Exception\InvalidArgumentException 

  Command line is missing a value for parameter "LARAVEL_LOAD_DATABASE": sqlite3 "${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"

How to reproduce the bug

Create a database/schema/turso-schema.sql file with a simple CREATE TABLE statement.
Run artisan migrate:fresh with Turso as the database driver.

Output from php artisan migrate:fresh

  Dropping all tables ..................................................................................................................... 10s DONE

   INFO  Preparing database.  

  Creating migration table ........................................................................................................... 136.16ms DONE

   INFO  Loading stored database schemas.  

  database/schema/turso-schema.sql ................................................................................................... 148.70ms FAIL

   Symfony\Component\Process\Exception\InvalidArgumentException 

  Command line is missing a value for parameter "LARAVEL_LOAD_DATABASE": sqlite3 "${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"

  at vendor/symfony/process/Process.php:1585
    1581▕     private function replacePlaceholders(string $commandline, array $env): string
    1582▕     {
    1583▕         return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) {
    1584▕             if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) {
  ➜ 1585▕                 throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline);
    1586▕             }
    1587▕ 
    1588▕             return $this->escapeArgument($env[$matches[1]]);
    1589▕         }, $commandline);

  1   [internal]:0
      Symfony\Component\Process\Process::Symfony\Component\Process\{closure}()
      +37 vendor frames 

  39  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

 ELIFECYCLE  Command failed with exit code 1.

Package Version

0.7.0

PHP Version

8.3

Laravel Version

11.6.0

Which operating systems does with happen with?

Linux

Notes

No response

@BrandonDR BrandonDR added the bug Something isn't working label May 28, 2024
@BrandonDR BrandonDR changed the title [Bug]: Migrate from sql dump file fails (Laravel Migration Squash Import) [Bug]: Migrate from sql dump file fails (Laravel migration squash import) May 28, 2024
@BrandonDR BrandonDR changed the title [Bug]: Migrate from sql dump file fails (Laravel migration squash import) [Bug]: Migrate from sql dump file fails (Laravel squashed migration import) May 28, 2024
@richan-fongdasen
Copy link
Owner

richan-fongdasen commented May 29, 2024

Hi @BrandonDR ! Are you importing an existing SQLite database into a remote Turso database? It's best to use the Turso CLI for this.

Reference:
https://docs.turso.tech/cli/db/create#create-database-from-sqlite-file
https://docs.turso.tech/cli/db/create#create-database-from-sqlite-dump

@richan-fongdasen richan-fongdasen self-assigned this May 29, 2024
@BrandonDR
Copy link
Author

Thanks @richan-fongdasen yeah that does work. I was just experimenting, I have a local sqlite database for unit tests. I was trying to import the dump in the same way. This is not a big deal I can work around it. Great work on this package by the way!

@richan-fongdasen
Copy link
Owner

Glad to hear the CLI method works for you, @BrandonDR!

For testing, you can use database migrations and seeding like you normally would in a Laravel application. You can also use the Turso local development server for testing.

References:

I appreciate the feedback! It's great to hear how people are using this package. Let me know if you have any other questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants