mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-13 23:16:45 +03:00
fix: resolve SQLite field mismatch for large starred repo imports (#90)
- Add missing database fields (language, description, mirroredLocation, destinationOrg) to repository operations - Add missing organization fields (publicRepositoryCount, privateRepositoryCount, forkRepositoryCount) to schema - Update GitRepo interface to include all required database fields - Fix GitHub data fetching functions to map all fields correctly - Update all sync endpoints (main, repository, organization, scheduler) to handle new fields This fixes the "SQLite query expected X values, received Y" error when importing large numbers (4.6k+) of starred repositories by ensuring all database fields are properly mapped from GitHub API responses through to database insertion.
This commit is contained in:
@@ -445,6 +445,9 @@ export const organizations = sqliteTable("organizations", {
|
||||
errorMessage: text("error_message"),
|
||||
|
||||
repositoryCount: integer("repository_count").notNull().default(0),
|
||||
publicRepositoryCount: integer("public_repository_count"),
|
||||
privateRepositoryCount: integer("private_repository_count"),
|
||||
forkRepositoryCount: integer("fork_repository_count"),
|
||||
|
||||
createdAt: integer("created_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
|
||||
@@ -68,6 +68,8 @@ export async function getGithubRepositories({
|
||||
owner: repo.owner.login,
|
||||
organization:
|
||||
repo.owner.type === "Organization" ? repo.owner.login : undefined,
|
||||
mirroredLocation: "",
|
||||
destinationOrg: null,
|
||||
|
||||
isPrivate: repo.private,
|
||||
isForked: repo.fork,
|
||||
@@ -82,6 +84,8 @@ export async function getGithubRepositories({
|
||||
hasLFS: false,
|
||||
hasSubmodules: false,
|
||||
|
||||
language: repo.language,
|
||||
description: repo.description,
|
||||
defaultBranch: repo.default_branch,
|
||||
visibility: (repo.visibility ?? "public") as GitRepo["visibility"],
|
||||
|
||||
@@ -125,6 +129,8 @@ export async function getGithubStarredRepositories({
|
||||
owner: repo.owner.login,
|
||||
organization:
|
||||
repo.owner.type === "Organization" ? repo.owner.login : undefined,
|
||||
mirroredLocation: "",
|
||||
destinationOrg: null,
|
||||
|
||||
isPrivate: repo.private,
|
||||
isForked: repo.fork,
|
||||
@@ -138,6 +144,8 @@ export async function getGithubStarredRepositories({
|
||||
hasLFS: false, // Placeholder
|
||||
hasSubmodules: false, // Placeholder
|
||||
|
||||
language: repo.language,
|
||||
description: repo.description,
|
||||
defaultBranch: repo.default_branch,
|
||||
visibility: (repo.visibility ?? "public") as GitRepo["visibility"],
|
||||
|
||||
@@ -244,6 +252,8 @@ export async function getGithubOrganizationRepositories({
|
||||
|
||||
owner: repo.owner.login,
|
||||
organization: repo.owner.login,
|
||||
mirroredLocation: "",
|
||||
destinationOrg: null,
|
||||
|
||||
isPrivate: repo.private,
|
||||
isForked: repo.fork,
|
||||
@@ -258,6 +268,8 @@ export async function getGithubOrganizationRepositories({
|
||||
hasLFS: false,
|
||||
hasSubmodules: false,
|
||||
|
||||
language: repo.language,
|
||||
description: repo.description,
|
||||
defaultBranch: repo.default_branch ?? "main",
|
||||
visibility: (repo.visibility ?? "public") as GitRepo["visibility"],
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ async function runScheduledSync(config: any): Promise<void> {
|
||||
cloneUrl: repo.cloneUrl,
|
||||
owner: repo.owner,
|
||||
organization: repo.organization,
|
||||
mirroredLocation: repo.mirroredLocation || "",
|
||||
destinationOrg: repo.destinationOrg || null,
|
||||
isPrivate: repo.isPrivate,
|
||||
isForked: repo.isForked,
|
||||
forkedFrom: repo.forkedFrom,
|
||||
@@ -129,6 +131,8 @@ async function runScheduledSync(config: any): Promise<void> {
|
||||
size: repo.size,
|
||||
hasLFS: repo.hasLFS,
|
||||
hasSubmodules: repo.hasSubmodules,
|
||||
language: repo.language || null,
|
||||
description: repo.description || null,
|
||||
defaultBranch: repo.defaultBranch,
|
||||
visibility: repo.visibility,
|
||||
status: 'imported',
|
||||
@@ -397,6 +401,8 @@ async function performInitialAutoStart(): Promise<void> {
|
||||
cloneUrl: repo.cloneUrl,
|
||||
owner: repo.owner,
|
||||
organization: repo.organization,
|
||||
mirroredLocation: repo.mirroredLocation || "",
|
||||
destinationOrg: repo.destinationOrg || null,
|
||||
isPrivate: repo.isPrivate,
|
||||
isForked: repo.isForked,
|
||||
forkedFrom: repo.forkedFrom,
|
||||
@@ -406,6 +412,8 @@ async function performInitialAutoStart(): Promise<void> {
|
||||
size: repo.size,
|
||||
hasLFS: repo.hasLFS,
|
||||
hasSubmodules: repo.hasSubmodules,
|
||||
language: repo.language || null,
|
||||
description: repo.description || null,
|
||||
defaultBranch: repo.defaultBranch,
|
||||
visibility: repo.visibility,
|
||||
status: 'imported',
|
||||
|
||||
@@ -67,6 +67,8 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
cloneUrl: repo.cloneUrl,
|
||||
owner: repo.owner,
|
||||
organization: repo.organization,
|
||||
mirroredLocation: repo.mirroredLocation || "",
|
||||
destinationOrg: repo.destinationOrg || null,
|
||||
isPrivate: repo.isPrivate,
|
||||
isForked: repo.isForked,
|
||||
forkedFrom: repo.forkedFrom,
|
||||
@@ -76,6 +78,8 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
size: repo.size,
|
||||
hasLFS: repo.hasLFS,
|
||||
hasSubmodules: repo.hasSubmodules,
|
||||
language: repo.language || null,
|
||||
description: repo.description || null,
|
||||
defaultBranch: repo.defaultBranch,
|
||||
visibility: repo.visibility,
|
||||
status: repo.status,
|
||||
|
||||
@@ -117,6 +117,8 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
owner: repo.owner.login,
|
||||
organization:
|
||||
repo.owner.type === "Organization" ? repo.owner.login : null,
|
||||
mirroredLocation: "",
|
||||
destinationOrg: null,
|
||||
isPrivate: repo.private,
|
||||
isForked: repo.fork,
|
||||
forkedFrom: undefined,
|
||||
@@ -126,6 +128,8 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
size: repo.size,
|
||||
hasLFS: false,
|
||||
hasSubmodules: false,
|
||||
language: repo.language || null,
|
||||
description: repo.description || null,
|
||||
defaultBranch: repo.default_branch ?? "main",
|
||||
visibility: (repo.visibility ?? "public") as RepositoryVisibility,
|
||||
status: "imported" as RepoStatus,
|
||||
|
||||
@@ -92,12 +92,15 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
size: repoData.size,
|
||||
hasLFS: false,
|
||||
hasSubmodules: false,
|
||||
language: repoData.language || null,
|
||||
description: repoData.description || null,
|
||||
defaultBranch: repoData.default_branch,
|
||||
visibility: (repoData.visibility ?? "public") as RepositoryVisibility,
|
||||
status: "imported" as Repository["status"],
|
||||
lastMirrored: undefined,
|
||||
errorMessage: undefined,
|
||||
mirroredLocation: "",
|
||||
destinationOrg: null,
|
||||
createdAt: repoData.created_at
|
||||
? new Date(repoData.created_at)
|
||||
: new Date(),
|
||||
|
||||
@@ -48,6 +48,8 @@ export interface GitRepo {
|
||||
|
||||
owner: string;
|
||||
organization?: string;
|
||||
mirroredLocation?: string;
|
||||
destinationOrg?: string | null;
|
||||
|
||||
isPrivate: boolean;
|
||||
isForked: boolean;
|
||||
@@ -61,6 +63,8 @@ export interface GitRepo {
|
||||
hasLFS: boolean;
|
||||
hasSubmodules: boolean;
|
||||
|
||||
language?: string | null;
|
||||
description?: string | null;
|
||||
defaultBranch: string;
|
||||
visibility: RepositoryVisibility;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user