migration

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 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

View Source
const EpDbPassword = "EP_DB_PASSWORD" // environment variable for the database password

Variables

This section is empty.

Functions

func RunFromCLI

func RunFromCLI(logger *zap.SugaredLogger, args []string)

Types

type Author

type Author struct {
	Id        string         `json:"-"`
	ColorId   int            `json:"colorId"`
	Name      string         `json:"name"`
	Timestamp int64          `json:"timestamp"`
	PadIDs    map[string]int `json:"padIDs"`
}

type Author2Sessions

type Author2Sessions struct {
	AuthorId string
	Sessions map[string]int
}

type ChatMessage

type ChatMessage struct {
	PadId     string `json:"-"`
	ChatNum   int    `json:"-"`
	Text      string `json:"text"`
	AuthorId  string `json:"authorId"`
	Timestamp int64  `json:"time"`
}

type Database

type Database interface {
	// Pads
	GetNextPads(lastPadId string, limit int) ([]Pad, error)
	GetPadRevisions(padId string, lastRev int, limit int) ([]PadRevision, error)

	// Authors
	GetNextAuthors(lastAuthorId string, limit int) ([]Author, error)

	// Readonly mappings
	GetNextReadonly2Pad(lastReadonlyId string, limit int) ([]Readonly2Pad, error)
	GetNextPad2Readonly(lastPadId string, limit int) ([]Pad2Readonly, error)

	// Token to Author mappings
	GetNextToken2Author(lastToken string, limit int) ([]Token2Author, error)

	// Chat messages
	GetPadChatMessages(padId string, lastChatNum int, limit int) ([]ChatMessage, error)

	// Groups
	GetNextGroups(lastGroupId string, limit int) ([]Group, error)
	GetNextGroup2Sessions(lastGroupId string, limit int) ([]Group2Sessions, error)
	GetNextAuthor2Sessions(lastAuthorId string, limit int) ([]Author2Sessions, error)
	GetNextSessions(lastSessionId string, limit int) ([]Session, error)

	// Utility
	Close() error
}

type DriverType

type DriverType int
const (
	DriverSQLite DriverType = iota
	DriverPostgres
	DriverMySQL
)

type Group

type Group struct {
	GroupId string         `json:"-"`
	Pads    map[string]int `json:"pads"`
}

type Group2Sessions

type Group2Sessions struct {
	GroupId  string
	Sessions map[string]int
}

type Migrator

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

func NewMigrator

func NewMigrator(oldEtherpadDB *SQLDatabase, newDataStore db.DataStore, logger *zap.SugaredLogger) *Migrator

func (*Migrator) MigrateAuthors

func (m *Migrator) MigrateAuthors() error

func (*Migrator) MigratePad2Readonly

func (m *Migrator) MigratePad2Readonly() error

func (*Migrator) MigratePadChats

func (m *Migrator) MigratePadChats() error

func (*Migrator) MigratePads

func (m *Migrator) MigratePads() error

func (*Migrator) MigrateRevisions

func (m *Migrator) MigrateRevisions() error

func (*Migrator) MigrateToken2Author

func (m *Migrator) MigrateToken2Author() error

type Pad

type Pad struct {
	PadId string `json:"-"`
	AText struct {
		Text    string `json:"text"`
		Attribs string `json:"attribs"`
	} `json:"atext"`
	Pool struct {
		NumToAttrib map[string][]string `json:"numToAttrib"`
		NextNum     int                 `json:"nextNum"`
	} `json:"pool"`
	Head           int  `json:"head"`
	ChatHead       int  `json:"chatHead"`
	PublicStatus   bool `json:"publicStatus"`
	SavedRevisions []struct {
		RevNum    int    `json:"revNum"`
		Timestamp int64  `json:"timestamp"`
		SavedById string `json:"savedById"`
		Label     string `json:"label"`
		Id        string `json:"id"`
	} `json:"savedRevisions"`
}

type Pad2Readonly

type Pad2Readonly struct {
	PadId      string
	ReadonlyId string
}

