db

package
v0.0.0-...-087457d Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PostgresFunctions = []PostgresFunction{
	{
		Name:       "job_results",
		Definition: jobResultFunction,
	},
	{
		Name:       "test_results",
		Definition: testResultFunction,
	},
}
View Source
var PostgresMatViews = []PostgresView{
	{
		Name:         "prow_test_report_7d_matview",
		Definition:   testReportMatView,
		IndexColumns: []string{"id", "name", "release", "variants", "suite_name"},
		ReplaceStrings: map[string]string{
			"|||START|||":    "|||TIMENOW||| - INTERVAL '14 DAY'",
			"|||BOUNDARY|||": "|||TIMENOW||| - INTERVAL '7 DAY'",
			"|||END|||":      "|||TIMENOW|||",
		},
	},
	{
		Name:         "prow_test_report_2d_matview",
		Definition:   testReportMatView,
		IndexColumns: []string{"id", "name", "release", "variants", "suite_name"},
		ReplaceStrings: map[string]string{
			"|||START|||":    "|||TIMENOW||| - INTERVAL '9 DAY'",
			"|||BOUNDARY|||": "|||TIMENOW||| - INTERVAL '2 DAY'",
			"|||END|||":      "|||TIMENOW|||",
		},
	},
	{
		Name:         "prow_job_runs_report_matview",
		Definition:   jobRunsReportMatView,
		IndexColumns: []string{"id"},
	},
	{
		Name:         "prow_job_failed_tests_by_day_matview",
		Definition:   prowJobFailedTestsMatView,
		IndexColumns: []string{"period", "prow_job_id", "test_name"},
		ReplaceStrings: map[string]string{
			"|||BY|||": "day",
		},
	},
	{
		Name:         "prow_job_failed_tests_by_hour_matview",
		Definition:   prowJobFailedTestsMatView,
		IndexColumns: []string{"period", "prow_job_id", "test_name"},
		ReplaceStrings: map[string]string{
			"|||BY|||": "hour",
		},
	},
	{

		Name:           "payload_test_failures_14d_matview",
		Definition:     payloadTestFailuresMatView,
		IndexColumns:   []string{"release", "architecture", "stream", "prow_job_run_id", "test_id", "suite_id"},
		ReplaceStrings: map[string]string{},
	},
}

TODO: for historical sippy we need to specify the pinnedDate and not use NOW

View Source
var PostgresPartitionedTables = []PostgresView{
	{
		Name:       "test_analysis_by_job_by_dates",
		Definition: testAnalysisByJobByDatesTable,
	},
}

PostgresPartitionedTables are special tables we do not let gorm manage due to very specific requirements (partitioning). Schema for these cannot be updated without a significant migration due to the partitioning.

View Source
var PostgresViews = []PostgresView{
	{
		Name:       "prow_test_analysis_by_variant_14d_view",
		Definition: testAnalysisByVariantView,
	},
}

PostgresViews are regular, non-materialized views:

Functions

func ParseGormLogLevel

func ParseGormLogLevel(logLevel string) (gormlogger.LogLevel, error)

Types

type DB

type DB struct {
	DB *gorm.DB

	// BatchSize is used for how many insertions we should do at once. Postgres supports
	// a maximum of 2^16 records per insert.
	BatchSize int
}

func New

func New(dsn string, logLevel gormlogger.LogLevel) (*DB, error)

func (*DB) UpdateSchema

func (d *DB) UpdateSchema(reportEnd *time.Time) error

type PostgresFunction

type PostgresFunction struct {
	Name       string
	Definition string
}

type PostgresView

type PostgresView struct {
	// Name is the name of the materialized view in postgres.
	Name string
	// Definition is the material view definition.
	Definition string
	// ReplaceStrings is a map of strings we want to replace in the create view statement, allowing for re-use.
	ReplaceStrings map[string]string
	// IndexColumns are the columns to create a unique index for. Will be named idx_[Name] and automatically
	// replaced if changes are made to these values. IndexColumns are required as we need them defined to be able to
	// refresh materialized views concurrently. (avoiding locking reads for several minutes while we update)
	IndexColumns []string
}

type SchemaHashType

type SchemaHashType string

Directories

Path Synopsis
These types are used to decode information from ci-search, but we don't want to expose these for anyone else.
These types are used to decode information from ci-search, but we don't want to expose these for anyone else.

Jump to

Keyboard shortcuts

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