tursodatabase / turso-cli

Command line interface to Turso.
https://turso.tech
MIT License
215 stars 35 forks source link

Database creation ignores location #677

Open penberg opened 12 months ago

penberg commented 12 months ago

The turso db create command silently ignores --location and instead just adds the database to the default placement group:

penberg@vonneumann libsql % turso db create foo --location cdg
Created database foo at group default in 1 seconds.

Start an interactive SQL shell with:

   turso db shell foo

To see information about the database, including a connection URL, run:

   turso db show foo

To get an authentication token for the database, run:

   turso db tokens create foo

What it should do is fail the creation and tell people to create a group instead.

notrab commented 8 months ago

@penberg I was thinking that we could remove the --location flag entirely and update ensureGroup to be:

func ensureGroup(client *turso.Client, group, version string) error {
    if ok, err := shouldCreateGroup(client, group); !ok {
        return err
    }

    location, _ := closestLocation(client)

    if err := createGroup(client, group, location, version); err != nil {
        return err
    }
    return client.Groups.WaitLocation(group, location)
}

That way when we magically create a default group we pick the closest region still. Wdyt?