gopgdbgen

package module
v0.0.0-...-ed743d2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

README

gopgdbgen

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorBlue = "\033[34m"
View Source
var ColorCyan = "\033[36m"
View Source
var ColorGray = "\033[37m"
View Source
var ColorGreen = "\033[32m"
View Source
var ColorMagenta = "\033[35m"
View Source
var ColorRed = "\033[31m"
View Source
var ColorReset = "\033[0m"
View Source
var ColorWhite = "\033[97m"
View Source
var ColorYellow = "\033[33m"
View Source
var FieldProp []string = []string{"name", "descr", "type", "length", "precision", "nullable", "default"}
View Source
var RelationProp []string = []string{"key", "name", "table", "field"}
View Source
var TableProp []string = []string{"schema", "table", "descr", "fields", "primarykeys", "uniques", "relations"}

Functions

This section is empty.

Types

type Config

type Config struct {
	Database    *DatabaseConfig  `yml:"database"`
	Directories *DirectoryConfig `yml:"directories"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Host     string `yml:"host"`
	Port     int    `yml:"port"`
	Dbname   string `yml:"dbname"`
	Username string `yml:"username"`
	Password string `yml:"password"`
}

type DbGenerator

type DbGenerator struct {
	Config *Config
}

func NewGenerator

func NewGenerator() *DbGenerator

func (*DbGenerator) BuildDatabase

func (dbg *DbGenerator) BuildDatabase(sqlfiles []string) error

func (*DbGenerator) ClearDdlDirectory

func (dbg *DbGenerator) ClearDdlDirectory() error

func (*DbGenerator) ComposeTableFromJson

func (dbg *DbGenerator) ComposeTableFromJson(filepath string) (tbl *Table, err error)

func (*DbGenerator) GenerateAll

func (dbg *DbGenerator) GenerateAll() ([]string, error)

func (*DbGenerator) ReadConfiguration

func (dbg *DbGenerator) ReadConfiguration(configfilepath string)

type DirectoryConfig

type DirectoryConfig struct {
	Ddl string `yml:"./dbbuild/ddl"`
	Tbl string `yml:"./dbbuild/tbl"`
}

type Field

type Field struct {
	Name         string `json:"name"`
	Description  string `json:"descr"`
	DataType     string `json:"type"`
	Length       int    `json:"length"`
	Precision    int    `json:"precision"`
	Nullable     bool   `json:"nullable"`
	DefaultValue string `json:"default"`
	IsPrimaryKey bool
}

func (*Field) AddFieldDdl

func (f *Field) AddFieldDdl() string

func (*Field) AlterFieldDdl

func (f *Field) AlterFieldDdl() []string

func (*Field) CreateFieldDdl

func (f *Field) CreateFieldDdl() string

type Relation

type Relation struct {
	Name     string `json:"name"`
	Table    string
	Key      string `json:"key"`
	RefTable string `json:"reftable"`
	RefKey   string `json:"refkey"`
}

type Table

type Table struct {
	Schema      string               `json:"schema"`
	TableName   string               `json:"table"`
	Description string               `json:"descr"`
	Fields      map[string]*Field    `json:"fields"`
	PrimaryKeys []string             `json:"primarykeys"`
	Uniques     map[string]*[]string `json:"uniques"`
	Relations   map[string]Relation  `json:"relations"`

	FieldNames []string
	PropNames  []string
}

func NewTable

func NewTable(jsondata []byte) (tbl *Table, err error)

func (*Table) AddMandatoryFields

func (tbl *Table) AddMandatoryFields() []string

func (*Table) GetRelations

func (tbl *Table) GetRelations() []*Relation

func (*Table) WriteSql

func (tbl *Table) WriteSql(sqlfilepath string) error

type TableRelations

type TableRelations struct {
	Relations []*Relation
}

func NewTableRelations

func NewTableRelations() *TableRelations

func (*TableRelations) Add

func (t *TableRelations) Add(r []*Relation)

func (*TableRelations) WriteSql

func (t *TableRelations) WriteSql(sqlfilepath string) error

Jump to

Keyboard shortcuts

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