Documentation ¶
Overview ¶
Package spanddl provides primitives for in-memory modeling the DDL of Spanner databases.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct { // Tables in the database. Tables []*Table // Indexes in the database. Indexes []*Index }
Database represents an in-memory Spanner database.
Example ¶
package main import ( "fmt" "os" "path/filepath" "cloud.google.com/go/spanner/spansql" "go.einride.tech/spanner-aip/spanddl" ) func main() { var db spanddl.Database files, err := filepath.Glob("../testdata/migrations/freight/*.up.sql") if err != nil { panic(err) // TODO: Handle error. } for _, file := range files { fileContent, err := os.ReadFile(file) if err != nil { panic(err) // TODO: Handle error. } ddl, err := spansql.ParseDDL(file, string(fileContent)) if err != nil { panic(err) // TODO: Handle error. } if err := db.ApplyDDL(ddl); err != nil { panic(err) // TODO: Handle error. } } for _, table := range db.Tables { fmt.Println(table.Name) } }
Output: shippers sites shipments line_items
Click to show internal directories.
Click to hide internal directories.