package postgres import ( "database/sql" "embed" "fmt" _ "github.com/jackc/pgx/v4/stdlib" "github.com/pressly/goose/v3" ) //go:embed schema/*.sql var migrations embed.FS // Connect to a database func Connect(server string, user string, password string, database string) (*Queries, error) { connString := fmt.Sprintf("postgres://%s:%s@%s/%s", user, password, server, database) conn, err := sql.Open("pgx", connString) if err != nil { return nil, err } goose.SetBaseFS(migrations) if err = goose.Up(conn, "schema"); err != nil { return nil, err } return New(conn), nil }