22 lines
508 B
Go
22 lines
508 B
Go
package checks
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.offline-twitter.com/offline-labs/gas-stack/pkg/schema"
|
|
"github.com/jmoiron/sqlx"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
// OpenSchema opens a SQLite database in memory, executes the schema against it, and adds some views
|
|
func OpenSchema(filepath string) (*sqlx.DB, error) {
|
|
// Read the SQL file
|
|
sqlBytes, err := os.ReadFile(filepath)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to read SQL file: %w", err)
|
|
}
|
|
|
|
return schema.InitDB(string(sqlBytes)), nil
|
|
}
|