type PadRevision

type PadRevision struct {
	PadRevisionId string `json:"-"`
	RevNum        int    `json:"-"`
	Changeset     string `json:"changeset"`
	Meta          struct {
		Author    string `json:"author"`
		Timestamp int64  `json:"timestamp"`
		Pool      struct {
			NumToAttrib map[string][]string `json:"numToAttrib"`
			AttribToNum map[string]int      `json:"attribToNum"`
			NextNum     int                 `json:"nextNum"`
		} `json:"pool"`
		Atext struct {
			Text    string `json:"text"`
			Attribs string `json:"attribs"`
		} `json:"atext"`
	} `json:"meta"`
}

type Readonly2Pad

type Readonly2Pad struct {
	ReadonlyId string
	PadId      string
}

type SQLDatabase

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

SQLDatabase implements the Database interface for SQL-based Etherpad stores

func NewDB

func NewDB(dsn string, dbType string) (*SQLDatabase, error)

func NewMySQLDatabase

func NewMySQLDatabase(dsn string) (*SQLDatabase, error)

NewMySQLDatabase creates a MySQL-backed database

func NewPostgresDatabase

func NewPostgresDatabase(dsn string) (*SQLDatabase, error)

NewPostgresDatabase creates a PostgreSQL-backed database

func NewSQLDatabase

func NewSQLDatabase(db *sql.DB, driver DriverType) (*SQLDatabase, error)

NewSQLDatabase creates a new SQLDatabase with the appropriate settings

func NewSQLiteDatabase

func NewSQLiteDatabase(dsn string) (*SQLDatabase, error)

func (*SQLDatabase) Close

func (s *SQLDatabase) Close() error

func (*SQLDatabase) GetNextAuthor2Sessions

func (s *SQLDatabase) GetNextAuthor2Sessions(
	lastAuthorId string,
	limit int,
) ([]Author2Sessions, error)

func (*SQLDatabase) GetNextAuthors

func (s *SQLDatabase) GetNextAuthors(lastAuthorId string, limit int) ([]Author, error)

func (*SQLDatabase) GetNextGroup2Sessions

func (s *SQLDatabase) GetNextGroup2Sessions(
	lastGroupId string,
	limit int,
) ([]Group2Sessions, error)

func (*SQLDatabase) GetNextGroups

func (s *SQLDatabase) GetNextGroups(lastGroupId string, limit int) ([]Group, error)

func (*SQLDatabase) GetNextPad2Readonly

func (s *SQLDatabase) GetNextPad2Readonly(lastPadId string, limit int) ([]Pad2Readonly, error)

func (*SQLDatabase) GetNextPads

func (s *SQLDatabase) GetNextPads(lastPadId string, limit int) ([]Pad, error)

func (*SQLDatabase) GetNextReadonly2Pad

func (s *SQLDatabase) GetNextReadonly2Pad(
	lastReadonlyId string,
	limit int,
) ([]Readonly2Pad, error)

func (*SQLDatabase) GetNextSessions

func (s *SQLDatabase) GetNextSessions(lastSessionId string, limit int) ([]Session, error)

func (*SQLDatabase) GetNextToken2Author

func (s *SQLDatabase) GetNextToken2Author(lastToken string, limit int) ([]Token2Author, error)

func (*SQLDatabase) GetPadChatMessages

func (s *SQLDatabase) GetPadChatMessages(
	padId string,
	lastChatNum int,
	limit int,
) ([]ChatMessage, error)

func (*SQLDatabase) GetPadRevisions

func (s *SQLDatabase) GetPadRevisions(
	padId string,
	lastRev int,
	limit int,
) ([]PadRevision, error)

type Session

type Session struct {
	SessionId  string `json:"-"`
	GroupId    string `json:"groupID"`
	AuthorId   string `json:"authorID"`
	ValidUntil int64  `json:"validUntil"`
}

type Token2Author

type Token2Author struct {
	Token    string
	AuthorId string
}

Jump to

Keyboard shortcuts

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