Documentation
¶
Overview ¶
Package migrate applies declarative Atlas HCL schemas to PostgreSQL databases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply loads colocated HCL and SQL migrations from schemaFS. SQL scripts marked phase pre run before the Atlas realm diff; all other SQL defaults to the post phase. Declared PostgreSQL roles and permissions are reconciled last. Tables absent from a partial schema bundle are never dropped unless WithTableDrops is supplied.
Types ¶
type Option ¶
type Option func(*options)
Option configures an HCL migration.
func WithExclude ¶
WithExclude excludes database objects from Atlas inspection. Values use Atlas's schema inspection patterns (for example "table.column").
func WithName ¶
WithName sets the metadata scope used for SQL hashes and managed security. It should be stable and unique for each migration bundle sharing a database.
func WithTableDrops ¶
func WithTableDrops() Option
WithTableDrops allows HCL files to remove tables. Drops are suppressed by default so a partial schema bundle cannot delete tables owned by consumers.
type SchemaProvisioner ¶ added in v0.1.26
type SchemaProvisioner struct {
// contains filtered or unexported fields
}
SchemaProvisioner prepares reusable dbtest templates and reconciles each cloned database using the same migration behavior as Apply.
func NewProvisioner ¶ added in v0.1.26
func NewProvisioner(schemaFS fs.FS, opts ...Option) *SchemaProvisioner
NewProvisioner adapts an HCL migration bundle to dbtest.Provisioner without coupling the migrate package to dbtest. Options are frozen at construction.
func (*SchemaProvisioner) Fingerprint ¶ added in v0.1.26
func (p *SchemaProvisioner) Fingerprint(ctx context.Context) (string, error)
Fingerprint returns a deterministic identity for all inputs that affect the database produced by this provisioner.
func (*SchemaProvisioner) PrepareInstance ¶ added in v0.1.26
func (p *SchemaProvisioner) PrepareInstance(ctx context.Context, connection string) error
PrepareInstance reconciles instance-specific and always-run migrations after cloning a prepared template.
func (*SchemaProvisioner) PrepareTemplate ¶ added in v0.1.26
func (p *SchemaProvisioner) PrepareTemplate(ctx context.Context, connection string) error
PrepareTemplate applies the full migration bundle to a new template.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package viewdeps finds, drops, and restores the views and materialized views that transitively depend on a set of tables, so DDL PostgreSQL refuses while a dependent view exists — DROP TABLE, DROP COLUMN, ALTER COLUMN TYPE — can proceed.
|
Package viewdeps finds, drops, and restores the views and materialized views that transitively depend on a set of tables, so DDL PostgreSQL refuses while a dependent view exists — DROP TABLE, DROP COLUMN, ALTER COLUMN TYPE — can proceed. |