SQLite
Bundled SQLite Store adapter and its migrations.
Signet ships a SQLite adapter in github.com/shakibdshy/signet-auth/store/sqlite. It uses
modernc.org/sqlite, so no CGO is required.
go get github.com/shakibdshy/signet-auth/store/sqlite
go get modernc.org/sqliteSetup
import (
"database/sql"
"github.com/shakibdshy/signet-auth/store/sqlite"
_ "modernc.org/sqlite"
)
db, err := sql.Open("sqlite", "file:signet.db?_pragma=foreign_keys(1)")
if err != nil {
log.Fatal(err)
}
defer db.Close()
store := sqlite.New(db)
if err := store.Migrate(ctx); err != nil {
log.Fatal(err)
}
cfg.Store = storeMigrate applies embedded, idempotent SQL and enables PRAGMA foreign_keys = ON. When using a
connection pool, include foreign_keys=1 in the DSN so every connection has the pragma set. The
caller owns the *sql.DB and its lifecycle.
The DSN above creates signet.db in the working directory. Use a different path for production
and back it up like any other database.
See Storage for the Store contracts and schema, and PostgreSQL for the other bundled adapter.