sqldb: add the sqldb package

This commit provides the scaffolding for using the new sql stores.
The new interfaces, structs and methods are in sync with other projects
like Taproot Assets.

- Transactional Queries: the sqldb package defines the interfaces required
to execute transactional queries to our storage interface.

- Migration Files Embedded: the migration files are embedded into the binary.

- Database Migrations: I kept the use of 'golang-migrate' to ensure our
codebase remains in sync with the other projects, but can be changed.

- Build Flags for Conditional DB Target: flexibility to specify our database
target at compile-time based on the build flags in the same way we do
with our kv stores.

- Update modules: ran `go mod tidy`.
This commit is contained in:
positiveblue
2023-06-05 21:54:52 -07:00
parent d46ee0bd74
commit 5a7d7c2e4f
12 changed files with 1195 additions and 52 deletions

13
sqldb/postgres_test.go Normal file
View File

@@ -0,0 +1,13 @@
//go:build test_db_postgres
// +build test_db_postgres
package sqldb
import (
"testing"
)
// NewTestDB is a helper function that creates a Postgres database for testing.
func NewTestDB(t *testing.T) *PostgresStore {
return NewTestPostgresDB(t)
}