Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ladon_policy table not getting created #100

Closed
adhicoder opened this issue Jan 23, 2018 · 3 comments
Closed

ladon_policy table not getting created #100

adhicoder opened this issue Jan 23, 2018 · 3 comments

Comments

@adhicoder
Copy link
Contributor

When I use the manager to interface with sql, the required tables are not getting created.

db, err := sqlx.Open("mysql", "tx81:@tcp(127.0.0.1:3306)/policies")
......
err=db.Ping()
if err == nil {
fmt.Printf("Database is up")
}

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

    var pol = &ladon.DefaultPolicy{
        ......
}
err = warden.Manager.Create(pol)
fmt.Printf("%s", err)

The error is printed as "Table 'policies.ladon_policy' doesn't exist".

@aeneasr
Copy link
Member

aeneasr commented Jan 23, 2018

The code is hard to read because its not formatted, could you please fix that?

The most likely reason is that you forgot to run CreateSchemas.

@adhicoder
Copy link
Contributor Author

Yes, using CreateSchemas solved the problem (partially). While creating the db object, it is also necessary to set parseTime to true. The documentation can be more comprehensive (as pointed out in another issue, sqlx must be used instead of sql). Please consider editing it.

@aeneasr
Copy link
Member

aeneasr commented Jan 24, 2018

While you're at it, could you improve those sections in a PR? That would be really helpful.

aeneasr pushed a commit that referenced this issue Feb 23, 2018
…ction. (#110)

This PR adds documentation for calling SQLManager.CreateSchemas when using
the officially supported SQLManager.

Additional notes:
- added note about using sqlx
- added note about adding parseTime=true to the
  MySQL connection string and a link to the driver for more options

This addresses issue #100

Signed-off-by: cabrel <cabrel@zerklabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants