Documentation
¶
Overview ¶
Package down provides the common aspects among all downwards database schema migrators. This package may be imported by its sub-packages in order to provide the Migrator[S, D] generic interface for them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Migrator ¶
type Migrator[S any, D any] interface { // Settler returns a settler object (with S type) without performing // any migration action (so, no error condition may arise). Returned // settler object may be employed to persist the migration results. Settler() S // MigrateDown migrates from current major version to the previous // major version by creating relevant views in a schema such as migN // based on the views in a schema such as migM where N=M-1 // considering the latest supported minor versions of those N and M // major versions. It may be necessary to create tables and // materialize data items or load them in the Golang process memory // in more complex scenarios, but using views is preferred as it // postpones the actual data copying till the last schema and // the settlement phase. // It then creates another downwards migrator object (with D type) // which can be used for continuing the downwards migration from // the previous major version similarly. MigrateDown(ctx context.Context) (D, error) }
Migrator of S and D is a generic interface which presents expectations from a version-dependent database schema downwards migrator object. Each downwards migrator needs a MigrateDown method which is responsible to migrate one major version downwards (staying at the latest supported minor version). The D type parameter indicates the previous downwards migrator type and S type parameter indicates the settler object type. After reaching to the target major version, Settler method can be used to obtain the corresponding settler object with type S and persist the migration results.
This generic interface must be implemented by all dnmigN.Migrator types. It is useful for causing compile-time errors and catching programming errors when an old dnmigN package is copied, but its methods are not updated properly in order to reflect the new version.
Directories
¶
Path | Synopsis |
---|---|
Package dnmig1 provides a downwards database schema Migrator type for major version 1 and its corresponding Adapter type which can adapt it to the version independent repo.DownMigrator[repo.SchemaSettler] interface.
|
Package dnmig1 provides a downwards database schema Migrator type for major version 1 and its corresponding Adapter type which can adapt it to the version independent repo.DownMigrator[repo.SchemaSettler] interface. |