NewSQLiteSessionStoreFromDB wraps an already-open *sql.DB in a session store, running the bootstrap schema and migrations against it. The caller retains ownership of db: it is not closed on error, and Store.Close() will close it when the store is closed. This is intended primarily for tests that wa
(ctx context.Context, db *sql.DB)
| 510 | // (sql.Open("sqlite", ":memory:")) or pre-seed a database with non-default |
| 511 | // state. Production callers should use NewSQLiteSessionStore. |
| 512 | func NewSQLiteSessionStoreFromDB(ctx context.Context, db *sql.DB) (*SQLiteSessionStore, error) { |
| 513 | if db == nil { |
| 514 | return nil, errors.New("db is nil") |
| 515 | } |
| 516 | if err := setupAndMigrate(ctx, db); err != nil { |
| 517 | return nil, err |
| 518 | } |
| 519 | return &SQLiteSessionStore{db: db}, nil |
| 520 | } |
| 521 | |
| 522 | // openAndMigrateSQLiteStore opens the database and runs migrations |
| 523 | func openAndMigrateSQLiteStore(ctx context.Context, path string) (*SQLiteSessionStore, error) { |