Documentation ¶
Index ¶
- Constants
- Variables
- type AdditionalComment
- type AdditionalRelation
- type ColumnCount
- type Config
- func (c *Config) FilterTables(s *schema.Schema) error
- func (c *Config) Load(configPath string, options ...Option) error
- func (c *Config) LoadConfig(in []byte) error
- func (c *Config) LoadConfigFile(path string) error
- func (c *Config) LoadEnviron() error
- func (c *Config) LoadOption(options ...Option) error
- func (c *Config) MaskedDSN() (string, error)
- func (c *Config) MergeAdditionalData(s *schema.Schema) error
- func (c *Config) ModifySchema(s *schema.Schema) error
- func (c *Config) NeedToGenerateERImages() bool
- func (c *Config) SchemaFilePath() string
- type DSN
- type DetectVirtualRelations
- type Dot
- type DuplicateRelations
- type ER
- type Format
- type LabelStyleBigQuery
- type Lint
- type MD
- type Mermaid
- type Namer
- type NamingStrategy
- type Option
- func Adjust(adjust bool) Option
- func BaseUrl(baseUrl string) Option
- func DSNURL(dsn string) Option
- func Distance(distance int) Option
- func DocPath(docPath string) Option
- func ERFormat(erFormat string) Option
- func ERSkip(skip bool) Option
- func Exclude(e []string) Option
- func Include(i []string) Option
- func IncludeLabels(l []string) Option
- func Sort(sort bool) Option
- type PUML
- type RequireColumnComment
- type RequireColumns
- type RequireColumnsColumn
- type RequireConstraintComment
- type RequireForeignKeyIndex
- type RequireIndexComment
- type RequireTableComment
- type RequireTableLabels
- type RequireTriggerComment
- type RequireViewpoints
- type Rule
- type RuleWarn
- type ShowColumnTypes
- type Templates
- type UnrelatedTable
- type Viewpoint
- type ViewpointGroup
Constants ¶
const DefaultDocPath = "dbdoc"
const DefaultERFormat = "svg"
DefaultERFormat is the default ER diagram format
const SchemaFileName = "schema.json"
Variables ¶
var DefaultConfigFilePaths = []string{".tbls.yml", "tbls.yml"}
var DefaultERDistance = 1
DefaultERDistance is the default distance between tables that display relations in the ER
var SupportERFormat = []string{"png", "jpg", "svg", "mermaid"}
Functions ¶
This section is empty.
Types ¶
type AdditionalComment ¶
type AdditionalComment struct { Table string `yaml:"table"` TableComment string `yaml:"tableComment,omitempty"` ColumnComments map[string]string `yaml:"columnComments,omitempty"` ColumnLabels map[string][]string `yaml:"columnLabels,omitempty"` IndexComments map[string]string `yaml:"indexComments,omitempty"` ConstraintComments map[string]string `yaml:"constraintComments,omitempty"` TriggerComments map[string]string `yaml:"triggerComments,omitempty"` Labels []string `yaml:"labels,omitempty"` }
AdditionalComment is the struct for table relation from yaml
type AdditionalRelation ¶
type AdditionalRelation struct { Table string `yaml:"table"` Columns []string `yaml:"columns"` Cardinality string `yaml:"cardinality,omitempty"` ParentTable string `yaml:"parentTable"` ParentColumns []string `yaml:"parentColumns"` ParentCardinality string `yaml:"parentCardinality,omitempty"` Def string `yaml:"def,omitempty"` Override bool `yaml:"override,omitempty"` }
AdditionalRelation is the struct for table relation from yaml
type ColumnCount ¶ added in v1.8.0
type ColumnCount struct { Enabled bool `yaml:"enabled"` Max int `yaml:"max"` Exclude []string `yaml:"exclude"` }
ColumnCount checks table column count
func (ColumnCount) Check ¶ added in v1.8.0
func (r ColumnCount) Check(s *schema.Schema, exclude []string) []RuleWarn
Check table column count
func (ColumnCount) IsEnabled ¶ added in v1.8.0
func (r ColumnCount) IsEnabled() bool
IsEnabled return Rule is enabled or not
type Config ¶
type Config struct { Name string `yaml:"name"` Desc string `yaml:"desc,omitempty"` Labels []string `yaml:"labels,omitempty"` DSN DSN `yaml:"dsn"` // Directory of schema document DocPath string `yaml:"docPath"` Format Format `yaml:"format,omitempty"` ER ER `yaml:"er,omitempty"` Include []string `yaml:"include,omitempty"` Exclude []string `yaml:"exclude,omitempty"` Distance int `yaml:"distance,omitempty"` Lint Lint `yaml:"lint,omitempty"` LintExclude []string `yaml:"lintExclude,omitempty"` Viewpoints []Viewpoint `yaml:"viewpoints,omitempty"` Relations []AdditionalRelation `yaml:"relations,omitempty"` Comments []AdditionalComment `yaml:"comments,omitempty"` Dict dict.Dict `yaml:"dict,omitempty"` Templates Templates `yaml:"templates,omitempty"` DetectVirtualRelations DetectVirtualRelations `yaml:"detectVirtualRelations,omitempty"` BaseUrl string `yaml:"baseUrl,omitempty"` RequiredVersion string `yaml:"requiredVersion,omitempty"` DisableOutputSchema bool `yaml:"disableOutputSchema,omitempty"` MergedDict dict.Dict `yaml:"-"` // Path of config file Path string `yaml:"-"` // contains filtered or unexported fields }
Config is tbls config
func (*Config) FilterTables ¶ added in v1.28.0
FilterTables filter tables from schema.Schema using include: and exclude: and includeLabels
func (*Config) LoadConfig ¶ added in v1.37.4
LoadConfig load config from []byte
func (*Config) LoadConfigFile ¶
LoadConfigFile load config file
func (*Config) LoadEnviron ¶ added in v1.9.0
LoadEnviron load environment variables
func (*Config) LoadOption ¶ added in v1.40.0
LoadOptions load options
func (*Config) MergeAdditionalData ¶ added in v1.8.0
MergeAdditionalData merge relations: comments: to schema.Schema
func (*Config) ModifySchema ¶ added in v1.12.0
ModifySchema modify schema.Schema by config
func (*Config) NeedToGenerateERImages ¶ added in v1.59.0
func (*Config) SchemaFilePath ¶ added in v1.57.0
type DSN ¶ added in v1.10.0
func (DSN) MarshalYAML ¶ added in v1.29.3
func (*DSN) UnmarshalYAML ¶ added in v1.29.3
type DetectVirtualRelations ¶ added in v1.45.0
type Dot ¶ added in v1.44.0
Dot holds the paths to the dot template files. If populated the files are used to override the default ones.
type DuplicateRelations ¶ added in v1.19.0
type DuplicateRelations struct {
Enabled bool `yaml:"enabled"`
}
DuplicateRelations checks duplicate table relations
func (DuplicateRelations) Check ¶ added in v1.19.0
func (r DuplicateRelations) Check(s *schema.Schema, exclude []string) []RuleWarn
Check duplicate table relations
func (DuplicateRelations) IsEnabled ¶ added in v1.19.0
func (r DuplicateRelations) IsEnabled() bool
IsEnabled return Rule is enabled or not
type ER ¶ added in v1.10.0
type ER struct { Skip bool `yaml:"skip,omitempty"` Format string `yaml:"format,omitempty"` Comment bool `yaml:"comment,omitempty"` HideDef bool `yaml:"hideDef,omitempty"` ShowColumnTypes *ShowColumnTypes `yaml:"showColumnTypes,omitempty"` Distance *int `yaml:"distance,omitempty"` Font string `yaml:"font,omitempty"` }
ER is er setting
type Format ¶ added in v1.10.0
type Format struct { Adjust bool `yaml:"adjust,omitempty"` Sort bool `yaml:"sort,omitempty"` Number bool `yaml:"number,omitempty"` ShowOnlyFirstParagraph bool `yaml:"showOnlyFirstParagraph,omitempty"` HideColumnsWithoutValues []string `yaml:"hideColumnsWithoutValues,omitempty"` }
Format is document format setting
func (Format) MarshalYAML ¶ added in v1.56.0
func (*Format) UnmarshalYAML ¶ added in v1.56.0
type LabelStyleBigQuery ¶ added in v1.32.0
LabelStyleBigQuery checks if labels are in BigQuery style ( https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements )
func (LabelStyleBigQuery) Check ¶ added in v1.32.0
func (r LabelStyleBigQuery) Check(s *schema.Schema, exclude []string) []RuleWarn
Check if labels are in BigQuery style
func (LabelStyleBigQuery) IsEnabled ¶ added in v1.32.0
func (r LabelStyleBigQuery) IsEnabled() bool
IsEnabled return Rule is enabled or not
type Lint ¶ added in v1.8.0
type Lint struct { RequireTableComment RequireTableComment `yaml:"requireTableComment"` RequireColumnComment RequireColumnComment `yaml:"requireColumnComment"` RequireIndexComment RequireIndexComment `yaml:"requireIndexComment"` RequireConstraintComment RequireConstraintComment `yaml:"requireConstraintComment"` RequireTriggerComment RequireTriggerComment `yaml:"requireTriggerComment"` RequireTableLabels RequireTableLabels `yaml:"requireTableLabels"` ColumnCount ColumnCount `yaml:"columnCount"` RequireColumns RequireColumns `yaml:"requireColumns"` DuplicateRelations DuplicateRelations `yaml:"duplicateRelations"` RequireForeignKeyIndex RequireForeignKeyIndex `yaml:"requireForeignKeyIndex"` LabelStyleBigQuery LabelStyleBigQuery `yaml:"labelStyleBigQuery"` RequireViewpoints RequireViewpoints `yaml:"requireViewpoints"` }
Lint is the struct for lint config
type MD ¶ added in v1.44.0
type MD struct { Index string `yaml:"index,omitempty"` Table string `yaml:"table,omitempty"` Viewpoint string `yaml:"viewpoint,omitempty"` }
MD holds the paths to the markdown template files. If populated the files are used to override the default ones.
type Mermaid ¶ added in v1.59.0
type Mermaid struct { Schema string `yaml:"schema,omitempty"` Table string `yaml:"table,omitempty"` }
Mermaid holds the paths to the Mermaid template files. If populated the files are used to override the default ones.
type NamingStrategy ¶ added in v1.45.0
NamingStrategy represents naming strategies
func SelectNamingStrategy ¶ added in v1.45.0
func SelectNamingStrategy(name string) (*NamingStrategy, error)
SelectNamingStrategy sets the naming strategy
func (*NamingStrategy) ParentColumnName ¶ added in v1.45.0
func (ns *NamingStrategy) ParentColumnName(name string) string
ParentColumnName alters the given name by Column
func (*NamingStrategy) ParentTableName ¶ added in v1.45.0
func (ns *NamingStrategy) ParentTableName(name string) string
ParentTableName alters the given name by Table
type Option ¶ added in v1.10.0
Option function change Config
func IncludeLabels ¶ added in v1.59.0
IncludeLabels return Option set Config.includeLabels
type PUML ¶ added in v1.44.0
PUML holds the paths to the PlantUML template files. If populated the files are used to override the default ones.
type RequireColumnComment ¶ added in v1.8.0
type RequireColumnComment struct { Enabled bool `yaml:"enabled"` AllOrNothing bool `yaml:"allOrNothing"` Exclude []string `yaml:"exclude"` ExcludeTables []string `yaml:"excludeTables"` }
RequireColumnComment checks column comment
func (RequireColumnComment) Check ¶ added in v1.8.0
func (r RequireColumnComment) Check(s *schema.Schema, exclude []string) []RuleWarn
Check column comment
func (RequireColumnComment) IsEnabled ¶ added in v1.8.0
func (r RequireColumnComment) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireColumns ¶ added in v1.12.0
type RequireColumns struct { Enabled bool `yaml:"enabled"` Columns []RequireColumnsColumn `yaml:"columns"` }
RequireColumns checks if the table has specified columns
func (RequireColumns) Check ¶ added in v1.12.0
func (r RequireColumns) Check(s *schema.Schema, exclude []string) []RuleWarn
Check the existence of a table columns
func (RequireColumns) IsEnabled ¶ added in v1.12.0
func (r RequireColumns) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireColumnsColumn ¶ added in v1.12.0
RequireColumnsColumn is required column
type RequireConstraintComment ¶ added in v1.37.0
type RequireConstraintComment struct { Enabled bool `yaml:"enabled"` AllOrNothing bool `yaml:"allOrNothing"` Exclude []string `yaml:"exclude"` ExcludeTables []string `yaml:"excludeTables"` }
RequireConstraintComment checks constraint comment
func (RequireConstraintComment) Check ¶ added in v1.37.0
func (r RequireConstraintComment) Check(s *schema.Schema, exclude []string) []RuleWarn
Check constraint comment
func (RequireConstraintComment) IsEnabled ¶ added in v1.37.0
func (r RequireConstraintComment) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireForeignKeyIndex ¶ added in v1.20.0
type RequireForeignKeyIndex struct { Enabled bool `yaml:"enabled"` Exclude []string `yaml:"exclude"` }
RequireForeignKeyIndex checks if the foreign key columns have an index
func (RequireForeignKeyIndex) Check ¶ added in v1.20.0
func (r RequireForeignKeyIndex) Check(s *schema.Schema, exclude []string) []RuleWarn
Check if the foreign key columns have an index
func (RequireForeignKeyIndex) IsEnabled ¶ added in v1.20.0
func (r RequireForeignKeyIndex) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireIndexComment ¶ added in v1.37.0
type RequireIndexComment struct { Enabled bool `yaml:"enabled"` AllOrNothing bool `yaml:"allOrNothing"` Exclude []string `yaml:"exclude"` ExcludeTables []string `yaml:"excludeTables"` }
RequireIndexComment checks index comment
func (RequireIndexComment) Check ¶ added in v1.37.0
func (r RequireIndexComment) Check(s *schema.Schema, exclude []string) []RuleWarn
Check index comment
func (RequireIndexComment) IsEnabled ¶ added in v1.37.0
func (r RequireIndexComment) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireTableComment ¶ added in v1.8.0
type RequireTableComment struct { Enabled bool `yaml:"enabled"` AllOrNothing bool `yaml:"allOrNothing"` Exclude []string `yaml:"exclude"` }
RequireTableComment checks table comment
func (RequireTableComment) Check ¶ added in v1.8.0
func (r RequireTableComment) Check(s *schema.Schema, exclude []string) []RuleWarn
Check table comment
func (RequireTableComment) IsEnabled ¶ added in v1.8.0
func (r RequireTableComment) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireTableLabels ¶ added in v1.65.0
type RequireTableLabels struct { Enabled bool `yaml:"enabled"` AllOrNothing bool `yaml:"allOrNothing"` Exclude []string `yaml:"exclude"` }
RequireTableLabels checks table labels
func (RequireTableLabels) Check ¶ added in v1.65.0
func (r RequireTableLabels) Check(s *schema.Schema, exclude []string) []RuleWarn
Check table labels
func (RequireTableLabels) IsEnabled ¶ added in v1.65.0
func (r RequireTableLabels) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireTriggerComment ¶ added in v1.37.0
type RequireTriggerComment struct { Enabled bool `yaml:"enabled"` AllOrNothing bool `yaml:"allOrNothing"` Exclude []string `yaml:"exclude"` ExcludeTables []string `yaml:"excludeTables"` }
RequireTriggerComment checks trigger comment
func (RequireTriggerComment) Check ¶ added in v1.37.0
func (r RequireTriggerComment) Check(s *schema.Schema, exclude []string) []RuleWarn
Check trigger comment
func (RequireTriggerComment) IsEnabled ¶ added in v1.37.0
func (r RequireTriggerComment) IsEnabled() bool
IsEnabled return Rule is enabled or not
type RequireViewpoints ¶ added in v1.70.0
RequireViewpoints checks if the table is included in any viewpoints.
func (RequireViewpoints) Check ¶ added in v1.70.0
func (r RequireViewpoints) Check(s *schema.Schema, exclude []string) []RuleWarn
Check if the table is included in any viewpoints.
func (RequireViewpoints) IsEnabled ¶ added in v1.70.0
func (r RequireViewpoints) IsEnabled() bool
IsEnabled return Rule is enabled or not
type ShowColumnTypes ¶ added in v1.62.0
type ShowColumnTypes struct { Related bool `yaml:"related,omitempty"` Primary bool `yaml:"primary,omitempty"` }
ShowColumnTypes is show column setting for ER diagram
type Templates ¶ added in v1.44.0
type Templates struct { MD MD `yaml:"md,omitempty"` Dot Dot `yaml:"dot,omitempty"` PUML PUML `yaml:"puml,omitempty"` Mermaid Mermaid `yaml:"mermaid,omitempty"` }
Templates holds the configurations to override the default templates used to render the schema and the docs.
type UnrelatedTable ¶ added in v1.8.2
type UnrelatedTable struct {}
UnrelatedTable checks isolated table
func (UnrelatedTable) Check ¶ added in v1.8.2
func (r UnrelatedTable) Check(s *schema.Schema, exclude []string) []RuleWarn
Check table relation
func (UnrelatedTable) IsEnabled ¶ added in v1.8.2
func (r UnrelatedTable) IsEnabled() bool
IsEnabled return Rule is enabled or not