Ladon unable to use persistence example


#1

package main

import “github.com/ory/ladon
import manager “github.com/ory/ladon/manager/sql
import “github.com/jmoiron/sqlx
import (
_ “github.com/go-sql-driver/mysql
“log”
“fmt”
)

func main() {
// The database manager expects a sqlx.DB object
//
// For MySQL, be sure to include parseTime=true in the connection string
// You can find all of the supported MySQL connection string options for the
// driver at: https://github.com/go-sql-driver/mysql
//
db, err := sqlx.Open(“mysql”, “:@tcp(0.0.0.0:32768)/?parseTime=true”)
// Or, if using postgres:
// import _ “github.com/lib/pq
//
// db, err = sqlx.Open(“postgres”, “postgres://foo:[email protected]/ladon”)
if err != nil {
log.Fatalf(“Could not connect to database: %s”, err)
}

warden := &ladon.Ladon{
	Manager: manager.NewSQLManager(db, nil),
}

fmt.Println(warden)

// You must call SQLManager.CreateSchemas(schema, table) before use
// to apply the necessary SQL migrations
//
// You can provide your own schema and table name or pass
// empty strings to use the default
n, err := warden.Manager.CreateSchemas("", "my-migration-table")
if err != nil {
	log.Fatalf("Failed to create schemas: %s", err)
}
log.Printf("applied %d migrations", n)

// ...

}


#2

Please format the issue properly and give a bit more explanation about your issue. Giving code examples is ok but a bit more effort in creating the question would be nice.