Documentation ¶
Index ¶
- Constants
- type Column
- type Constraint
- type Driver
- type DriverMeta
- type Index
- type Label
- type Labels
- type Relation
- type Schema
- func (s *Schema) FindRelation(cs, pcs []*Column) (*Relation, error)
- func (s *Schema) FindTableByName(name string) (*Table, error)
- func (s Schema) MarshalJSON() ([]byte, error)
- func (s *Schema) NormalizeTableName(name string) string
- func (s *Schema) NormalizeTableNames(names []string) []string
- func (s *Schema) Repair() error
- func (s *Schema) Sort() error
- type Table
- func (t *Table) CollectTablesAndRelations(distance int, root bool) ([]*Table, []*Relation, error)
- func (t *Table) FindColumnByName(name string) (*Column, error)
- func (t *Table) FindConstrainsByColumnName(name string) []*Constraint
- func (t *Table) FindConstraintByName(name string) (*Constraint, error)
- func (t *Table) FindIndexByName(name string) (*Index, error)
- func (t *Table) FindTriggerByName(name string) (*Trigger, error)
- func (t *Table) HasColumnWithExtraDef() bool
- func (t Table) MarshalJSON() ([]byte, error)
- type Trigger
Constants ¶
const (
TypeFK = "FOREIGN KEY"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct { Name string `json:"name"` Type string `json:"type"` Nullable bool `json:"nullable"` Default sql.NullString `json:"default"` Comment string `json:"comment"` ExtraDef string `json:"extra_def,omitempty" yaml:"extraDef,omitempty"` ParentRelations []*Relation `json:"-"` ChildRelations []*Relation `json:"-"` }
Column is the struct for table column
func (Column) MarshalJSON ¶ added in v1.6.0
MarshalJSON return custom JSON byte
func (Column) MarshalYAML ¶ added in v1.26.0
MarshalYAML return custom YAML byte
func (*Column) UnmarshalJSON ¶ added in v1.6.0
UnmarshalJSON unmarshal JSON to schema.Column
func (*Column) UnmarshalYAML ¶ added in v1.26.0
UnmarshalYAML unmarshal YAML to schema.Column
type Constraint ¶ added in v0.2.2
type Constraint struct { Name string `json:"name"` Type string `json:"type"` Def string `json:"def"` Table *string `json:"table"` ReferenceTable *string `json:"reference_table" yaml:"referenceTable"` Columns []string `json:"columns"` ReferenceColumns []string `json:"reference_columns" yaml:"referenceColumns"` Comment string `json:"comment"` }
Constraint is the struct for database constraint
type Driver ¶ added in v1.6.0
type Driver struct { Name string `json:"name"` DatabaseVersion string `json:"database_version" yaml:"databaseVersion"` Meta *DriverMeta `json:"meta"` }
Driver is the struct for tbls driver information
func (Driver) MarshalJSON ¶ added in v1.28.0
MarshalJSON return custom JSON byte
type DriverMeta ¶ added in v1.29.0
type Index ¶
type Index struct { Name string `json:"name"` Def string `json:"def"` Table *string `json:"table"` Columns []string `json:"columns"` Comment string `json:"comment"` }
Index is the struct for database index
type Relation ¶
type Relation struct { Table *Table `json:"table"` Columns []*Column `json:"columns"` ParentTable *Table `json:"parent_table" yaml:"parentTable"` ParentColumns []*Column `json:"parent_columns" yaml:"parentColumns"` Def string `json:"def"` Virtual bool `json:"virtual"` }
Relation is the struct for table relation
func (Relation) MarshalJSON ¶ added in v1.26.0
MarshalJSON return custom JSON byte
func (Relation) MarshalYAML ¶ added in v1.26.0
MarshalYAML return custom YAML byte
func (*Relation) UnmarshalJSON ¶ added in v1.26.0
UnmarshalJSON unmarshal JSON to schema.Column
func (*Relation) UnmarshalYAML ¶ added in v1.26.0
UnmarshalYAML unmarshal YAML to schema.Column
type Schema ¶
type Schema struct { Name string `json:"name"` Desc string `json:"desc"` Tables []*Table `json:"tables"` Relations []*Relation `json:"relations"` Driver *Driver `json:"driver"` Labels Labels `json:"labels,omitempty"` }
Schema is the struct for database schema
func (*Schema) FindRelation ¶ added in v1.45.1
FindRelation ...
func (*Schema) FindTableByName ¶
FindTableByName find table by table name
func (Schema) MarshalJSON ¶ added in v1.25.1
MarshalJSON return custom JSON byte
func (*Schema) NormalizeTableName ¶ added in v1.28.2
func (*Schema) NormalizeTableNames ¶ added in v1.28.2
type Table ¶
type Table struct { Name string `json:"name"` Type string `json:"type"` Comment string `json:"comment"` Columns []*Column `json:"columns"` Indexes []*Index `json:"indexes"` Constraints []*Constraint `json:"constraints"` Triggers []*Trigger `json:"triggers"` Def string `json:"def"` Labels Labels `json:"labels,omitempty"` }
Table is the struct for database table
func (*Table) CollectTablesAndRelations ¶ added in v1.27.0
func (*Table) FindColumnByName ¶
FindColumnByName find column by column name
func (*Table) FindConstrainsByColumnName ¶ added in v1.33.0
func (t *Table) FindConstrainsByColumnName(name string) []*Constraint
FindConstrainsByColumnName find constraint by column name
func (*Table) FindConstraintByName ¶ added in v1.37.0
func (t *Table) FindConstraintByName(name string) (*Constraint, error)
FindConstraintByName find constraint by constraint name
func (*Table) FindIndexByName ¶ added in v1.37.0
FindIndexByName find index by index name
func (*Table) FindTriggerByName ¶ added in v1.37.0
FindTriggerByName find trigger by trigger name
func (*Table) HasColumnWithExtraDef ¶ added in v1.47.0
func (Table) MarshalJSON ¶ added in v1.25.1
MarshalJSON return custom JSON byte