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)
- func RunMigrationsTestWithNewDB(t *testing.T, dbDSN string, newDBName string, prov *provider.Provider, ...)
- type TableCreator
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
func RunMigrationsTest ¶
RunMigrationsTest helper tests the migration files of the provider using the database (and dialect) specified in CQ_MIGRATION_TEST_DSN
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) 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 |