Documentation
¶
Index ¶
- func FindComplexJunctionTables(allTables *TableRegistry, junctionTables map[string]*JunctionInfo) map[string]string
- func FindJunctionTables(allTables *TableRegistry) map[string]*JunctionInfo
- func GenerateModel(buf *bytes.Buffer, info *TableInfo, junctionTables map[string]*JunctionInfo, ...) error
- func MapSQLTypeToGo(sqlType string, driver string) string
- func TrimShortPrefix(name, prefix string) string
- func UnquoteWord(word string) string
- type ColumnInfo
- type ForeignKeyInfo
- type IndexInfo
- type JunctionInfo
- type O2MField
- type PrimaryKeyInfo
- type ReverseConfig
- type ReverseEngineer
- type SQLTemplates
- type TableInfo
- type TableRegistry
- type TableRelationshipInfo
- type TableType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindComplexJunctionTables ¶
func FindComplexJunctionTables(allTables *TableRegistry, junctionTables map[string]*JunctionInfo) map[string]string
FindComplexJunctionTables identifies complex junction tables (junction tables with additional fields)
func FindJunctionTables ¶
func FindJunctionTables(allTables *TableRegistry) map[string]*JunctionInfo
FindJunctionTables identifies junction tables (m2m relationship tables) A junction table must have exactly 2 foreign keys and only primary keys + bool columns Bool columns are identified by names starting with "Is" (e.g., IsActive)
func GenerateModel ¶
func GenerateModel(buf *bytes.Buffer, info *TableInfo, junctionTables map[string]*JunctionInfo, complexJunctionTables map[string]string, driverType, prefix string) error
GenerateModel generates Go struct code for a table
func MapSQLTypeToGo ¶
MapSQLTypeToGo maps SQL data types to Go types
func TrimShortPrefix ¶
TrimShortPrefix trims the short prefix from the name if it exists.
func UnquoteWord ¶
UnquoteWord removes quotes from a word if it is quoted.
Types ¶
type ColumnInfo ¶
type ColumnInfo struct {
Name string
DataType string
IsNullable bool
IsPrimaryKey bool
IsUnique bool
IsIndex bool
DefaultValue *string
}
ColumnInfo represents database column metadata
type ForeignKeyInfo ¶
type ForeignKeyInfo struct {
Name string
Columns []string
ReferencedTable string
ReferencedColumns []string
IsUnique bool
}
ForeignKeyInfo represents foreign key metadata
type JunctionInfo ¶
JunctionInfo represents a junction table for m2m relationships
type PrimaryKeyInfo ¶
PrimaryKeyInfo represents primary key metadata
type ReverseConfig ¶
type ReverseConfig struct {
DriverType string
DatabaseDSN string
SchemaName string
TablePrefix string
}
func (*ReverseConfig) FixConfigData ¶
func (rc *ReverseConfig) FixConfigData()
type ReverseEngineer ¶
type ReverseEngineer struct {
Config *ReverseConfig
// contains filtered or unexported fields
}
ReverseEngineer implements database reverse engineering
func NewPgsqlReverseEngineer ¶
func NewPgsqlReverseEngineer(dsn, schema string) (*ReverseEngineer, error)
NewPgsqlReverseEngineer creates a new PostgreSQL reverse engineer
func NewSqliteReverseEngineer ¶
func NewSqliteReverseEngineer(dsn string) (*ReverseEngineer, error)
NewSqliteReverseEngineer creates a new SQLite reverse engineer
func (*ReverseEngineer) Close ¶
func (r *ReverseEngineer) Close()
Close closes the database connection
func (*ReverseEngineer) GetDatabaseConfig ¶
func (r *ReverseEngineer) GetDatabaseConfig() *model.DatabaseConfig
func (*ReverseEngineer) GetTableInfo ¶
func (r *ReverseEngineer) GetTableInfo(tableName string) (*TableInfo, error)
GetTableInfo returns detailed information about a table
type SQLTemplates ¶
type SQLTemplates struct {
GetTables string
GetColumns string
GetPrimaryKey string
GetForeignKeys string
GetIndexes string
}
SQLTemplates holds database-specific SQL queries
type TableInfo ¶
type TableInfo struct {
Schema string
Name string
Columns []*ColumnInfo
PrimaryKey *PrimaryKeyInfo
ForeignKeys []*ForeignKeyInfo
Indexes []*IndexInfo
}
TableInfo represents database table metadata