mysqldb

package
v0.10.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	*Queries
	// contains filtered or unexported fields
}

Adapter wraps mysqldb.Queries and provides the DB() method.

func NewAdapter

func NewAdapter(db *sql.DB) *Adapter

NewAdapter creates a new MySQL adapter.

func (*Adapter) DB

func (a *Adapter) DB() *sql.DB

DB returns the underlying database connection.

func (*Adapter) DBTX added in v0.9.0

func (a *Adapter) DBTX() DBTX

DBTX returns the current database executor (can be a transaction or the pool).

func (*Adapter) WithTx

func (a *Adapter) WithTx(tx *sql.Tx) *Adapter

WithTx returns a new Adapter with the queries scoped to the given transaction.

type AddNarInfoReferenceParams added in v0.8.0

type AddNarInfoReferenceParams struct {
	NarInfoID int64
	Reference string
}

type AddNarInfoSignatureParams added in v0.8.0

type AddNarInfoSignatureParams struct {
	NarInfoID int64
	Signature string
}

type Chunk added in v0.9.0

type Chunk struct {
	ID             int64
	Hash           string
	Size           uint32
	CompressedSize uint32
	CreatedAt      time.Time
	UpdatedAt      sql.NullTime
}

type Config

type Config struct {
	ID        int64
	Key       string
	Value     string
	CreatedAt time.Time
	UpdatedAt sql.NullTime
}

type CreateChunkParams added in v0.9.0

type CreateChunkParams struct {
	Hash           string
	Size           uint32
	CompressedSize uint32
}

type CreateConfigParams

type CreateConfigParams struct {
	Key   string
	Value string
}

type CreateNarFileParams

type CreateNarFileParams struct {
	Hash        string
	Compression string
	Query       string
	FileSize    uint64
	TotalChunks int64
}

type CreateNarInfoParams added in v0.8.0

