schema

package
v0.0.0-...-a8d5110 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InsertDbQ    = "INSERT INTO dbs(id, name) VALUES (?, ?) ON CONFLICT DO NOTHING;"
	InsertTableQ = "INSERT INTO tables(id, name) VALUES (?, ?) ON CONFLICT DO NOTHING;"
	InsertTypeQ  = "INSERT INTO types(id, name) VALUES (?, ?) ON CONFLICT DO NOTHING;"
	InsertUrlQ   = "INSERT INTO urls(id, url) VALUES (?, ?) ON CONFLICT DO NOTHING;"
	InsertNoteQ  = "INSERT INTO notes(id, note) VALUES (?, ?) ON CONFLICT DO NOTHING;"

	InsertColumnQ = "INSERT INTO columns(id, table_id, name) VALUES (?, ?, ?) " +
		"ON CONFLICT DO NOTHING;"

	InsertVersionQ = "INSERT INTO versions(id, db_id, version, is_current, version_order) " +
		"VALUES (?, ?, ?, ?, ?) ON CONFLICT DO UPDATE SET" +
		" is_current = coalesce(excluded.is_current, is_current)" +
		" , version_order = coalesce(excluded.version_order, version_order);"
	InsertLicenseQ = "INSERT INTO licenses(id, license, attribution, url_id) " +
		"VALUES (?, ?, ?, ?) ON CONFLICT DO NOTHING;" // ?
	InsertColumnVersionQ = "INSERT INTO column_versions(" +
		"id, column_id, version_id, type_id, nullable, url_id, note_id, note_license_id" +
		") VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET" +
		" type_id = coalesce(excluded.type_id, type_id)" +
		" , url_id = coalesce(excluded.url_id, url_id)" +
		" , note_id = coalesce(excluded.note_id, note_id)" +
		" , note_license_id = coalesce(excluded.note_license_id, note_license_id);"
)

Variables

View Source
var Schema string

Functions

func AsOrder

func AsOrder(version string) int64

func BulkInsert

func BulkInsert(outputPath string, cols <-chan []ColVersion, wg *sync.WaitGroup)

func Connect

func Connect(path string) (db *sql.DB, err error)

func DeriveColumnId

func DeriveColumnId(tableId int64, colName string) int64

func DeriveColumnVersionId

func DeriveColumnVersionId(colId int64, versionId int64) int64

func DeriveDbId

func DeriveDbId(dbName string) int64

func DeriveLicenseId

func DeriveLicenseId(license string, attribution string) int64

func DeriveNoteId

func DeriveNoteId(note string) int64

func DeriveTableId

func DeriveTableId(table string) int64

func DeriveTypeId

func DeriveTypeId(name string) int64

func DeriveUrlId

func DeriveUrlId(url string) int64

func DeriveVersionId

func DeriveVersionId(dbId int64, version string) int64

func MustConnect

func MustConnect(path string) *sql.DB

func SemverAsOrder

func SemverAsOrder(v *semver.Version) (result int64)

pack major.minor[.patch] numbers into a single int64

Types

type ColVersion

type ColVersion struct {
	DbVersion *Version
	Column    *Column
	Type      *Type
	Notes     *Note
	Url       *Url
	Nullable  Nullability
	Number    int
}

func (ColVersion) Clone

func (c ColVersion) Clone() ColVersion

func (ColVersion) Id

func (c ColVersion) Id() int64

type Column

type Column struct {
	Table *Table
	Name  string
}

func (Column) Id

func (c Column) Id() int64

type Database

type Database struct {
	Name string
}

func (Database) Id

func (db Database) Id() int64

type License

type License struct {
	License     string
	Attribution string
	Url         *Url
}

func (License) Id

func (l License) Id() int64

type Note

type Note struct {
	Note    string
	License *License
}

func (Note) Id

func (n Note) Id() int64

type Nullability

type Nullability int8
const (
	Unknown     Nullability = -1
	Nullable    Nullability = 0
	NotNullable Nullability = 1
)

func FromBool

func FromBool(nullable *bool) Nullability

func FromString

func FromString(nullable string) Nullability

func (Nullability) ToBool

func (n Nullability) ToBool() *bool

type Table

type Table struct{ Name string }

func (Table) Id

func (t Table) Id() int64

type Type

type Type struct {
	Name string
}

func (Type) Id

func (t Type) Id() int64

type Url

type Url struct {
	Url string
}

func (Url) Id

func (u Url) Id() int64

type Version

type Version struct {
	Db        *Database
	IsCurrent *bool
	Version   string
	Order     *int64
}

func (Version) Id

func (v Version) Id() int64

Jump to

Keyboard shortcuts

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