Documentation ¶
Index ¶
- func GenerateDiff(ctx context.Context, logger hclog.Logger, conn *pgxpool.Conn, ...) error
- func GenerateFull(ctx context.Context, logger hclog.Logger, p *provider.Provider, ...) error
- func Run(ctx context.Context, p *provider.Provider, outputPath string) error
- func RunMigrationsTest(t *testing.T, prov *provider.Provider, additionalVersionsToTest []string)
- type TableCreator
- func (m TableCreator) CreateTable(ctx context.Context, conn execution.QueryExecer, t, p *schema.Table) error
- func (m TableCreator) CreateTableDefinitions(ctx context.Context, t *schema.Table, parent *schema.Table) (up, down []string, err error)
- func (m TableCreator) DiffTable(ctx context.Context, conn *pgxpool.Conn, schemaName string, ...) (up, down []string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateDiff ¶
func GenerateDiff(ctx context.Context, logger hclog.Logger, conn *pgxpool.Conn, schemaName string, dialectType schema.DialectType, p *provider.Provider, outputPath, prefix string) error
GenerateDiff creates incremental table migrations for the provider based on it's ResourceMap. Entities are compared to a given conn.
func GenerateFull ¶
func GenerateFull(ctx context.Context, logger hclog.Logger, p *provider.Provider, dialects []schema.DialectType, outputPath, prefix string) error
GenerateFull creates initial table migrations for the provider based on it's ResourceMap
Types ¶
type TableCreator ¶
type TableCreator struct {
// contains filtered or unexported fields
}
TableCreator handles creation of schema.Table in database as SQL strings
func NewTableCreator ¶
func NewTableCreator(log hclog.Logger, dialect schema.Dialect) *TableCreator
func (TableCreator) CreateTable ¶
func (m TableCreator) CreateTable(ctx context.Context, conn execution.QueryExecer, t, p *schema.Table) error
CreateTable generates CREATE TABLE definitions for the given table and runs them on the given conn
func (TableCreator) CreateTableDefinitions ¶
func (m TableCreator) CreateTableDefinitions(ctx context.Context, t *schema.Table, parent *schema.Table) (up, down []string, err error)
CreateTableDefinitions reads schema.Table and builds the CREATE TABLE and DROP TABLE statements for it, also processing and returning subrelation tables
func (TableCreator) DiffTable ¶
func (m TableCreator) DiffTable(ctx context.Context, conn *pgxpool.Conn, schemaName string, t, parent *schema.Table) (up, down []string, err error)
DiffTable reads current table info from the given conn for the given table, and returns ALTER TABLE ADD COLUMN statements for the missing columns. Newly appearing tables will return a CREATE TABLE statement. Column renames are detected (best effort) and ALTER TABLE RENAME COLUMN statements are generated as comments. Table renames or removals are not detected. FK changes are not detected.
Directories ¶
Path | Synopsis |
---|---|
https://github.com/jpillora/longestcommon Doesn't have go.mod file
|
https://github.com/jpillora/longestcommon Doesn't have go.mod file |