Documentation
¶
Overview ¶
Package types defines shared types for the migrator module. This package is separate to avoid import cycles between migrator and source implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigField ¶
type ConfigField struct {
Name string // Field name (form key)
Label string // Display label
Type string // Field type: "text", "password", "number", "path"
Required bool // Whether the field is required
Default string // Default value
Placeholder string // Placeholder text
}
ConfigField represents a configuration field for a migration source.
type ImportOptions ¶
type ImportOptions struct {
ImportTags bool
ImportMedia bool
ImportPosts bool
ImportPages bool
ImportUsers bool
SkipExisting bool
}
ImportOptions contains options for the import operation.
type ImportResult ¶
type ImportResult struct {
TagsImported int
MediaImported int
PostsImported int
PagesImported int
UsersImported int
TagsSkipped int
MediaSkipped int
PostsSkipped int
PagesSkipped int
UsersSkipped int
Errors []string
}
ImportResult contains the results of an import operation.
func (*ImportResult) HasErrors ¶
func (r *ImportResult) HasErrors() bool
HasErrors returns true if there were any errors during import.
func (*ImportResult) TotalImported ¶
func (r *ImportResult) TotalImported() int
TotalImported returns the total number of items imported.
func (*ImportResult) TotalSkipped ¶
func (r *ImportResult) TotalSkipped() int
TotalSkipped returns the total number of items skipped.
type ImportTracker ¶
type ImportTracker interface {
// TrackImportedItem records an imported item.
TrackImportedItem(ctx context.Context, source, entityType string, entityID int64) error
}
ImportTracker tracks imported items for later deletion.
type Source ¶
type Source interface {
// Name returns the unique identifier for this source (e.g., "elefant", "drupal").
Name() string
// DisplayName returns the human-readable name for the UI.
DisplayName() string
// Description returns a brief description of what this source imports.
Description() string
// ConfigFields returns the configuration fields needed for this source.
ConfigFields() []ConfigField
// TestConnection tests the connection using the provided configuration.
TestConnection(cfg map[string]string) error
// Import performs the actual import using the provided configuration and options.
// The tracker can be used to record imported items for later deletion.
Import(ctx context.Context, db *sql.DB, cfg map[string]string, opts ImportOptions, tracker ImportTracker) (*ImportResult, error)
}
Source defines the interface that all migration sources must implement.