crdb

package module
v0.0.0-...-42d4cf2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2017 License: AGPL-3.0 Imports: 5 Imported by: 0

README

ladon-crdb

CockroachDB support for the ladon library

To Use

IMPORTANT: The migration tool used by Ladon does not currently support CockroachDB, therefore some special care must be taken by creating the initial "ladon" database/schema manually.

This will be fixed with the merge of https://github.com/go-gorp/gorp/pull/359

import (
  "fmt"

  "github.com/jmoiron/sqlx"
  manager "github.com/ory/ladon/manager/sql"

  _ "github.com/wehco/ladon-crdb"
)

func main() {
  schema := "ladon"
  migrations_table := "ladon_migrations"

  crdb, _ := sqlx.Open(
    "cockroachdb",
    fmt.Sprintf("postgres://...@.../%s", schema),
  )

  if _, err := crdb.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s;", schema)); err != nil {
    panic(err)
  }

  crdbManager := manager.NewSQLManager(crdb, nil)
  _, err := crdbManager.CreateSchemas("", migrations_table)

  warden := ladon.Ladon{
    Manager: crdbManager,
  }
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL