expectedschema

package
v0.0.0-...-e0ff526 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package expectedschema contains the schema the database is expected to have.

This file contains useful logic for maintenance tasks to migrate new schema changes.

Maintenance tasks (see //perf/go/maintenance/maintenance.go) use the same executable as the perf frontend and ingesters, so when Louhi does an update all of them will be deployed at the same time. Since frontend and ingesters check for a correct schema they will panic on startup, so the old instances of those apps will continue to run.

The maintenance task will run and thus will upgrade the schema in the database. After that completes when frontend and ingesters are retried (k8s does that automatically), then they will start successfully. This means that any change in schema must be compatible with both the current and previous version of the perfserver executable.

Index

Constants

This section is empty.

Variables

FS is a filesystem with the schema.json file.

View Source
var FromLiveToNext = `` /* 266-byte string literal not displayed */

The two vars below should be updated everytime there's a schema change:

  • FromLiveToNext tells the SQL to execute to apply the change
  • FromNextToLive tells the SQL to revert the change

Also we need to update LiveSchema schema and DropTables in sql_test.go:

  • DropTables deletes all tables *including* the new one in the change.
  • LiveSchema creates all existing tables *without* the new one in the change.

DO NOT DROP TABLES IN VAR BELOW. FOR MODIFYING COLUMNS USE ADD/DROP COLUMN INSTEAD.

View Source
var FromNextToLive = `` /* 252-byte string literal not displayed */

ONLY DROP TABLE IF YOU JUST CREATED A NEW TABLE. FOR MODIFYING COLUMNS USE ADD/DROP COLUMN INSTEAD.

Functions

func Load

func Load() (schema.Description, error)

Load returns the deserialized schema.Description stored in the schema.json file.

func LoadPrev

func LoadPrev() (schema.Description, error)

LoadPrev returns the deserialized schema.Description stored in the schema_old.json file.

func ValidateAndMigrateNewSchema

func ValidateAndMigrateNewSchema(ctx context.Context, db pool.Pool) error

This function will check whether there's a new schema checked-in, and if so, migrate the schema in the given CockroachDB instance.

Types

This section is empty.

Jump to

Keyboard shortcuts

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