catalog

package
v0.32.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestColumnSuite

func TestColumnSuite(t *testing.T)

TestColumnSuite provides organized tests for Column functionality

Types

type AlterationType

type AlterationType int
const (
	AddColumn AlterationType = iota
	DropColumn
	ModifyColumn
	RenameColumn
	AddIndex
	DropIndex
)

type Catalog

type Catalog struct {
	DefaultSchema string
	Schemas       map[string]*Schema
	// contains filtered or unexported fields
}

func NewCatalog

func NewCatalog(defaultSchema string) *Catalog

func (*Catalog) AddEnum

func (c *Catalog) AddEnum(schemaName string, enum *Enum) error

func (*Catalog) AddTable

func (c *Catalog) AddTable(schemaName string, table *Table) error

func (*Catalog) AlterTable

func (c *Catalog) AlterTable(
	schemaName, tableName string,
	alteration TableAlteration,
) error

func (*Catalog) CreateSchema

func (c *Catalog) CreateSchema(name string) (*Schema, error)

func (*Catalog) DropTable

func (c *Catalog) DropTable(schemaName, tableName string) error

func (*Catalog) GetSchema

func (c *Catalog) GetSchema(name string) (*Schema, error)

func (*Catalog) GetTable

func (c *Catalog) GetTable(schemaName, tableName string) (*Table, error)

func (*Catalog) ListTables

func (c *Catalog) ListTables(schemaName string) ([]*Table, error)

func (*Catalog) RenameTable

func (c *Catalog) RenameTable(schemaName, oldName, newName string) error

type Column

type Column struct {
	Name         string
	DataType     string
	IsNullable   bool
	IsArray      bool
	Length       *int32
	Precision    *int32
	Scale        *int32
	DefaultVal   *string
	CreatedBy    string // migration file that added this column
	ModifiedBy   string // migration file that last modified this column
	IsPrimaryKey bool
	IsUnique     bool
}

func NewColumn

func NewColumn(name, dataType string) *Column

func (*Column) Clone

func (c *Column) Clone() *Column

func (*Column) SetArray

func (c *Column) SetArray() *Column

func (*Column) SetCreatedBy

func (c *Column) SetCreatedBy(migrationFile string) *Column

func (*Column) SetDefault

func (c *Column) SetDefault(defaultValue string) *Column

func (*Column) SetLength

func (c *Column) SetLength(length int32) *Column

func (*Column) SetModifiedBy

func (c *Column) SetModifiedBy(migrationFile string) *Column

func (*Column) SetNotNull

func (c *Column) SetNotNull() *Column

func (*Column) SetPrecisionScale

func (c *Column) SetPrecisionScale(precision, scale int32) *Column

func (*Column) SetPrimaryKey

func (c *Column) SetPrimaryKey() *Column

func (*Column) SetUnique

func (c *Column) SetUnique() *Column

func (*Column) ValidatePrimaryKeyDatatype

func (c *Column) ValidatePrimaryKeyDatatype(databaseType, migrationFile string) error

type Enum

type Enum struct {
	Name      string
	Values    []string
	CreatedBy string
}

type Index

type Index struct {
	Name      string
	Columns   []string
	IsUnique  bool
	CreatedBy string
}

type Schema

type Schema struct {
	Name   string
	Tables map[string]*Table
	Enums  map[string]*Enum
}

type Table

type Table struct {
	Schema    string
	Name      string
	Columns   []*Column
	Indexes   []*Index
	CreatedBy string // migration file that created this table
}

func NewTable

func NewTable(schema, name string) *Table

func (*Table) AddColumn

func (t *Table) AddColumn(column *Column) error

func (*Table) AddIndex

func (t *Table) AddIndex(index *Index) error

func (*Table) Clone

func (t *Table) Clone() *Table

func (*Table) DropColumn

func (t *Table) DropColumn(name string) error

func (*Table) DropIndex

func (t *Table) DropIndex(name string) error

func (*Table) GetColumn

func (t *Table) GetColumn(name string) (*Column, error)

func (*Table) GetPrimaryKeyColumns

func (t *Table) GetPrimaryKeyColumns() []*Column

func (*Table) ModifyColumn

func (t *Table) ModifyColumn(name string, newColumn *Column) error

func (*Table) RenameColumn

func (t *Table) RenameColumn(oldName, newName string) error

func (*Table) SetCreatedBy

func (t *Table) SetCreatedBy(migrationFile string) *Table

type TableAlteration

type TableAlteration struct {
	Type      AlterationType
	Column    *Column
	OldName   string
	NewName   string
	IndexName string
	IndexDef  *Index
}

Jump to

Keyboard shortcuts

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