Documentation
¶
Overview ¶
Package generator provides migration and seeder file generation using Go text/template and embedded template files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseModulePath ¶
ParseModulePath reads a go.mod file and extracts the module path from the module directive. It returns an error if the file cannot be read or the module directive is missing or malformed.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates migration and seeder files from templates.
func NewGenerator ¶
NewGenerator creates a new Generator that writes files to outputDir.
func (*Generator) Factory ¶
Factory generates a factory file and returns the full filepath. The filename follows the pattern description_factory.go.
func (*Generator) Migration ¶
func (g *Generator) Migration(description string, opts MigrationOptions) (string, error)
Migration generates a migration file and returns the full filepath. The filename follows the pattern YYYY_MM_DD_HHMMSS_RRRR_description.go. The opts parameter controls whether the template includes pre-populated Schema_Builder calls for --create or --table flags.
type InitResult ¶
InitResult summarizes what the scaffolder created or skipped.
type InitScaffolder ¶
type InitScaffolder struct {
// contains filtered or unexported fields
}
InitScaffolder handles all file system operations for the init command.
func NewInitScaffolder ¶
func NewInitScaffolder(baseDir, modulePath string, force bool, stdout, stderr io.Writer) *InitScaffolder
NewInitScaffolder creates a new InitScaffolder with the given configuration.
func (*InitScaffolder) Scaffold ¶
func (s *InitScaffolder) Scaffold() (*InitResult, error)
Scaffold creates the project directory structure and generated files. It returns an InitResult summarizing what was created or skipped.
type MigrationOptions ¶
type MigrationOptions struct {
// CreateTable pre-populates Up() with a Schema_Builder Create call.
CreateTable string
// AlterTable pre-populates Up() with a Schema_Builder Alter call.
AlterTable string
}
MigrationOptions configures optional flags for migration generation.