An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 9.2% on proxy.golang.org

proxy.golang.org : github.com/tailscale/squibble

Package squibble provides a schema migration assistant for SQLite databases. A Schema value manages the schema of a SQLite database that will be modified over time. The current database schema is stored in the Current field, and migrations from previous versions are captured as UpdateRules. When the program starts up, it should pass the open database to the Apply method of the Schema. This verifies that the Schema is valid, then checks whether the database is up-to-date. If not, it applies any relevant update rules to bring it to the current state. If Apply fails, the database is rolled back. The Schema tracks schema versions by hashing the schema with SHA256, and it stores a record of upgrades in a _schema_history table that it maintains. Apply creates this table if it does not already exist, and updates it as update rules are applied. The Updates field of the Schema must contain an ordered list of update rules for all the versions of the schema prior to the Current one, from oldest to newest. Each rule has the hash of a previous schema version and a function that can be applied to the database to upgrade it to the next version in sequence. When revising the schema, you must add a new rule mapping the old (existing) schema to the new one. These rules are intended to be a permanent record of changes, and should be committed into source control as part of the program. As a consistency check, each rule must also declare the hash of the target schema it upgrades to. When Apply runs, it looks for the most recent version of the schema recorded in the _schema_history table. If there is none, and the database is otherwise empty, the current schema is assumed to be the initial version, and it is applied directly. Otherwise, Apply compares the hash of the most recent update to the current version: If they differ, it finds the most recent update hash in the Updates list, and applies all the updates from that point forward. If this succeeds, the current schema is recorded as the latest version in _schema_history. You use the Validate function to check that the current schema in the special sqlite_schema table maintained by SQLite matches a schema written as SQL text. If not, it reports a diff describing the differences between what the text wants and what the real schema has. Currently this package only handles the main database, not attachments.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/tailscale/squibble
License: BSD-3-Clause
Latest release: 21 days ago
Namespace: github.com/tailscale
Stars: 3 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 21 days ago