migration

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateFile

func MigrateFile(filePath, basePath string, options MigrationOptions, output io.Writer) error

Types

type Analyzer

type Analyzer struct {
	// contains filtered or unexported fields
}

func NewAnalyzer

func NewAnalyzer(basePath string) *Analyzer

func (*Analyzer) AnalyzeNote

func (a *Analyzer) AnalyzeNote(filePath string) ([]MigrationIssue, error)

type MigrationIssue

type MigrationIssue struct {
	Type        string
	Description string
	Field       string
	Current     interface{}
	Expected    interface{}
}

func AnalyzeFile

func AnalyzeFile(filePath, basePath string) ([]MigrationIssue, error)

type MigrationOptions

type MigrationOptions struct {
	Scope      MigrationScope
	DryRun     bool
	Verbose    bool
	ShowReport bool
	NoBackup   bool
}

type MigrationReport

type MigrationReport struct {
	TotalFiles       int
	ProcessedFiles   int
	MigratedFiles    int
	SkippedFiles     int
	FailedFiles      int
	CreatedFiles     int
	DeletedFiles     int
	IssuesFixed      int
	Errors           []string
	ProcessingErrors map[string]error
	StartTime        time.Time
	EndTime          time.Time
}

func EnsureTypeInTags

func EnsureTypeInTags(notebookRoot string, options MigrationOptions, output io.Writer) (*MigrationReport, error)

EnsureTypeInTags scans all notes in a notebook and ensures their note type is present in the tags array, matching the behavior of new note creation. Also handles converting "current" type to "inbox".

func Migrate

func Migrate(basePath string, options MigrationOptions, output io.Writer, logger *logrus.Entry) (*MigrationReport, error)

func MigrateWorkspaces

func MigrateWorkspaces(sourceNotebookRoot, targetNotebookRoot string, renames map[string]string, options MigrationOptions, output io.Writer) (*MigrationReport, error)

MigrateWorkspaces copies all files from old workspace names to new ones within notebooks, updating frontmatter fields like 'repository' and 'tags' for markdown files. Non-markdown files (logs, xml, yaml, etc.) are copied as-is.

func NewMigrationReport

func NewMigrationReport() *MigrationReport

func RenameCurrentToInbox

func RenameCurrentToInbox(notebookRoot string, options MigrationOptions, output io.Writer) (*MigrationReport, error)

RenameCurrentToInbox scans a notebook for directories named "current" and renames them to "inbox", updating the frontmatter of notes within.

func (*MigrationReport) Add

func (r *MigrationReport) Add(other *MigrationReport)

Add merges another report's stats into this one.

func (*MigrationReport) AddError

func (r *MigrationReport) AddError(file string, err error)

func (*MigrationReport) Complete

func (r *MigrationReport) Complete()

func (*MigrationReport) Duration

func (r *MigrationReport) Duration() time.Duration

type MigrationScope

type MigrationScope struct {
	Context   string
	Global    bool
	Workspace string
	All       bool
}

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(options MigrationOptions, basePath string, output io.Writer, logger *logrus.Entry) *Migrator

func (*Migrator) Complete

func (m *Migrator) Complete()

func (*Migrator) GetReport

func (m *Migrator) GetReport() *MigrationReport

func (*Migrator) MigrateFile

func (m *Migrator) MigrateFile(filePath string) error

type StructuralMigration

type StructuralMigration struct {
	// contains filtered or unexported fields
}

StructuralMigration performs migration from old repos/{workspace}/{branch} structure to new notebooks/{workspace}/notes/{noteType} structure

func NewStructuralMigration

func NewStructuralMigration(sourcePath, targetPath, globalRoot string, locator *coreworkspace.NotebookLocator,
	provider *coreworkspace.Provider, options MigrationOptions, isCopyOnly bool, output io.Writer) *StructuralMigration

NewStructuralMigration creates a new structural migration instance

func (*StructuralMigration) GetReport

func (sm *StructuralMigration) GetReport() *MigrationReport

GetReport returns the migration report

func (*StructuralMigration) MigrateStructure

func (sm *StructuralMigration) MigrateStructure() error

MigrateStructure performs the structural migration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL