migration

package
v1.0.0-rc.59 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpTableJSON added in v0.35.0

func DumpTableJSON(db *gorm.DB, tableName, outDir string, schemaFromVer, schemaToVer int) (string, error)

DumpTableJSON snapshots an entire DB table to a JSON file under outDir. Filename format: {tableName}_v{schemaFromVer}_to_v{schemaToVer}_{ts}.json outDir is created if it does not exist. Returns the absolute path of the written file. Reads via SELECT * with []map[string]any to remain decoupled from concrete model structs.

Types

type BackupData

type BackupData struct {
	Version   string                   `json:"version"`
	CreatedAt time.Time                `json:"created_at"`
	Global    models.SettingsGlobal    `json:"global"`
	Qbit      models.QbitSettings      `json:"qbit"`
	Sites     []models.SiteSetting     `json:"sites"`
	RSS       []models.RSSSubscription `json:"rss"`
}

BackupData 备份数据结构

type MigrationResult

type MigrationResult struct {
	Success             bool      `json:"success"`
	Message             string    `json:"message"`
	BackupPath          string    `json:"backup_path,omitempty"`
	MigratedAt          time.Time `json:"migrated_at"`
	DownloadersMigrated int       `json:"downloaders_migrated"`
	SitesMigrated       int       `json:"sites_migrated"`
	Errors              []string  `json:"errors,omitempty"`
}

MigrationResult 迁移结果

type MigrationService

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

MigrationService 配置迁移服务

func NewMigrationService

func NewMigrationService(db *gorm.DB) *MigrationService

NewMigrationService 创建迁移服务

func NewMigrationServiceWithBackupDir

func NewMigrationServiceWithBackupDir(db *gorm.DB, backupDir string) *MigrationService

NewMigrationServiceWithBackupDir 创建迁移服务(指定备份目录)

func (*MigrationService) CreateBackup

func (m *MigrationService) CreateBackup() (string, error)

CreateBackup 创建配置备份

func (*MigrationService) GetMigrationStatus

func (m *MigrationService) GetMigrationStatus() *MigrationStatus

func (*MigrationService) IsMigrationNeeded

func (m *MigrationService) IsMigrationNeeded() bool

IsMigrationNeeded 检查是否需要迁移

func (*MigrationService) MigrateV1ToV2

func (m *MigrationService) MigrateV1ToV2() *MigrationResult

MigrateV1ToV2 执行v1到v2的迁移

func (*MigrationService) RestoreBackup

func (m *MigrationService) RestoreBackup(backupPath string) error

RestoreBackup 从备份恢复

type MigrationStatus

type MigrationStatus struct {
	NeedsMigration    bool `json:"needs_migration"`
	HasOldQbitConfig  bool `json:"has_old_qbit_config"`
	HasNewDownloaders bool `json:"has_new_downloaders"`
	SitesCount        int  `json:"sites_count"`
}

GetMigrationStatus 获取迁移状态

Jump to

Keyboard shortcuts

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