{"modulePath":"github.com/RedAFD/code-core","version":"v1.14.0-rc8","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package migrations\n\n## Variables\n\n```go\nvar (\n\t// ErrRepoNotCreated returns the error that repository not created\n\tErrRepoNotCreated = errors.New(\"repository is not created yet\")\n)\n```\n\n```go\nvar (\n\n\t// GithubLimitRateRemaining limit to wait for new rate to apply\n\tGithubLimitRateRemaining = 0\n)\n```\n\n## Functions\n\n```go\nfunc DumpRepository(ctx context.Context, baseDir, ownerName string, opts base.MigrateOptions) error\n```\nDumpRepository dump repository according MigrateOptions to a local directory\n\n```go\nfunc Init() error\n```\nInit migrations service\n\n```go\nfunc IsMigrateURLAllowed(remoteURL string, doer *models.User) error\n```\nIsMigrateURLAllowed checks if an URL is allowed to be migrated from\n\n```go\nfunc IsRateLimitError(err error) bool\n```\nIsRateLimitError returns true if the err is github.RateLimitError\n\n```go\nfunc IsTwoFactorAuthError(err error) bool\n```\nIsTwoFactorAuthError returns true if the err is github.TwoFactorAuthError\n\n```go\nfunc MigrateRepository(ctx context.Context, doer *models.User, ownerName string, opts base.MigrateOptions) (*models.Repository, error)\n```\nMigrateRepository migrate repository according MigrateOptions\n\n```go\nfunc RegisterDownloaderFactory(factory base.DownloaderFactory)\n```\nRegisterDownloaderFactory registers a downloader factory\n\n```go\nfunc RestoreRepository(ctx context.Context, baseDir string, ownerName, repoName string) error\n```\nRestoreRepository restore a repository from the disk directory\n\n```go\nfunc UpdateMigrationPosterID(ctx context.Context) error\n```\nUpdateMigrationPosterID updates all migrated repositories' issues and comments posterID\n\n## Types\n\n```go\ntype GiteaDownloader struct {\n\tbase.NullDownloader\n\t// contains filtered or unexported fields\n}\n```\nGiteaDownloader implements a Downloader interface to get repository information's\n\n```go\nfunc NewGiteaDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GiteaDownloader, error)\n```\nNewGiteaDownloader creates a gitea Downloader via gitea API\n\n\tUse either a username/password or personal token. token is preferred\n\tNote: Public access only allows very basic access\n\n```go\nfunc (g *GiteaDownloader) GetComments(index int64) ([]*base.Comment, error)\n```\nGetComments returns comments according issueNumber\n\n```go\nfunc (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, error)\n```\nGetIssues returns issues according start and limit\n\n```go\nfunc (g *GiteaDownloader) GetLabels() ([]*base.Label, error)\n```\nGetLabels returns labels\n\n```go\nfunc (g *GiteaDownloader) GetMilestones() ([]*base.Milestone, error)\n```\nGetMilestones returns milestones\n\n```go\nfunc (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)\n```\nGetPullRequests returns pull requests according page and perPage\n\n```go\nfunc (g *GiteaDownloader) GetReleases() ([]*base.Release, error)\n```\nGetReleases returns releases\n\n```go\nfunc (g *GiteaDownloader) GetRepoInfo() (*base.Repository, error)\n```\nGetRepoInfo returns a repository information\n\n```go\nfunc (g *GiteaDownloader) GetReviews(index int64) ([]*base.Review, error)\n```\nGetReviews returns pull requests review\n\n```go\nfunc (g *GiteaDownloader) GetTopics() ([]string, error)\n```\nGetTopics return gitea topics\n\n```go\nfunc (g *GiteaDownloader) SetContext(ctx context.Context)\n```\nSetContext set context\n\n```go\ntype GiteaDownloaderFactory struct {\n}\n```\nGiteaDownloaderFactory defines a gitea downloader factory\n\n```go\nfunc (f *GiteaDownloaderFactory) GitServiceType() structs.GitServiceType\n```\nGitServiceType returns the type of git service\n\n```go\nfunc (f *GiteaDownloaderFactory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)\n```\nNew returns a Downloader related to this factory according MigrateOptions\n\n```go\ntype GiteaLocalUploader struct {\n\t// contains filtered or unexported fields\n}\n```\nGiteaLocalUploader implements an Uploader to gitea sites\n\n```go\nfunc NewGiteaLocalUploader(ctx context.Context, doer *models.User, repoOwner, repoName string) *GiteaLocalUploader\n```\nNewGiteaLocalUploader creates an gitea Uploader via gitea API v1\n\n```go\nfunc (g *GiteaLocalUploader) Close()\n```\nClose closes this uploader\n\n```go\nfunc (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error\n```\nCreateComments creates comments of issues\n\n```go\nfunc (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error\n```\nCreateIssues creates issues\n\n```go\nfunc (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error\n```\nCreateLabels creates labels\n\n```go\nfunc (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) error\n```\nCreateMilestones creates milestones\n\n```go\nfunc (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error\n```\nCreatePullRequests creates pull requests\n\n```go\nfunc (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error\n```\nCreateReleases creates releases\n\n```go\nfunc (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error\n```\nCreateRepo creates a repository\n\n```go\nfunc (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error\n```\nCreateReviews create pull request reviews\n\n```go\nfunc (g *GiteaLocalUploader) CreateTopics(topics ...string) error\n```\nCreateTopics creates topics\n\n```go\nfunc (g *GiteaLocalUploader) Finish() error\n```\nFinish when migrating success, this will do some status update things.\n\n```go\nfunc (g *GiteaLocalUploader) MaxBatchInsertSize(tp string) int\n```\nMaxBatchInsertSize returns the table's max batch insert size\n\n```go\nfunc (g *GiteaLocalUploader) Rollback() error\n```\nRollback when migrating failed, this will rollback all the changes.\n\n```go\nfunc (g *GiteaLocalUploader) SyncTags() error\n```\nSyncTags syncs releases with tags in the database\n\n```go\ntype GithubDownloaderV3 struct {\n\tbase.NullDownloader\n\t// contains filtered or unexported fields\n}\n```\nGithubDownloaderV3 implements a Downloader interface to get repository informations from github via APIv3\n\n```go\nfunc NewGithubDownloaderV3(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GithubDownloaderV3\n```\nNewGithubDownloaderV3 creates a github Downloader via github v3 API\n\n```go\nfunc (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, error)\n```\nGetComments returns comments according issueNumber\n\n```go\nfunc (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool, error)\n```\nGetIssues returns issues according start and limit\n\n```go\nfunc (g *GithubDownloaderV3) GetLabels() ([]*base.Label, error)\n```\nGetLabels returns labels\n\n```go\nfunc (g *GithubDownloaderV3) GetMilestones() ([]*base.Milestone, error)\n```\nGetMilestones returns milestones\n\n```go\nfunc (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)\n```\nGetPullRequests returns pull requests according page and perPage\n\n```go\nfunc (g *GithubDownloaderV3) GetReleases() ([]*base.Release, error)\n```\nGetReleases returns releases\n\n```go\nfunc (g *GithubDownloaderV3) GetRepoInfo() (*base.Repository, error)\n```\nGetRepoInfo returns a repository information\n\n```go\nfunc (g *GithubDownloaderV3) GetReviews(pullRequestNumber int64) ([]*base.Review, error)\n```\nGetReviews returns pull requests review\n\n```go\nfunc (g *GithubDownloaderV3) GetTopics() ([]string, error)\n```\nGetTopics return github topics\n\n```go\nfunc (g *GithubDownloaderV3) RefreshRate() error\n```\nRefreshRate update the current rate (doesn't count in rate limit)\n\n```go\nfunc (g *GithubDownloaderV3) SetContext(ctx context.Context)\n```\nSetContext set context\n\n```go\ntype GithubDownloaderV3Factory struct {\n}\n```\nGithubDownloaderV3Factory defines a github downloader v3 factory\n\n```go\nfunc (f *GithubDownloaderV3Factory) GitServiceType() structs.GitServiceType\n```\nGitServiceType returns the type of git service\n\n```go\nfunc (f *GithubDownloaderV3Factory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)\n```\nNew returns a Downloader related to this factory according MigrateOptions\n\n```go\ntype GitlabDownloader struct {\n\tbase.NullDownloader\n\t// contains filtered or unexported fields\n}\n```\nGitlabDownloader implements a Downloader interface to get repository informations from gitlab via go-gitlab - issueCount is incremented in GetIssues() to ensure PR and Issue numbers do not overlap, because Gitlab has individual Issue and Pull Request numbers. - issueSeen, working alongside issueCount, is checked in GetComments() to see whether we need to fetch the Issue or PR comments, as Gitlab stores them separately.\n\n```go\nfunc NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error)\n```\nNewGitlabDownloader creates a gitlab Downloader via gitlab API\n\n\tUse either a username/password, personal token entered into the username field, or anonymous/public access\n\tNote: Public access only allows very basic access\n\n```go\nfunc (g *GitlabDownloader) GetComments(issueNumber int64) ([]*base.Comment, error)\n```\nGetComments returns comments according issueNumber TODO: figure out how to transfer comment reactions\n\n```go\nfunc (g *GitlabDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, error)\n```\nGetIssues returns issues according start and limit\n\n\tNote: issue label description and colors are not supported by the go-gitlab library at this time\n\n```go\nfunc (g *GitlabDownloader) GetLabels() ([]*base.Label, error)\n```\nGetLabels returns labels\n\n```go\nfunc (g *GitlabDownloader) GetMilestones() ([]*base.Milestone, error)\n```\nGetMilestones returns milestones\n\n```go\nfunc (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)\n```\nGetPullRequests returns pull requests according page and perPage\n\n```go\nfunc (g *GitlabDownloader) GetReleases() ([]*base.Release, error)\n```\nGetReleases returns releases\n\n```go\nfunc (g *GitlabDownloader) GetRepoInfo() (*base.Repository, error)\n```\nGetRepoInfo returns a repository information\n\n```go\nfunc (g *GitlabDownloader) GetReviews(pullRequestNumber int64) ([]*base.Review, error)\n```\nGetReviews returns pull requests review\n\n```go\nfunc (g *GitlabDownloader) GetTopics() ([]string, error)\n```\nGetTopics return gitlab topics\n\n```go\nfunc (g *GitlabDownloader) SetContext(ctx context.Context)\n```\nSetContext set context\n\n```go\ntype GitlabDownloaderFactory struct {\n}\n```\nGitlabDownloaderFactory defines a gitlab downloader factory\n\n```go\nfunc (f *GitlabDownloaderFactory) GitServiceType() structs.GitServiceType\n```\nGitServiceType returns the type of git service\n\n```go\nfunc (f *GitlabDownloaderFactory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)\n```\nNew returns a Downloader related to this factory according MigrateOptions\n\n```go\ntype GogsDownloader struct {\n\tbase.NullDownloader\n\t// contains filtered or unexported fields\n}\n```\nGogsDownloader implements a Downloader interface to get repository informations from gogs via API\n\n```go\nfunc NewGogsDownloader(ctx context.Context, baseURL, userName, password, token, repoOwner, repoName string) *GogsDownloader\n```\nNewGogsDownloader creates a gogs Downloader via gogs API\n\n```go\nfunc (g *GogsDownloader) FormatCloneURL(opts MigrateOptions, remoteAddr string) (string, error)\n```\nFormatCloneURL add authentification into remote URLs\n\n```go\nfunc (g *GogsDownloader) GetComments(issueNumber int64) ([]*base.Comment, error)\n```\nGetComments returns comments according issueNumber\n\n```go\nfunc (g *GogsDownloader) GetIssues(page, _ int) ([]*base.Issue, bool, error)\n```\nGetIssues returns issues according start and limit, perPage is not supported\n\n```go\nfunc (g *GogsDownloader) GetLabels() ([]*base.Label, error)\n```\nGetLabels returns labels\n\n```go\nfunc (g *GogsDownloader) GetMilestones() ([]*base.Milestone, error)\n```\nGetMilestones returns milestones\n\n```go\nfunc (g *GogsDownloader) GetRepoInfo() (*base.Repository, error)\n```\nGetRepoInfo returns a repository information\n\n```go\nfunc (g *GogsDownloader) GetTopics() ([]string, error)\n```\nGetTopics return repository topics\n\n```go\nfunc (g *GogsDownloader) RoundTrip(req *http.Request) (*http.Response, error)\n```\nRoundTrip wraps the provided request within this downloader's context and passes it to our internal http.Transport. This implements http.RoundTripper and makes the gogs client requests cancellable even though it is not cancellable itself\n\n```go\nfunc (g *GogsDownloader) SetContext(ctx context.Context)\n```\nSetContext set context\n\n```go\ntype GogsDownloaderFactory struct {\n}\n```\nGogsDownloaderFactory defines a gogs downloader factory\n\n```go\nfunc (f *GogsDownloaderFactory) GitServiceType() structs.GitServiceType\n```\nGitServiceType returns the type of git service\n\n```go\nfunc (f *GogsDownloaderFactory) New(ctx context.Context, opts base.MigrateOptions) (base.Downloader, error)\n```\nNew returns a Downloader related to this factory according MigrateOptions\n\n```go\ntype MigrateOptions = base.MigrateOptions\n```\nMigrateOptions is equal to base.MigrateOptions\n\n```go\ntype PlainGitDownloader struct {\n\tbase.NullDownloader\n\t// contains filtered or unexported fields\n}\n```\nPlainGitDownloader implements a Downloader interface to clone git from a http/https URL\n\n```go\nfunc NewPlainGitDownloader(ownerName, repoName, remoteURL string) *PlainGitDownloader\n```\nNewPlainGitDownloader creates a git Downloader\n\n```go\nfunc (g *PlainGitDownloader) GetRepoInfo() (*base.Repository, error)\n```\nGetRepoInfo returns a repository information\n\n```go\nfunc (g PlainGitDownloader) GetTopics() ([]string, error)\n```\nGetTopics return empty string slice\n\n```go\nfunc (g *PlainGitDownloader) SetContext(ctx context.Context)\n```\nSetContext set context\n\n```go\ntype RepositoryDumper struct {\n\t// contains filtered or unexported fields\n}\n```\nRepositoryDumper implements an Uploader to the local directory\n\n```go\nfunc NewRepositoryDumper(ctx context.Context, baseDir, repoOwner, repoName string, opts base.MigrateOptions) (*RepositoryDumper, error)\n```\nNewRepositoryDumper creates an gitea Uploader\n\n```go\nfunc (g *RepositoryDumper) Close()\n```\nClose closes this uploader\n\n```go\nfunc (g *RepositoryDumper) CreateComments(comments ...*base.Comment) error\n```\nCreateComments creates comments of issues\n\n```go\nfunc (g *RepositoryDumper) CreateIssues(issues ...*base.Issue) error\n```\nCreateIssues creates issues\n\n```go\nfunc (g *RepositoryDumper) CreateLabels(labels ...*base.Label) error\n```\nCreateLabels creates labels\n\n```go\nfunc (g *RepositoryDumper) CreateMilestones(milestones ...*base.Milestone) error\n```\nCreateMilestones creates milestones\n\n```go\nfunc (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error\n```\nCreatePullRequests creates pull requests\n\n```go\nfunc (g *RepositoryDumper) CreateReleases(releases ...*base.Release) error\n```\nCreateReleases creates releases\n\n```go\nfunc (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error\n```\nCreateRepo creates a repository\n\n```go\nfunc (g *RepositoryDumper) CreateReviews(reviews ...*base.Review) error\n```\nCreateReviews create pull request reviews\n\n```go\nfunc (g *RepositoryDumper) CreateTopics(topics ...string) error\n```\nCreateTopics creates topics\n\n```go\nfunc (g *RepositoryDumper) Finish() error\n```\nFinish when migrating succeed, this will update something.\n\n```go\nfunc (g *RepositoryDumper) MaxBatchInsertSize(tp string) int\n```\nMaxBatchInsertSize returns the table's max batch insert size\n\n```go\nfunc (g *RepositoryDumper) Rollback() error\n```\nRollback when migrating failed, this will rollback all the changes.\n\n```go\nfunc (g *RepositoryDumper) SyncTags() error\n```\nSyncTags syncs releases with tags in the database\n\n```go\ntype RepositoryRestorer struct {\n\tbase.NullDownloader\n\t// contains filtered or unexported fields\n}\n```\nRepositoryRestorer implements an Downloader from the local directory\n\n```go\nfunc NewRepositoryRestorer(ctx context.Context, baseDir string, owner, repoName string) (*RepositoryRestorer, error)\n```\nNewRepositoryRestorer creates a repository restorer which could restore repository from a dumped folder\n\n```go\nfunc (r *RepositoryRestorer) GetComments(issueNumber int64) ([]*base.Comment, error)\n```\nGetComments returns comments according issueNumber\n\n```go\nfunc (r *RepositoryRestorer) GetIssues(page, perPage int) ([]*base.Issue, bool, error)\n```\nGetIssues returns issues according start and limit\n\n```go\nfunc (r *RepositoryRestorer) GetLabels() ([]*base.Label, error)\n```\nGetLabels returns labels\n\n```go\nfunc (r *RepositoryRestorer) GetMilestones() ([]*base.Milestone, error)\n```\nGetMilestones returns milestones\n\n```go\nfunc (r *RepositoryRestorer) GetPullRequests(page, perPage int) ([]*base.PullRequest, bool, error)\n```\nGetPullRequests returns pull requests according page and perPage\n\n```go\nfunc (r *RepositoryRestorer) GetReleases() ([]*base.Release, error)\n```\nGetReleases returns releases\n\n```go\nfunc (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error)\n```\nGetRepoInfo returns a repository information\n\n```go\nfunc (r *RepositoryRestorer) GetReviews(pullRequestNumber int64) ([]*base.Review, error)\n```\nGetReviews returns pull requests review\n\n```go\nfunc (r *RepositoryRestorer) GetTopics() ([]string, error)\n```\nGetTopics return github topics\n\n```go\nfunc (r *RepositoryRestorer) SetContext(ctx context.Context)\n```\nSetContext set context\n\n","path":"github.com/RedAFD/code-core/modules/migrations","name":"migrations","synopsis":"","isRedistributable":true}
