Help us shape the future of Go! Take the 2026 Go Developer Survey

tablesync

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tablesync keeps table configuration in step with the database.

Editing YAML by hand and having a tool rewrite it are usually in tension: the tool reformats, drops comments, and reorders keys, so people stop trusting it and stop running it. This package edits the syntax tree and prints it back, which preserves comments, blank lines, and key order exactly. The only thing that changes is what was asked for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(changes []Change) error

Apply writes the planned changes.

Types

type Change

type Change struct {
	Kind  ChangeKind
	Table string
	Path  string
	// Content is the file to write. Empty for an orphan.
	Content string
	// Notes describe what changed, for reporting.
	Notes []string
}

Change is one file's worth of work.

func Plan

func Plan(schema ir.Schema, set *tableconf.Set, pathFor func(table string) string, opt Options) ([]Change, error)

Plan works out what needs to change without writing anything.

type ChangeKind

type ChangeKind string

ChangeKind is what a Change does to a file.

const (
	// ChangeCreate writes a configuration file for a table that has none.
	ChangeCreate ChangeKind = "create"
	// ChangeUpdate adds or removes entries in an existing file.
	ChangeUpdate ChangeKind = "update"
	// ChangeOrphan reports a file whose table is gone. rig does not delete it:
	// it may hold endpoint definitions that took real work, and a flag is not
	// enough authority to throw those away.
	ChangeOrphan ChangeKind = "orphan"
)

type Options

type Options struct {
	Namer *naming.Namer
	// Prune removes entries for columns and enum values that no longer exist.
	Prune bool
	// Only limits the sync to one table.
	Only string
}

Options tune a sync.

Jump to

Keyboard shortcuts

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