schema

package
v0.0.0-...-2d490e1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package schema provides a generic representation of database schemas. Note that our goal is not to faithfully represent all aspects of the schema, but just the relevant components for conversion to Spanner and reporting on the quality of the conversion (this motivates us to keep partial information about some features we will report on but not use in the conversion e.g. default values, check constraints).

The current version supports PostgreSQL. Expect it to grow as we support other databases. We might eventually support the Spanner schema, and potentially get rid of the ddl package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name    string
	Type    Type
	NotNull bool
	Unique  bool
	Ignored Ignored
}

Column represents a database column. TODO: add support for foreign keys.

type Ignored

type Ignored struct {
	Check      bool
	Identity   bool
	Default    bool
	Exclusion  bool
	ForeignKey bool
}

Ignored represents column properties/constraints that are not represented. We drop the details, but retain presence/absence for reporting purposes.

type Index

type Index struct {
	Name string
	Keys []Key
}

Index represents a database index.

type Key

type Key struct {
	Column string
	Desc   bool // By default, order is ASC. Set to true to specifiy DESC.
}

Key respresents a primary key or index key.

type Table

type Table struct {
	Name        string
	ColNames    []string          // List of column names (for predictable iteration order e.g. printing).
	ColDefs     map[string]Column // Details of columns.
	PrimaryKeys []Key
	Indexes     []Index
}

Table represents a database table.

type Type

type Type struct {
	Name        string
	Mods        []int64 // List of modifiers (aka type parameters e.g. varchar(8) or numeric(6, 4).
	ArrayBounds []int64 // Empty for scalar types.
}

Type represents the type of a column.

func (Type) Print

func (ty Type) Print() string

Print converts ty to a string suitable for printing.

Jump to

Keyboard shortcuts

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