fermyon / cloud-plugin

A Spin plugin for the Spin CLI for managing Spin apps in Fermyon Cloud.
https://developer.fermyon.com/cloud/
Apache License 2.0
8 stars 13 forks source link

Sqlite execute does not respect (default) database #70

Closed adamreese closed 1 year ago

adamreese commented 1 year ago

When running sqlite commands the name of the database is required. This makes it difficult to run ci deployments using migrations without using awk.

❯ spin cloud sqlite list
Databases (1)
blissful-sheep (default)

❯ spin cloud sqlite execute default @highscore/migration.sql
Error: No database found with name "default"

❯ spin cloud sqlite execute blissful-sheep @highscore/migration.sql

The work around is

❯ spin cloud sqlite execute "$(spin cloud sqlite list | awk '/default/{print $1}')" @highscore/migration.sql
itowlson commented 1 year ago

@kate-goldenring I am not sure how to tackle this one. My first thought was we could allow --label (or --app/--label) instead of the name, but that doesn't mesh super comfortably with the current positional syntax - we'd have to treat the first positional argument as the statement if --label was present, and disallow a second positional argument.

The alternative is to make a breaking change away from positional arguments to spin cloud sqlite execute --database feline-dustbin @migration.sql (or even --database feline-dustbin --sql @migration.sql). Then we could allow --label as an alternative to --database.

Thoughts?

kate-goldenring commented 1 year ago

@itowlson this is tricky because as you say, you must either provide DB name or both app and label. I think our best option here is to break the CLI experience. I don't think we need the --sql flag rather the only positional argument could be the statement to execute