schema

package
v3.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

This package has SQL parser, its abstraction and SQL generator. Never touch database.

Index

Constants

View Source
const (
	AscScr  = "asc"
	DescScr = "desc"
)

IndexColumn.direction

View Source
const (
	ValueTypeStr = ValueType(iota)
	ValueTypeInt
	ValueTypeFloat
	ValueTypeHexNum
	ValueTypeHex
	ValueTypeValArg
	ValueTypeBit
	ValueTypeBool
)
View Source
const (
	ColumnKeyNone = ColumnKeyOption(iota)
	ColumnKeyPrimary
	ColumnKeySpatialKey
	ColumnKeyUnique
	ColumnKeyUniqueKey
	ColumnKey
)
View Source
const (
	GeneratedTypeVirtual = GeneratedType(iota)
	GeneratedTypeStored
)
View Source
const (
	GeneratorModeMysql = GeneratorMode(iota)
	GeneratorModePostgres
	GeneratorModeSQLite3
	GeneratorModeMssql
)

Variables

This section is empty.

Functions

func GenerateIdempotentDDLs

func GenerateIdempotentDDLs(mode GeneratorMode, sqlParser database.Parser, desiredSQL string, currentSQL string, config database.GeneratorConfig, defaultSchema string) ([]string, error)

Parse argument DDLs and call `generateDDLs()`

func StringConstant

func StringConstant(s string) string

Escape a string and add quotes to form a legal SQL string constant.

Types

type AddExclusion

type AddExclusion struct {
	// contains filtered or unexported fields
}

func (*AddExclusion) Statement

func (a *AddExclusion) Statement() string

type AddForeignKey

type AddForeignKey struct {
	// contains filtered or unexported fields
}

func (*AddForeignKey) Statement

func (a *AddForeignKey) Statement() string

type AddIndex

type AddIndex struct {
	// contains filtered or unexported fields
}

func (*AddIndex) Statement

func (a *AddIndex) Statement() string

type AddPolicy

type AddPolicy struct {
	// contains filtered or unexported fields
}

func (*AddPolicy) Statement

func (a *AddPolicy) Statement() string

type AddPrimaryKey

type AddPrimaryKey struct {
	// contains filtered or unexported fields
}

func (*AddPrimaryKey) Statement

func (a *AddPrimaryKey) Statement() string

type AggregatedSchema

type AggregatedSchema struct {
	Tables     []*Table
	Views      []*View
	Triggers   []*Trigger
	Types      []*Type
	Domains    []*Domain
	Comments   []*Comment
	Extensions []*Extension
	Schemas    []*Schema
	Privileges []*GrantPrivilege
}

type CheckDefinition

type CheckDefinition struct {
	// contains filtered or unexported fields
}

type Column

type Column struct {
	// contains filtered or unexported fields
}

type ColumnKeyOption

type ColumnKeyOption int

type Comment

type Comment struct {
	// contains filtered or unexported fields
}

func (*Comment) Statement

func (t *Comment) Statement() string

type ConstraintOptions

type ConstraintOptions struct {
	// contains filtered or unexported fields
}

type CreateIndex

type CreateIndex struct {
	// contains filtered or unexported fields
}

func (*CreateIndex) Statement

func (c *CreateIndex) Statement() string

type CreateTable

type CreateTable struct {
	// contains filtered or unexported fields
}

func (*CreateTable) Statement

func (c *CreateTable) Statement() string

type DDL

type DDL interface {
	Statement() string
}

func FilterPrivileges

func FilterPrivileges(ddls []DDL, config database.GeneratorConfig) []DDL

func FilterTables

func FilterTables(ddls []DDL, config database.GeneratorConfig) []DDL

func FilterViews

func FilterViews(ddls []DDL, config database.GeneratorConfig) []DDL

func ParseDDLs

func ParseDDLs(mode GeneratorMode, sqlParser database.Parser, sql string, defaultSchema string) ([]DDL, error)

Parse `ddls`, which is expected to `;`-concatenated DDLs and not to include destructive DDL.

func SortTablesByDependencies added in v3.1.0

func SortTablesByDependencies(ddls []DDL) []DDL

SortTablesByDependencies sorts CREATE TABLE DDLs by foreign key dependencies to ensure tables are created in the correct order (referenced tables before referencing tables) Also ensures CREATE TYPE statements are placed before CREATE TABLE statements that use them

type DefaultDefinition

type DefaultDefinition struct {
	// contains filtered or unexported fields
}

type Domain added in v3.6.0

type Domain struct {
	// contains filtered or unexported fields
}

func (*Domain) Statement added in v3.6.0

func (d *Domain) Statement() string

type DomainConstraint added in v3.6.0

type DomainConstraint struct {
	// contains filtered or unexported fields
}

type Exclusion

type Exclusion struct {
	// contains filtered or unexported fields
}

type ExclusionPair

type ExclusionPair struct {
	// contains filtered or unexported fields
}

type Extension

type Extension struct {
	// contains filtered or unexported fields
}

func (*Extension) Statement

func (t *Extension) Statement() string

type ForeignKey

type ForeignKey struct {
	// contains filtered or unexported fields
}

type Generated

type Generated struct {
	// contains filtered or unexported fields
}

type GeneratedType

type GeneratedType int

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

This struct holds simulated schema states during GenerateIdempotentDDLs().

type GeneratorMode

type GeneratorMode int

type GrantPrivilege

type GrantPrivilege struct {
	// contains filtered or unexported fields
}

func (*GrantPrivilege) Statement

func (g *GrantPrivilege) Statement() string

type Identity

type Identity struct {
	// contains filtered or unexported fields
}

type Index

type Index struct {
	// contains filtered or unexported fields
}

type IndexColumn

type IndexColumn struct {
	// contains filtered or unexported fields
}

func (IndexColumn) ColumnName added in v3.2.1

func (ic IndexColumn) ColumnName() string

ColumnName returns the column name if this is a simple column reference. For functional indexes or expressions, it returns the string representation.

type IndexOption

type IndexOption struct {
	// contains filtered or unexported fields
}

type IndexPartition

type IndexPartition struct {
	// contains filtered or unexported fields
}

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

type RevokePrivilege

type RevokePrivilege struct {
	// contains filtered or unexported fields
}

func (*RevokePrivilege) Statement

func (r *RevokePrivilege) Statement() string

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

func (*Schema) Statement

func (t *Schema) Statement() string

type Sequence

type Sequence struct {
	Name        string
	IfNotExists bool
	Type        string
	IncrementBy *int
	MinValue    *int
	NoMinValue  bool
	MaxValue    *int
	NoMaxValue  bool
	StartWith   *int
	Cache       *int
	Cycle       bool
	NoCycle     bool
	OwnedBy     string
}

type SridDefinition

type SridDefinition struct {
	// contains filtered or unexported fields
}

type Table

type Table struct {
	// contains filtered or unexported fields
}

func (*Table) PrimaryKey

func (t *Table) PrimaryKey() *Index

type TablePrivilege

type TablePrivilege struct {
	// contains filtered or unexported fields
}

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

func (*Trigger) Statement

func (t *Trigger) Statement() string

type Type

type Type struct {
	// contains filtered or unexported fields
}

TODO: include type information

func (*Type) Statement

func (t *Type) Statement() string

type Value

type Value struct {
	// contains filtered or unexported fields
}

type ValueType

type ValueType int

type View

type View struct {
	// contains filtered or unexported fields
}

func (*View) Statement

func (v *View) Statement() string

Jump to

Keyboard shortcuts

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