type CreateNarInfoParams struct {
	Hash        string
	StorePath   sql.NullString
	URL         sql.NullString
	Compression sql.NullString
	FileHash    sql.NullString
	FileSize    sql.NullInt64
	NarHash     sql.NullString
	NarSize     sql.NullInt64
	Deriver     sql.NullString
	System      sql.NullString
	Ca          sql.NullString
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DeleteNarFileByHashParams added in v0.8.0

type DeleteNarFileByHashParams struct {
	Hash        string
	Compression string
	Query       string
}

type GetAllNarFilesRow added in v0.9.2

type GetAllNarFilesRow struct {
	ID                int64
	Hash              string
	Compression       string
	Query             string
	FileSize          uint64
	TotalChunks       int64
	ChunkingStartedAt sql.NullTime
	CreatedAt         time.Time
	UpdatedAt         sql.NullTime
	LastAccessedAt    sql.NullTime
	VerifiedAt        sql.NullTime
}

type GetChunkByNarFileIDAndIndexParams added in v0.9.0

type GetChunkByNarFileIDAndIndexParams struct {
	NarFileID  int64
	ChunkIndex int64
}

type GetChunkByNarFileIDAndIndexRow added in v0.9.0

type GetChunkByNarFileIDAndIndexRow struct {
	ID        int64
	Hash      string
	Size      uint32
	CreatedAt time.Time
	UpdatedAt sql.NullTime
}

type GetChunksByNarFileIDFromIndexParams added in v0.9.4

type GetChunksByNarFileIDFromIndexParams struct {
	NarFileID  int64
	ChunkIndex int64
	Limit      int32
}

type GetChunksByNarFileIDFromIndexRow added in v0.9.4

type GetChunksByNarFileIDFromIndexRow struct {
	ID        int64
	Hash      string
	Size      uint32
	CreatedAt time.Time
	UpdatedAt sql.NullTime
}

type GetNarFileByHashAndCompressionAndQueryParams added in v0.8.0

type GetNarFileByHashAndCompressionAndQueryParams struct {
	Hash        string
	Compression string
	Query       string
}

type GetNarFileByHashAndCompressionAndQueryRow added in v0.8.0

type GetNarFileByHashAndCompressionAndQueryRow struct {
	ID                int64
	Hash              string
	Compression       string
	FileSize          uint64
	Query             string
	CreatedAt         time.Time
	UpdatedAt         sql.NullTime
	LastAccessedAt    sql.NullTime
	TotalChunks       int64
	ChunkingStartedAt sql.NullTime
	VerifiedAt        sql.NullTime
}

type GetNarFileByNarInfoIDRow added in v0.8.0

type GetNarFileByNarInfoIDRow struct {
	ID                int64
	Hash              string
	Compression       string
	FileSize          uint64
	Query             string
	CreatedAt         time.Time
	UpdatedAt         sql.NullTime
	LastAccessedAt    sql.NullTime
	TotalChunks       int64
	ChunkingStartedAt sql.NullTime
	VerifiedAt        sql.NullTime
}

type GetNarFilesToChunkRow added in v0.9.0

type GetNarFilesToChunkRow struct {
	ID          int64
	Hash        string
	Compression string
	Query       string
	FileSize    uint64
}

type GetNarInfoURLByNarFileHashParams added in v0.8.5

type GetNarInfoURLByNarFileHashParams struct {
	Hash        string
	Compression string
	Query       string
}

type GetOldCompressedNarFilesRow

type GetOldCompressedNarFilesRow struct {
	ID          int64
	Hash        string
	Compression string
	Query       string
	FileSize    uint64
	CreatedAt   time.Time
}

type GetOrphanedChunksRow added in v0.9.0

type GetOrphanedChunksRow struct {
	ID        int64
	Hash      string
	Size      uint32
	CreatedAt time.Time
	UpdatedAt sql.NullTime
}

type GetOrphanedNarFilesRow added in v0.8.0

type GetOrphanedNarFilesRow struct {
	ID                int64
	Hash              string
	Compression       string
	FileSize          uint64
	Query             string
	CreatedAt         time.Time
	UpdatedAt         sql.NullTime
	LastAccessedAt    sql.NullTime
	TotalChunks       int64
	ChunkingStartedAt sql.NullTime
	VerifiedAt        sql.NullTime
}

type GetStuckNarFilesParams

type GetStuckNarFilesParams struct {
	CutoffTime time.Time
	Limit      int32
}

type GetStuckNarFilesRow

type GetStuckNarFilesRow struct {
	ID          int64
	Hash        string
	Compression string
	Query       string
	FileSize    uint64
}

type LinkNarFileToChunkParams added in v0.9.0

type LinkNarFileToChunkParams struct {
	NarFileID  int64
	ChunkID    int64
	ChunkIndex int64
}

type LinkNarFileToChunksParams added in v0.9.0

type LinkNarFileToChunksParams struct {
	NarFileID  int64
	ChunkID    int64
	ChunkIndex int64
}

type LinkNarInfoToNarFileParams

type LinkNarInfoToNarFileParams struct {
	NarInfoID int64
	NarFileID int64
}

type LinkNarInfosByURLToNarFileParams added in v0.9.0

type LinkNarInfosByURLToNarFileParams struct {
	NarFileID int64
	URL       sql.NullString
}

type NarFile

type NarFile struct {
	ID                int64
	Hash              string
	Compression       string
	FileSize          uint64
	CreatedAt         time.Time
	UpdatedAt         sql.NullTime
	LastAccessedAt    sql.NullTime
	Query             string
	TotalChunks       int64
	ChunkingStartedAt sql.NullTime
	VerifiedAt        sql.NullTime
}

type NarFileChunk added in v0.9.0

type NarFileChunk struct {
	NarFileID  int64
	ChunkID    int64
	ChunkIndex int64
}

type NarInfo

type NarInfo struct {
	ID             int64
	Hash           string
	CreatedAt      time.Time
	UpdatedAt      sql.NullTime
	LastAccessedAt sql.NullTime
	StorePath      sql.NullString
	URL            sql.NullString
	Compression    sql.NullString
	FileHash       sql.NullString
	FileSize       sql.NullInt64
	NarHash        sql.NullString
	NarSize        sql.NullInt64
	Deriver        sql.NullString
	System         sql.NullString
	Ca             sql.NullString
}

type NarinfoNarFile

type NarinfoNarFile struct {
	NarInfoID int64
	NarFileID int64
}

type NarinfoReference added in v0.8.0

type NarinfoReference struct {
	NarInfoID int64
	Reference string
}

type NarinfoSignature added in v0.8.0

type NarinfoSignature struct {
	NarInfoID int64
	Signature string
}

type Querier

type Querier interface {
	//AddNarInfoReference
	//
	//  INSERT IGNORE INTO narinfo_references (
	//      narinfo_id, reference
	//  ) VALUES (
	//      ?, ?
	//  )
	AddNarInfoReference(ctx context.Context, arg AddNarInfoReferenceParams) error
	//AddNarInfoSignature
	//
	//  INSERT IGNORE INTO narinfo_signatures (
	//      narinfo_id, signature
	//  ) VALUES (
	//      ?, ?
	//  )
	AddNarInfoSignature(ctx context.Context, arg AddNarInfoSignatureParams) error
	//ClearNarFileChunkingStarted
	//
	//  UPDATE nar_files
	//  SET chunking_started_at = NULL, updated_at = CURRENT_TIMESTAMP
	//  WHERE id = ?
	ClearNarFileChunkingStarted(ctx context.Context, id int64) error
	//CreateChunk
	//
	//  INSERT INTO chunks (
	//      hash, size, compressed_size
	//  ) VALUES (
	//      ?, ?, ?
	//  )
	//  ON DUPLICATE KEY UPDATE
	//      id = LAST_INSERT_ID(id),
	//      updated_at = CURRENT_TIMESTAMP
	CreateChunk(ctx context.Context, arg CreateChunkParams) (sql.Result, error)
	//CreateConfig
	//
	//  INSERT INTO config (
	//      `key`, value
	//  ) VALUES (
	//      ?, ?
	//  )
	CreateConfig(ctx context.Context, arg CreateConfigParams) (sql.Result, error)
	//CreateNarFile
	//
	//  INSERT INTO nar_files (
	//      hash, compression, `query`, file_size, total_chunks
	//  ) VALUES (
	//      ?, ?, ?, ?, ?
	//  )
	//  ON DUPLICATE KEY UPDATE
	//      id = LAST_INSERT_ID(id),
	//      updated_at = CURRENT_TIMESTAMP
	CreateNarFile(ctx context.Context, arg CreateNarFileParams) (sql.Result, error)
	//CreateNarInfo
	//
	//  INSERT INTO narinfos (
	//      hash, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
	//  ) VALUES (
	//      ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
	//  )
	//  ON DUPLICATE KEY UPDATE
	//      id = LAST_INSERT_ID(id),
	//      store_path = IF(url IS NULL, VALUES(store_path), store_path),
	//      compression = IF(url IS NULL, VALUES(compression), compression),
	//      file_hash = IF(url IS NULL, VALUES(file_hash), file_hash),
	//      file_size = IF(url IS NULL, VALUES(file_size), file_size),
	//      nar_hash = IF(url IS NULL, VALUES(nar_hash), nar_hash),
	//      nar_size = IF(url IS NULL, VALUES(nar_size), nar_size),
	//      deriver = IF(url IS NULL, VALUES(deriver), deriver),
	//      system = IF(url IS NULL, VALUES(system), system),
	//      ca = IF(url IS NULL, VALUES(ca), ca),
	//      url = IF(url IS NULL, VALUES(url), url),
	//      updated_at = IF(url IS NULL, CURRENT_TIMESTAMP, updated_at)
	CreateNarInfo(ctx context.Context, arg CreateNarInfoParams) (sql.Result, error)
	//DeleteChunkByID
	//
	//  DELETE FROM chunks
	//  WHERE id = ?
	DeleteChunkByID(ctx context.Context, id int64) error
	//DeleteNarFileByHash
	//
	//  DELETE FROM nar_files
	//  WHERE hash = ? AND compression = ? AND `query` = ?
	DeleteNarFileByHash(ctx context.Context, arg DeleteNarFileByHashParams) (int64, error)
	//DeleteNarFileByID
	//
	//  DELETE FROM nar_files
	//  WHERE id = ?
	DeleteNarFileByID(ctx context.Context, id int64) (int64, error)
	//DeleteNarFileChunksByNarFileID
	//
	//  DELETE FROM nar_file_chunks
	//  WHERE nar_file_id = ?
	DeleteNarFileChunksByNarFileID(ctx context.Context, narFileID int64) error
	//DeleteNarInfoByHash
	//
	//  DELETE FROM narinfos
	//  WHERE hash = ?
	DeleteNarInfoByHash(ctx context.Context, hash string) (int64, error)
	//DeleteNarInfoByID
	//
	//  DELETE FROM narinfos
	//  WHERE id = ?
	DeleteNarInfoByID(ctx context.Context, id int64) (int64, error)
	//DeleteOrphanedChunks
	//
	//  DELETE FROM chunks
	//  WHERE NOT EXISTS (
	//      SELECT 1
	//      FROM nar_file_chunks
	//      WHERE chunk_id = chunks.id
	//  )
	DeleteOrphanedChunks(ctx context.Context) (int64, error)
	//DeleteOrphanedNarFiles
	//
	//  DELETE FROM nar_files
	//  WHERE id NOT IN (
	//      SELECT DISTINCT nar_file_id
	//      FROM narinfo_nar_files
	//  )
	DeleteOrphanedNarFiles(ctx context.Context) (int64, error)
	// Returns all chunks for storage existence verification (CDC mode).
	//
	//  SELECT id, hash, size, compressed_size, created_at, updated_at
	//  FROM chunks
	GetAllChunks(ctx context.Context) ([]Chunk, error)
	// Returns all nar_files for storage existence verification.
	//
	//  SELECT id, hash, compression, `query`, file_size, total_chunks, chunking_started_at, created_at, updated_at, last_accessed_at, verified_at
	//  FROM nar_files
	GetAllNarFiles(ctx context.Context) ([]GetAllNarFilesRow, error)
	//GetChunkByHash
	//
	//  SELECT id, hash, size, compressed_size, created_at, updated_at
	//  FROM chunks
	//  WHERE hash = ?
	GetChunkByHash(ctx context.Context, hash string) (Chunk, error)
	//GetChunkByNarFileIDAndIndex
	//
	//  SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
	//  FROM chunks c
	//  INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
	//  WHERE nfc.nar_file_id = ? AND nfc.chunk_index = ?
	GetChunkByNarFileIDAndIndex(ctx context.Context, arg GetChunkByNarFileIDAndIndexParams) (GetChunkByNarFileIDAndIndexRow, error)
	//GetChunkCount
	//
	//  SELECT CAST(COUNT(*) AS SIGNED) AS count
	//  FROM chunks
	GetChunkCount(ctx context.Context) (int64, error)
	//GetChunksByNarFileID
	//
	//  SELECT c.id, c.hash, c.size, c.compressed_size, c.created_at, c.updated_at
	//  FROM chunks c
	//  INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
	//  WHERE nfc.nar_file_id = ?
	//  ORDER BY nfc.chunk_index
	GetChunksByNarFileID(ctx context.Context, narFileID int64) ([]Chunk, error)
	//GetChunksByNarFileIDFromIndex
	//
	//  SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
	//  FROM chunks c
	//  INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
	//  WHERE nfc.nar_file_id = ? AND nfc.chunk_index >= ?
	//  ORDER BY nfc.chunk_index
	//  LIMIT ?
	GetChunksByNarFileIDFromIndex(ctx context.Context, arg GetChunksByNarFileIDFromIndexParams) ([]GetChunksByNarFileIDFromIndexRow, error)
	//GetConfigByKey
	//
	//  SELECT id, `key`, value, created_at, updated_at
	//  FROM config
	//  WHERE `key` = ?
	GetConfigByKey(ctx context.Context, key string) (Config, error)
	// NOTE: This query uses a correlated subquery which is not optimal for performance.
	// The ideal implementation would use a window function (SUM OVER), but sqlc v1.30.0
	// does not properly support filtering on window function results in subqueries.
	// Gets the least-used narinfos up to a certain total file size (accounting for their nar_files).
	//
	//  SELECT ni1.id, ni1.hash, ni1.created_at, ni1.updated_at, ni1.last_accessed_at, ni1.store_path, ni1.url, ni1.compression, ni1.file_hash, ni1.file_size, ni1.nar_hash, ni1.nar_size, ni1.deriver, ni1.`system`, ni1.ca
	//  FROM narinfos ni1
	//  WHERE (
	//      SELECT COALESCE(SUM(nf.file_size), 0)
	//      FROM nar_files nf
	//      WHERE nf.id IN (
	//          SELECT DISTINCT nnf.nar_file_id
	//          FROM narinfo_nar_files nnf
	//          INNER JOIN narinfos ni2 ON nnf.narinfo_id = ni2.id
	//          WHERE ni2.last_accessed_at < ni1.last_accessed_at
	//              OR (ni2.last_accessed_at = ni1.last_accessed_at AND ni2.id <= ni1.id)
	//      )
	//  ) <= ?
	GetLeastUsedNarInfos(ctx context.Context, fileSize uint64) ([]NarInfo, error)
	// Get all narinfo hashes that have a URL (migrated).
	//
	//  SELECT hash
	//  FROM narinfos
	//  WHERE url IS NOT NULL
	GetMigratedNarInfoHashes(ctx context.Context) ([]string, error)
	//GetNarFileByHashAndCompressionAndQuery
	//
	//  SELECT id, hash, compression, file_size, `query`, created_at, updated_at, last_accessed_at, total_chunks, chunking_started_at, verified_at
	//  FROM nar_files
	//  WHERE hash = ? AND compression = ? AND `query` = ?
	GetNarFileByHashAndCompressionAndQuery(ctx context.Context, arg GetNarFileByHashAndCompressionAndQueryParams) (GetNarFileByHashAndCompressionAndQueryRow, error)
	//GetNarFileByNarInfoID
	//
	//  SELECT nf.id, nf.hash, nf.compression, nf.file_size, nf.`query`, nf.created_at, nf.updated_at, nf.last_accessed_at, nf.total_chunks, nf.chunking_started_at, nf.verified_at
	//  FROM nar_files nf
	//  INNER JOIN narinfo_nar_files nnf ON nf.id = nnf.nar_file_id
	//  WHERE nnf.narinfo_id = ?
	GetNarFileByNarInfoID(ctx context.Context, narinfoID int64) (GetNarFileByNarInfoIDRow, error)
	//GetNarFileCount
	//
	//  SELECT CAST(COUNT(*) AS SIGNED) AS count
	//  FROM nar_files
	GetNarFileCount(ctx context.Context) (int64, error)
	// Get all NAR files that are not yet chunked.
	//
	//  SELECT id, hash, compression, `query`, file_size
	//  FROM nar_files
	//  WHERE total_chunks = 0
	//  ORDER BY id
	GetNarFilesToChunk(ctx context.Context) ([]GetNarFilesToChunkRow, error)
	// Get the count of NAR files that are not yet chunked.
	//
	//  SELECT COUNT(*)
	//  FROM nar_files
	//  WHERE total_chunks = 0
	GetNarFilesToChunkCount(ctx context.Context) (int64, error)
	//GetNarInfoByHash
	//
	//  SELECT id, hash, created_at, updated_at, last_accessed_at, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, `system`, ca
	//  FROM narinfos
	//  WHERE hash = ?
	GetNarInfoByHash(ctx context.Context, hash string) (NarInfo, error)
	//GetNarInfoCount
	//
	//  SELECT CAST(COUNT(*) AS SIGNED) AS count
	//  FROM narinfos
	GetNarInfoCount(ctx context.Context) (int64, error)
	//GetNarInfoHashByNarURL
	//
	//  SELECT hash
	//  FROM narinfos
	//  WHERE url = ?
	//  LIMIT 1
	GetNarInfoHashByNarURL(ctx context.Context, url sql.NullString) (string, error)
	//GetNarInfoHashesByURL
	//
	//  SELECT hash
	//  FROM narinfos
	//  WHERE url = ?
	GetNarInfoHashesByURL(ctx context.Context, url sql.NullString) ([]string, error)
	//GetNarInfoReferences
	//
	//  SELECT reference
	//  FROM narinfo_references
	//  WHERE narinfo_id = ?
	GetNarInfoReferences(ctx context.Context, narinfoID int64) ([]string, error)
	//GetNarInfoSignatures
	//
	//  SELECT signature
	//  FROM narinfo_signatures
	//  WHERE narinfo_id = ?
	GetNarInfoSignatures(ctx context.Context, narinfoID int64) ([]string, error)
	//GetNarInfoURLByNarFileHash
	//
	//  SELECT ni.url
	//  FROM narinfos ni
	//  INNER JOIN narinfo_nar_files nnf ON ni.id = nnf.narinfo_id
	//  INNER JOIN nar_files nf ON nf.id = nnf.nar_file_id
	//  WHERE nf.hash = ? AND nf.compression = ? AND nf.query = ?
	//  LIMIT 1
	GetNarInfoURLByNarFileHash(ctx context.Context, arg GetNarInfoURLByNarFileHashParams) (sql.NullString, error)
	// Returns narinfos that have no linked nar_file entries.
	//
	//  SELECT ni.id, ni.hash, ni.created_at, ni.updated_at, ni.last_accessed_at, ni.store_path, ni.url, ni.compression, ni.file_hash, ni.file_size, ni.nar_hash, ni.nar_size, ni.deriver, ni.`system`, ni.ca
	//  FROM narinfos ni
	//  WHERE NOT EXISTS (
	//      SELECT 1 FROM narinfo_nar_files nnf WHERE nnf.narinfo_id = ni.id
	//  )
	GetNarInfosWithoutNarFiles(ctx context.Context) ([]NarInfo, error)
	//GetNarTotalSize
	//
	//  SELECT CAST(COALESCE(SUM(file_size), 0) AS SIGNED) AS total_size
	//  FROM nar_files
	GetNarTotalSize(ctx context.Context) (int64, error)
	// Get compressed NAR files that have been replaced by chunked versions and are ready for deletion.
	// This is used by the CDC delayed cleanup job to find old compressed files after chunking.
	//
	//  SELECT old_nf.id, old_nf.hash, old_nf.compression, old_nf.query, old_nf.file_size, old_nf.created_at
	//  FROM nar_files old_nf
	//  JOIN nar_files new_nf ON old_nf.hash = new_nf.hash
	//  WHERE old_nf.total_chunks = 0
	//    AND old_nf.compression != 'none'
	//    AND new_nf.compression = 'none'
	//    AND new_nf.total_chunks > 0
	//    AND old_nf.created_at < ?
	GetOldCompressedNarFiles(ctx context.Context, cutoffTime time.Time) ([]GetOldCompressedNarFilesRow, error)
	//GetOrphanedChunks
	//
	//  SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
	//  FROM chunks c
	//  LEFT JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
	//  WHERE nfc.chunk_id IS NULL
	GetOrphanedChunks(ctx context.Context) ([]GetOrphanedChunksRow, error)
	// Find files that have no relationship to any narinfo
	//
	//  SELECT nf.id, nf.hash, nf.compression, nf.file_size, nf.`query`, nf.created_at, nf.updated_at, nf.last_accessed_at, nf.total_chunks, nf.chunking_started_at, nf.verified_at
	//  FROM nar_files nf
	//  LEFT JOIN narinfo_nar_files ninf ON nf.id = ninf.nar_file_id
	//  WHERE ninf.narinfo_id IS NULL
	GetOrphanedNarFiles(ctx context.Context) ([]GetOrphanedNarFilesRow, error)
	// Get NAR files that are stuck (not chunked, no active chunking, and older than the given age).
	// This is used by the CDC lazy recovery job to find NARs that failed to chunk due to restart.
	//
	//  SELECT id, hash, compression, query, file_size
	//  FROM nar_files
	//  WHERE total_chunks = 0
	//    AND chunking_started_at IS NULL
	//    AND created_at < ?
	//  ORDER BY id
	//  LIMIT ?
	GetStuckNarFiles(ctx context.Context, arg GetStuckNarFilesParams) ([]GetStuckNarFilesRow, error)
	// Get all narinfo hashes that have no URL (unmigrated).
	//
	//  SELECT hash
	//  FROM narinfos
	//  WHERE url IS NULL
	GetUnmigratedNarInfoHashes(ctx context.Context) ([]string, error)
	// Returns true if any nar_file has total_chunks > 0 (used for CDC auto-detection).
	//
	//  SELECT EXISTS(SELECT 1 FROM nar_files WHERE total_chunks > 0) AS "exists"
	HasAnyChunkedNarFiles(ctx context.Context) (bool, error)
	//LinkNarFileToChunk
	//
	//  INSERT IGNORE INTO nar_file_chunks (
	//      nar_file_id, chunk_id, chunk_index
	//  ) VALUES (
	//      ?, ?, ?
	//  )
	LinkNarFileToChunk(ctx context.Context, arg LinkNarFileToChunkParams) error
	// @bulk-for LinkNarFileToChunk
	//
	//  INSERT IGNORE INTO nar_file_chunks (
	//      nar_file_id, chunk_id, chunk_index
	//  ) VALUES (
	//      ?, ?, ?
	//  )
	LinkNarFileToChunks(ctx context.Context, arg LinkNarFileToChunksParams) error
	//LinkNarInfoToNarFile
	//
	//  INSERT INTO narinfo_nar_files (
	//      narinfo_id, nar_file_id
	//  ) VALUES (
	//      ?, ?
	//  )
	//  ON DUPLICATE KEY UPDATE narinfo_id = narinfo_id
	LinkNarInfoToNarFile(ctx context.Context, arg LinkNarInfoToNarFileParams) error
	//LinkNarInfosByURLToNarFile
	//
	//  INSERT IGNORE INTO narinfo_nar_files (narinfo_id, nar_file_id)
	//  SELECT id, ?
	//  FROM narinfos
	//  WHERE url = ?
	LinkNarInfosByURLToNarFile(ctx context.Context, arg LinkNarInfosByURLToNarFileParams) error
	//SetConfig
	//
	//  INSERT INTO config (
	//      `key`, value
	//  ) VALUES (
	//      ?, ?
	//  )
	//  ON DUPLICATE KEY UPDATE
	//      value = VALUES(value),
	//      updated_at = CURRENT_TIMESTAMP
	SetConfig(ctx context.Context, arg SetConfigParams) error
	//SetNarFileChunkingStarted
	//
	//  UPDATE nar_files
	//  SET chunking_started_at = CURRENT_TIMESTAMP, updated_at = CURRENT_TIMESTAMP
	//  WHERE id = ?
	SetNarFileChunkingStarted(ctx context.Context, id int64) error
	//TouchNarFile
	//
	//  UPDATE nar_files
	//  SET
	//      last_accessed_at = CURRENT_TIMESTAMP,
	//      updated_at = CURRENT_TIMESTAMP
	//  WHERE hash = ? AND compression = ? AND `query` = ?
	TouchNarFile(ctx context.Context, arg TouchNarFileParams) (int64, error)
	//TouchNarInfo
	//
	//  UPDATE narinfos
	//  SET
	//      last_accessed_at = CURRENT_TIMESTAMP,
	//      updated_at = CURRENT_TIMESTAMP
	//  WHERE hash = ?
	TouchNarInfo(ctx context.Context, hash string) (int64, error)
	//UpdateNarFileFileSize
	//
	//  UPDATE nar_files
	//  SET file_size = ?, updated_at = CURRENT_TIMESTAMP
	//  WHERE id = ?
	UpdateNarFileFileSize(ctx context.Context, arg UpdateNarFileFileSizeParams) error
	//UpdateNarFileTotalChunks
	//
	//  UPDATE nar_files
	//  SET total_chunks = ?, file_size = ?, updated_at = CURRENT_TIMESTAMP, chunking_started_at = NULL
	//  WHERE id = ?
	UpdateNarFileTotalChunks(ctx context.Context, arg UpdateNarFileTotalChunksParams) error
	//UpdateNarFileVerifiedAt
	//
	//  UPDATE nar_files
	//  SET verified_at = CURRENT_TIMESTAMP
	//  WHERE id = ?
	UpdateNarFileVerifiedAt(ctx context.Context, id int64) error
	//UpdateNarInfo
	//
	//  UPDATE narinfos
	//  SET
	//      store_path = ?,
	//      url = ?,
	//      compression = ?,
	//      file_hash = ?,
	//      file_size = ?,
	//      nar_hash = ?,
	//      nar_size = ?,
	//      deriver = ?,
	//      system = ?,
	//      ca = ?,
	//      updated_at = CURRENT_TIMESTAMP
	//  WHERE hash = ?
	UpdateNarInfo(ctx context.Context, arg UpdateNarInfoParams) (sql.Result, error)
	// Update narinfo compression and URL after CDC migration.
	//
	//  UPDATE narinfos
	//  SET compression = ?, url = ?, updated_at = CURRENT_TIMESTAMP
	//  WHERE url = ?
	UpdateNarInfoCompressionAndURL(ctx context.Context, arg UpdateNarInfoCompressionAndURLParams) (int64, error)
	// Update narinfo compression, file_size, file_hash and URL after CDC migration.
	//
	//  UPDATE narinfos
	//  SET
	//      compression = ?,
	//      url = ?,
	//      file_size = ?,
	//      file_hash = ?,
	//      updated_at = CURRENT_TIMESTAMP
	//  WHERE url = ?
	UpdateNarInfoCompressionFileSizeHashAndURL(ctx context.Context, arg UpdateNarInfoCompressionFileSizeHashAndURLParams) (int64, error)
	//UpdateNarInfoFileHash
	//
	//  UPDATE narinfos
	//  SET file_hash = ?, updated_at = CURRENT_TIMESTAMP
	//  WHERE hash = ?
	UpdateNarInfoFileHash(ctx context.Context, arg UpdateNarInfoFileHashParams) error
	//UpdateNarInfoFileSize
	//
	//  UPDATE narinfos
	//  SET file_size = ?, updated_at = CURRENT_TIMESTAMP
	//  WHERE hash = ?
	UpdateNarInfoFileSize(ctx context.Context, arg UpdateNarInfoFileSizeParams) error
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddNarInfoReference added in v0.8.0

func (q *Queries) AddNarInfoReference(ctx context.Context, arg AddNarInfoReferenceParams) error

AddNarInfoReference

INSERT IGNORE INTO narinfo_references (
    narinfo_id, reference
) VALUES (
    ?, ?
)

func (*Queries) AddNarInfoSignature added in v0.8.0

func (q *Queries) AddNarInfoSignature(ctx context.Context, arg AddNarInfoSignatureParams) error

AddNarInfoSignature

INSERT IGNORE INTO narinfo_signatures (
    narinfo_id, signature
) VALUES (
    ?, ?
)

func (*Queries) ClearNarFileChunkingStarted added in v0.9.3

func (q *Queries) ClearNarFileChunkingStarted(ctx context.Context, id int64) error

ClearNarFileChunkingStarted

UPDATE nar_files
SET chunking_started_at = NULL, updated_at = CURRENT_TIMESTAMP
WHERE id = ?

func (*Queries) CreateChunk added in v0.9.0

func (q *Queries) CreateChunk(ctx context.Context, arg CreateChunkParams) (sql.Result, error)

CreateChunk

INSERT INTO chunks (
    hash, size, compressed_size
) VALUES (
    ?, ?, ?
)
ON DUPLICATE KEY UPDATE
    id = LAST_INSERT_ID(id),
    updated_at = CURRENT_TIMESTAMP

func (*Queries) CreateConfig

func (q *Queries) CreateConfig(ctx context.Context, arg CreateConfigParams) (sql.Result, error)

CreateConfig

INSERT INTO config (
    `key`, value
) VALUES (
    ?, ?
)

func (*Queries) CreateNarFile

func (q *Queries) CreateNarFile(ctx context.Context, arg CreateNarFileParams) (sql.Result, error)

CreateNarFile

INSERT INTO nar_files (
    hash, compression, `query`, file_size, total_chunks
) VALUES (
    ?, ?, ?, ?, ?
)
ON DUPLICATE KEY UPDATE
    id = LAST_INSERT_ID(id),
    updated_at = CURRENT_TIMESTAMP

func (*Queries) CreateNarInfo

func (q *Queries) CreateNarInfo(ctx context.Context, arg CreateNarInfoParams) (sql.Result, error)

CreateNarInfo

INSERT INTO narinfos (
    hash, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
) VALUES (
    ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)
ON DUPLICATE KEY UPDATE
    id = LAST_INSERT_ID(id),
    store_path = IF(url IS NULL, VALUES(store_path), store_path),
    compression = IF(url IS NULL, VALUES(compression), compression),
    file_hash = IF(url IS NULL, VALUES(file_hash), file_hash),
    file_size = IF(url IS NULL, VALUES(file_size), file_size),
    nar_hash = IF(url IS NULL, VALUES(nar_hash), nar_hash),
    nar_size = IF(url IS NULL, VALUES(nar_size), nar_size),
    deriver = IF(url IS NULL, VALUES(deriver), deriver),
    system = IF(url IS NULL, VALUES(system), system),
    ca = IF(url IS NULL, VALUES(ca), ca),
    url = IF(url IS NULL, VALUES(url), url),
    updated_at = IF(url IS NULL, CURRENT_TIMESTAMP, updated_at)

func (*Queries) DeleteChunkByID added in v0.9.0

func (q *Queries) DeleteChunkByID(ctx context.Context, id int64) error

DeleteChunkByID

DELETE FROM chunks
WHERE id = ?

func (*Queries) DeleteNarFileByHash

func (q *Queries) DeleteNarFileByHash(ctx context.Context, arg DeleteNarFileByHashParams) (int64, error)

DeleteNarFileByHash

DELETE FROM nar_files
WHERE hash = ? AND compression = ? AND `query` = ?

func (*Queries) DeleteNarFileByID

func (q *Queries) DeleteNarFileByID(ctx context.Context, id int64) (int64, error)

DeleteNarFileByID

DELETE FROM nar_files
WHERE id = ?

func (*Queries) DeleteNarFileChunksByNarFileID added in v0.9.0

func (q *Queries) DeleteNarFileChunksByNarFileID(ctx context.Context, narFileID int64) error

DeleteNarFileChunksByNarFileID

DELETE FROM nar_file_chunks
WHERE nar_file_id = ?

func (*Queries) DeleteNarInfoByHash

func (q *Queries) DeleteNarInfoByHash(ctx context.Context, hash string) (int64, error)

DeleteNarInfoByHash

DELETE FROM narinfos
WHERE hash = ?

func (*Queries) DeleteNarInfoByID

func (q *Queries) DeleteNarInfoByID(ctx context.Context, id int64) (int64, error)

DeleteNarInfoByID

DELETE FROM narinfos
WHERE id = ?

func (*Queries) DeleteOrphanedChunks added in v0.9.0

func (q *Queries) DeleteOrphanedChunks(ctx context.Context) (int64, error)

DeleteOrphanedChunks

DELETE FROM chunks
WHERE NOT EXISTS (
    SELECT 1
    FROM nar_file_chunks
    WHERE chunk_id = chunks.id
)

func (*Queries) DeleteOrphanedNarFiles

func (q *Queries) DeleteOrphanedNarFiles(ctx context.Context) (int64, error)

DeleteOrphanedNarFiles

DELETE FROM nar_files
WHERE id NOT IN (
    SELECT DISTINCT nar_file_id
    FROM narinfo_nar_files
)

func (*Queries) GetAllChunks added in v0.9.2

func (q *Queries) GetAllChunks(ctx context.Context) ([]Chunk, error)

Returns all chunks for storage existence verification (CDC mode).

SELECT id, hash, size, compressed_size, created_at, updated_at
FROM chunks

func (*Queries) GetAllNarFiles added in v0.9.2

func (q *Queries) GetAllNarFiles(ctx context.Context) ([]GetAllNarFilesRow, error)

Returns all nar_files for storage existence verification.

SELECT id, hash, compression, `query`, file_size, total_chunks, chunking_started_at, created_at, updated_at, last_accessed_at, verified_at
FROM nar_files

func (*Queries) GetChunkByHash added in v0.9.0

func (q *Queries) GetChunkByHash(ctx context.Context, hash string) (Chunk, error)

GetChunkByHash

SELECT id, hash, size, compressed_size, created_at, updated_at
FROM chunks
WHERE hash = ?

func (*Queries) GetChunkByNarFileIDAndIndex added in v0.9.0

GetChunkByNarFileIDAndIndex

SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
FROM chunks c
INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
WHERE nfc.nar_file_id = ? AND nfc.chunk_index = ?

func (*Queries) GetChunkCount added in v0.9.0

func (q *Queries) GetChunkCount(ctx context.Context) (int64, error)

GetChunkCount

SELECT CAST(COUNT(*) AS SIGNED) AS count
FROM chunks

func (*Queries) GetChunksByNarFileID added in v0.9.0

func (q *Queries) GetChunksByNarFileID(ctx context.Context, narFileID int64) ([]Chunk, error)

GetChunksByNarFileID

SELECT c.id, c.hash, c.size, c.compressed_size, c.created_at, c.updated_at
FROM chunks c
INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
WHERE nfc.nar_file_id = ?
ORDER BY nfc.chunk_index

func (*Queries) GetChunksByNarFileIDFromIndex added in v0.9.4

func (q *Queries) GetChunksByNarFileIDFromIndex(ctx context.Context, arg GetChunksByNarFileIDFromIndexParams) ([]GetChunksByNarFileIDFromIndexRow, error)

GetChunksByNarFileIDFromIndex

SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
FROM chunks c
INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
WHERE nfc.nar_file_id = ? AND nfc.chunk_index >= ?
ORDER BY nfc.chunk_index
LIMIT ?

func (*Queries) GetConfigByKey

func (q *Queries) GetConfigByKey(ctx context.Context, key string) (Config, error)

GetConfigByKey

SELECT id, `key`, value, created_at, updated_at
FROM config
WHERE `key` = ?

func (*Queries) GetLeastUsedNarInfos

func (q *Queries) GetLeastUsedNarInfos(ctx context.Context, fileSize uint64) ([]NarInfo, error)

NOTE: This query uses a correlated subquery which is not optimal for performance. The ideal implementation would use a window function (SUM OVER), but sqlc v1.30.0 does not properly support filtering on window function results in subqueries. Gets the least-used narinfos up to a certain total file size (accounting for their nar_files).

SELECT ni1.id, ni1.hash, ni1.created_at, ni1.updated_at, ni1.last_accessed_at, ni1.store_path, ni1.url, ni1.compression, ni1.file_hash, ni1.file_size, ni1.nar_hash, ni1.nar_size, ni1.deriver, ni1.`system`, ni1.ca
FROM narinfos ni1
WHERE (
    SELECT COALESCE(SUM(nf.file_size), 0)
    FROM nar_files nf
    WHERE nf.id IN (
        SELECT DISTINCT nnf.nar_file_id
        FROM narinfo_nar_files nnf
        INNER JOIN narinfos ni2 ON nnf.narinfo_id = ni2.id
        WHERE ni2.last_accessed_at < ni1.last_accessed_at
            OR (ni2.last_accessed_at = ni1.last_accessed_at AND ni2.id <= ni1.id)
    )
) <= ?

func (*Queries) GetMigratedNarInfoHashes added in v0.8.0

func (q *Queries) GetMigratedNarInfoHashes(ctx context.Context) ([]string, error)

Get all narinfo hashes that have a URL (migrated).

SELECT hash
FROM narinfos
WHERE url IS NOT NULL

func (*Queries) GetNarFileByHashAndCompressionAndQuery added in v0.8.0

GetNarFileByHashAndCompressionAndQuery

SELECT id, hash, compression, file_size, `query`, created_at, updated_at, last_accessed_at, total_chunks, chunking_started_at, verified_at
FROM nar_files
WHERE hash = ? AND compression = ? AND `query` = ?

func (*Queries) GetNarFileByNarInfoID

func (q *Queries) GetNarFileByNarInfoID(ctx context.Context, narinfoID int64) (GetNarFileByNarInfoIDRow, error)

GetNarFileByNarInfoID

SELECT nf.id, nf.hash, nf.compression, nf.file_size, nf.`query`, nf.created_at, nf.updated_at, nf.last_accessed_at, nf.total_chunks, nf.chunking_started_at, nf.verified_at
FROM nar_files nf
INNER JOIN narinfo_nar_files nnf ON nf.id = nnf.nar_file_id
WHERE nnf.narinfo_id = ?

func (*Queries) GetNarFileCount added in v0.7.1

func (q *Queries) GetNarFileCount(ctx context.Context) (int64, error)

GetNarFileCount

SELECT CAST(COUNT(*) AS SIGNED) AS count
FROM nar_files

func (*Queries) GetNarFilesToChunk added in v0.9.0

func (q *Queries) GetNarFilesToChunk(ctx context.Context) ([]GetNarFilesToChunkRow, error)

Get all NAR files that are not yet chunked.

SELECT id, hash, compression, `query`, file_size
FROM nar_files
WHERE total_chunks = 0
ORDER BY id

func (*Queries) GetNarFilesToChunkCount added in v0.9.0

func (q *Queries) GetNarFilesToChunkCount(ctx context.Context) (int64, error)

Get the count of NAR files that are not yet chunked.

SELECT COUNT(*)
FROM nar_files
WHERE total_chunks = 0

func (*Queries) GetNarInfoByHash

func (q *Queries) GetNarInfoByHash(ctx context.Context, hash string) (NarInfo, error)

GetNarInfoByHash

SELECT id, hash, created_at, updated_at, last_accessed_at, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, `system`, ca
FROM narinfos
WHERE hash = ?

func (*Queries) GetNarInfoCount added in v0.7.1

func (q *Queries) GetNarInfoCount(ctx context.Context) (int64, error)

GetNarInfoCount

SELECT CAST(COUNT(*) AS SIGNED) AS count
FROM narinfos

func (*Queries) GetNarInfoHashByNarURL added in v0.9.0

func (q *Queries) GetNarInfoHashByNarURL(ctx context.Context, url sql.NullString) (string, error)

GetNarInfoHashByNarURL

SELECT hash
FROM narinfos
WHERE url = ?
LIMIT 1

func (*Queries) GetNarInfoHashesByURL added in v0.9.0

func (q *Queries) GetNarInfoHashesByURL(ctx context.Context, url sql.NullString) ([]string, error)

GetNarInfoHashesByURL

SELECT hash
FROM narinfos
WHERE url = ?

func (*Queries) GetNarInfoReferences added in v0.8.0

func (q *Queries) GetNarInfoReferences(ctx context.Context, narinfoID int64) ([]string, error)

GetNarInfoReferences

SELECT reference
FROM narinfo_references
WHERE narinfo_id = ?

func (*Queries) GetNarInfoSignatures added in v0.8.0

func (q *Queries) GetNarInfoSignatures(ctx context.Context, narinfoID int64) ([]string, error)

GetNarInfoSignatures

SELECT signature
FROM narinfo_signatures
WHERE narinfo_id = ?

func (*Queries) GetNarInfoURLByNarFileHash added in v0.8.5

func (q *Queries) GetNarInfoURLByNarFileHash(ctx context.Context, arg GetNarInfoURLByNarFileHashParams) (sql.NullString, error)

GetNarInfoURLByNarFileHash

SELECT ni.url
FROM narinfos ni
INNER JOIN narinfo_nar_files nnf ON ni.id = nnf.narinfo_id
INNER JOIN nar_files nf ON nf.id = nnf.nar_file_id
WHERE nf.hash = ? AND nf.compression = ? AND nf.query = ?
LIMIT 1

func (*Queries) GetNarInfosWithoutNarFiles added in v0.9.2

func (q *Queries) GetNarInfosWithoutNarFiles(ctx context.Context) ([]NarInfo, error)

Returns narinfos that have no linked nar_file entries.

SELECT ni.id, ni.hash, ni.created_at, ni.updated_at, ni.last_accessed_at, ni.store_path, ni.url, ni.compression, ni.file_hash, ni.file_size, ni.nar_hash, ni.nar_size, ni.deriver, ni.`system`, ni.ca
FROM narinfos ni
WHERE NOT EXISTS (
    SELECT 1 FROM narinfo_nar_files nnf WHERE nnf.narinfo_id = ni.id
)

func (*Queries) GetNarTotalSize

func (q *Queries) GetNarTotalSize(ctx context.Context) (int64, error)

GetNarTotalSize

SELECT CAST(COALESCE(SUM(file_size), 0) AS SIGNED) AS total_size
FROM nar_files

func (*Queries) GetOldCompressedNarFiles

func (q *Queries) GetOldCompressedNarFiles(ctx context.Context, cutoffTime time.Time) ([]GetOldCompressedNarFilesRow, error)

Get compressed NAR files that have been replaced by chunked versions and are ready for deletion. This is used by the CDC delayed cleanup job to find old compressed files after chunking.

SELECT old_nf.id, old_nf.hash, old_nf.compression, old_nf.query, old_nf.file_size, old_nf.created_at
FROM nar_files old_nf
JOIN nar_files new_nf ON old_nf.hash = new_nf.hash
WHERE old_nf.total_chunks = 0
  AND old_nf.compression != 'none'
  AND new_nf.compression = 'none'
  AND new_nf.total_chunks > 0
  AND old_nf.created_at < ?

func (*Queries) GetOrphanedChunks added in v0.9.0

func (q *Queries) GetOrphanedChunks(ctx context.Context) ([]GetOrphanedChunksRow, error)

GetOrphanedChunks

SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
FROM chunks c
LEFT JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
WHERE nfc.chunk_id IS NULL

func (*Queries) GetOrphanedNarFiles

func (q *Queries) GetOrphanedNarFiles(ctx context.Context) ([]GetOrphanedNarFilesRow, error)

Find files that have no relationship to any narinfo

SELECT nf.id, nf.hash, nf.compression, nf.file_size, nf.`query`, nf.created_at, nf.updated_at, nf.last_accessed_at, nf.total_chunks, nf.chunking_started_at, nf.verified_at
FROM nar_files nf
LEFT JOIN narinfo_nar_files ninf ON nf.id = ninf.nar_file_id
WHERE ninf.narinfo_id IS NULL

func (*Queries) GetStuckNarFiles

func (q *Queries) GetStuckNarFiles(ctx context.Context, arg GetStuckNarFilesParams) ([]GetStuckNarFilesRow, error)

Get NAR files that are stuck (not chunked, no active chunking, and older than the given age). This is used by the CDC lazy recovery job to find NARs that failed to chunk due to restart.

SELECT id, hash, compression, query, file_size
FROM nar_files
WHERE total_chunks = 0
  AND chunking_started_at IS NULL
  AND created_at < ?
ORDER BY id
LIMIT ?

func (*Queries) GetUnmigratedNarInfoHashes added in v0.8.0

func (q *Queries) GetUnmigratedNarInfoHashes(ctx context.Context) ([]string, error)

Get all narinfo hashes that have no URL (unmigrated).

SELECT hash
FROM narinfos
WHERE url IS NULL

func (*Queries) HasAnyChunkedNarFiles added in v0.9.3

func (q *Queries) HasAnyChunkedNarFiles(ctx context.Context) (bool, error)

Returns true if any nar_file has total_chunks > 0 (used for CDC auto-detection).

SELECT EXISTS(SELECT 1 FROM nar_files WHERE total_chunks > 0) AS "exists"

func (*Queries) LinkNarFileToChunk added in v0.9.0

func (q *Queries) LinkNarFileToChunk(ctx context.Context, arg LinkNarFileToChunkParams) error

LinkNarFileToChunk

INSERT IGNORE INTO nar_file_chunks (
    nar_file_id, chunk_id, chunk_index
) VALUES (
    ?, ?, ?
)

func (*Queries) LinkNarFileToChunks added in v0.9.0

func (q *Queries) LinkNarFileToChunks(ctx context.Context, arg LinkNarFileToChunksParams) error

@bulk-for LinkNarFileToChunk

INSERT IGNORE INTO nar_file_chunks (
    nar_file_id, chunk_id, chunk_index
) VALUES (
    ?, ?, ?
)

func (*Queries) LinkNarInfoToNarFile

func (q *Queries) LinkNarInfoToNarFile(ctx context.Context, arg LinkNarInfoToNarFileParams) error

LinkNarInfoToNarFile

INSERT INTO narinfo_nar_files (
    narinfo_id, nar_file_id
) VALUES (
    ?, ?
)
ON DUPLICATE KEY UPDATE narinfo_id = narinfo_id

func (*Queries) LinkNarInfosByURLToNarFile added in v0.9.0

func (q *Queries) LinkNarInfosByURLToNarFile(ctx context.Context, arg LinkNarInfosByURLToNarFileParams) error

LinkNarInfosByURLToNarFile

INSERT IGNORE INTO narinfo_nar_files (narinfo_id, nar_file_id)
SELECT id, ?
FROM narinfos
WHERE url = ?

func (*Queries) SetConfig

func (q *Queries) SetConfig(ctx context.Context, arg SetConfigParams) error

SetConfig

INSERT INTO config (
    `key`, value
) VALUES (
    ?, ?
)
ON DUPLICATE KEY UPDATE
    value = VALUES(value),
    updated_at = CURRENT_TIMESTAMP

func (*Queries) SetNarFileChunkingStarted added in v0.9.0

func (q *Queries) SetNarFileChunkingStarted(ctx context.Context, id int64) error

SetNarFileChunkingStarted

UPDATE nar_files
SET chunking_started_at = CURRENT_TIMESTAMP, updated_at = CURRENT_TIMESTAMP
WHERE id = ?

func (*Queries) TouchNarFile

func (q *Queries) TouchNarFile(ctx context.Context, arg TouchNarFileParams) (int64, error)

TouchNarFile

UPDATE nar_files
SET
    last_accessed_at = CURRENT_TIMESTAMP,
    updated_at = CURRENT_TIMESTAMP
WHERE hash = ? AND compression = ? AND `query` = ?

func (*Queries) TouchNarInfo

func (q *Queries) TouchNarInfo(ctx context.Context, hash string) (int64, error)

TouchNarInfo

UPDATE narinfos
SET
    last_accessed_at = CURRENT_TIMESTAMP,
    updated_at = CURRENT_TIMESTAMP
WHERE hash = ?

func (*Queries) UpdateNarFileFileSize added in v0.9.0

func (q *Queries) UpdateNarFileFileSize(ctx context.Context, arg UpdateNarFileFileSizeParams) error

UpdateNarFileFileSize

UPDATE nar_files
SET file_size = ?, updated_at = CURRENT_TIMESTAMP
WHERE id = ?

func (*Queries) UpdateNarFileTotalChunks added in v0.9.0

func (q *Queries) UpdateNarFileTotalChunks(ctx context.Context, arg UpdateNarFileTotalChunksParams) error

UpdateNarFileTotalChunks

UPDATE nar_files
SET total_chunks = ?, file_size = ?, updated_at = CURRENT_TIMESTAMP, chunking_started_at = NULL
WHERE id = ?

func (*Queries) UpdateNarFileVerifiedAt added in v0.9.3

func (q *Queries) UpdateNarFileVerifiedAt(ctx context.Context, id int64) error

UpdateNarFileVerifiedAt

UPDATE nar_files
SET verified_at = CURRENT_TIMESTAMP
WHERE id = ?

func (*Queries) UpdateNarInfo added in v0.9.0

func (q *Queries) UpdateNarInfo(ctx context.Context, arg UpdateNarInfoParams) (sql.Result, error)

UpdateNarInfo

UPDATE narinfos
SET
    store_path = ?,
    url = ?,
    compression = ?,
    file_hash = ?,
    file_size = ?,
    nar_hash = ?,
    nar_size = ?,
    deriver = ?,
    system = ?,
    ca = ?,
    updated_at = CURRENT_TIMESTAMP
WHERE hash = ?

func (*Queries) UpdateNarInfoCompressionAndURL added in v0.9.0

func (q *Queries) UpdateNarInfoCompressionAndURL(ctx context.Context, arg UpdateNarInfoCompressionAndURLParams) (int64, error)

Update narinfo compression and URL after CDC migration.

UPDATE narinfos
SET compression = ?, url = ?, updated_at = CURRENT_TIMESTAMP
WHERE url = ?

func (*Queries) UpdateNarInfoCompressionFileSizeHashAndURL added in v0.9.0

func (q *Queries) UpdateNarInfoCompressionFileSizeHashAndURL(ctx context.Context, arg UpdateNarInfoCompressionFileSizeHashAndURLParams) (int64, error)

Update narinfo compression, file_size, file_hash and URL after CDC migration.

UPDATE narinfos
SET
    compression = ?,
    url = ?,
    file_size = ?,
    file_hash = ?,
    updated_at = CURRENT_TIMESTAMP
WHERE url = ?

func (*Queries) UpdateNarInfoFileHash added in v0.9.0

func (q *Queries) UpdateNarInfoFileHash(ctx context.Context, arg UpdateNarInfoFileHashParams) error

UpdateNarInfoFileHash

UPDATE narinfos
SET file_hash = ?, updated_at = CURRENT_TIMESTAMP
WHERE hash = ?

func (*Queries) UpdateNarInfoFileSize added in v0.9.0

func (q *Queries) UpdateNarInfoFileSize(ctx context.Context, arg UpdateNarInfoFileSizeParams) error

UpdateNarInfoFileSize

UPDATE narinfos
SET file_size = ?, updated_at = CURRENT_TIMESTAMP
WHERE hash = ?

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type SetConfigParams

type SetConfigParams struct {
	Key   string
	Value string
}

type TouchNarFileParams added in v0.8.0

type TouchNarFileParams struct {
	Hash        string
	Compression string
	Query       string
}

type UpdateNarFileFileSizeParams added in v0.9.0

type UpdateNarFileFileSizeParams struct {
	FileSize uint64
	ID       int64
}

type UpdateNarFileTotalChunksParams added in v0.9.0

type UpdateNarFileTotalChunksParams struct {
	TotalChunks int64
	FileSize    uint64
	ID          int64
}

type UpdateNarInfoCompressionAndURLParams added in v0.9.0

type UpdateNarInfoCompressionAndURLParams struct {
	Compression sql.NullString
	NewUrl      sql.NullString
	OldUrl      sql.NullString
}

type UpdateNarInfoCompressionFileSizeHashAndURLParams added in v0.9.0

type UpdateNarInfoCompressionFileSizeHashAndURLParams struct {
	Compression sql.NullString
	NewUrl      sql.NullString
	FileSize    sql.NullInt64
	FileHash    sql.NullString
	OldUrl      sql.NullString
}

type UpdateNarInfoFileHashParams added in v0.9.0

type UpdateNarInfoFileHashParams struct {
	FileHash sql.NullString
	Hash     string
}

type UpdateNarInfoFileSizeParams added in v0.9.0

type UpdateNarInfoFileSizeParams struct {
	FileSize sql.NullInt64
	Hash     string
}

type UpdateNarInfoParams added in v0.9.0

type UpdateNarInfoParams struct {
	StorePath   sql.NullString
	URL         sql.NullString
	Compression sql.NullString
	FileHash    sql.NullString
	FileSize    sql.NullInt64
	NarHash     sql.NullString
	NarSize     sql.NullInt64
	Deriver     sql.NullString
	System      sql.NullString
	Ca          sql.NullString
	Hash        string
}

Jump to

Keyboard shortcuts

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