Documentation
¶
Overview ¶
Package edition provides internal structs for the schema package for defining and organizing database migration editions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect string
Dialect is a specific SQL language variant. This generally is the same as a specific SQL server implementation.
type Edition ¶
type Edition struct {
// The identifier of an edition. The Name and Dialect pair should be unique.
Name string
// The specific SQL language variant that the Migrtions are for. The Name
// and Dialect pair should be unique.
Dialect Dialect
// The latest version of the schema for this edition that this binary supports.
LatestVersion int
// The set of migrations that should be applied to a database to reach the latest version.
// This is a map of schema versions to sql.
Migrations map[int][]byte
// Priority is used to determine the order that multiple Editions should be applied.
Priority int
}
Edition is a collection of sql statements along with a version number. It is used to apply changes to the database instance.
func New ¶
New creates an Edition with the provided parameters. The embed.FS m will be walked to extract the sql statements. The priority is used to determine when this Edition's migrations are applied relative to other Editions. A lower number indicates a higher priority. New will panic if the structure of the embed.FS is not correct. The files must be structured as follows:
<majorVersion>/
<minorVersion>_<description>.up.sql
Where majorVersion and minorVersion are integers. There can be any number of leading directories prior to the major versions. For example a directory structure like the following is correct:
migrations/oss/postgres/ 0/ 01_initial.up.sql 1/ 01_add_columns.up.sql 02_rename_table.up.sql 2/ 01_add_new_table.up.sql 02_refactor_views.up.sql