Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Field ¶
type Field struct { Name string `json:"name,omitempty"` Type Type `json:"type,omitempty"` Default string `json:"default,omitempty"` IsPrimary bool `json:"is_primary,omitempty"` IsSequence bool `json:"is_sequence,omitempty"` }
Field is a column, index, enum value, or stored procedure parameter.
type ForeignKey ¶
type ForeignKey struct { Name string `json:"name,omitempty"` Fields []Field `json:"column,omitempty"` // column that has the key on it RefTable string `json:"ref_table,omitempty"` // table the foreign key refers to RefFields []Field `json:"ref_column,omitempty"` // column in ref table the index refers to }
ForeignKey is a foreign key.
type Index ¶
type Index struct { Name string `json:"name,omitempty"` Fields []Field `json:"fields,omitempty"` IsUnique bool `json:"is_unique,omitempty"` IsPrimary bool `json:"is_primary,omitempty"` }
Index is a index.
type Schema ¶
type Schema struct { Name string `json:"name,omitempty"` Enums []Enum `json:"enums,omitempty"` Tables []Table `json:"tables,omitempty"` }
Schema is the intermediate schema.
type Table ¶
type Table struct { Name string `json:"name,omitempty"` Columns []Field `json:"columns,omitempty"` PrimaryKeys []Field `json:"primary_keys,omitempty"` Indexes []Index `json:"indexes,omitempty"` ForeignKeys []ForeignKey `json:"foreign_keys,omitempty"` }
func NewRefTable ¶
NewRefTable creates a reference table with the specified name, mapping from leftTable to rightTable. Indexes and foreign keys are automatically created.
leftCol is used as the name of the left column and rightCol is used as the name of the right column. It is assumed that both columns refer to the id column of leftTable and rightTable.
Click to show internal directories.
Click to hide internal directories.