Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed Oct 14, 2023
1 parent 431499f commit 7040b22
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func NewProvider(dialect string, db *sql.DB, fsys fs.FS, opts ...ProviderOption)
}

// Provider is a goose migration provider.
// Experimental: This API is experimental and may change in the future.
type Provider struct {
db *sql.DB
fsys fs.FS
Expand All @@ -99,15 +98,13 @@ type MigrationStatus struct {

// Status returns the status of all migrations, merging the list of migrations from the database and
// filesystem. The returned items are ordered by version, in ascending order.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) Status(ctx context.Context) ([]*MigrationStatus, error) {
return nil, errors.New("not implemented")
}

// GetDBVersion returns the max version from the database, regardless of the applied order. For
// example, if migrations 1,4,2,3 were applied, this method returns 4. If no migrations have been
// applied, it returns 0.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) GetDBVersion(ctx context.Context) (int64, error) {
return 0, errors.New("not implemented")
}
Expand All @@ -122,16 +119,11 @@ const (
SourceTypeGo SourceType = "go"
)

func (t SourceType) String() string {
return string(t)
}

// Source represents a single migration source.
//
// For SQL migrations, Fullpath will always be set. For Go migrations, Fullpath will will be set if
// the migration has a corresponding file on disk. It will be empty if the migration was registered
// manually.
// Experimental: This API is experimental and may change in the future.
type Source struct {
// Type is the type of migration.
Type SourceType
Expand All @@ -143,8 +135,8 @@ type Source struct {
Version int64
}

// ListSources returns a list of all available migration sources the provider is aware of.
// Experimental: This API is experimental and may change in the future.
// ListSources returns a list of all available migration sources the provider is aware of, sorted in
// ascending order by version.
func (p *Provider) ListSources() []*Source {
sources := make([]*Source, 0, len(p.migrations))
for _, m := range p.migrations {
Expand All @@ -164,15 +156,13 @@ func (p *Provider) ListSources() []*Source {
}

// Ping attempts to ping the database to verify a connection is available.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) Ping(ctx context.Context) error {
return errors.New("not implemented")
return p.db.PingContext(ctx)
}

// Close closes the database connection.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) Close() error {
return errors.New("not implemented")
return p.db.Close()
}

// MigrationResult represents the result of a single migration.
Expand All @@ -184,21 +174,18 @@ type MigrationResult struct{}
//
// When direction is true, the up migration is executed, and when direction is false, the down
// migration is executed.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) ApplyVersion(ctx context.Context, version int64, direction bool) (*MigrationResult, error) {
return nil, errors.New("not implemented")
}

// Up applies all pending migrations. If there are no new migrations to apply, this method returns
// empty list and nil error.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) Up(ctx context.Context) ([]*MigrationResult, error) {
return nil, errors.New("not implemented")
}

// UpByOne applies the next available migration. If there are no migrations to apply, this method
// returns [ErrNoNextVersion].
// Experimental: This API is experimental and may change in the future.
func (p *Provider) UpByOne(ctx context.Context) (*MigrationResult, error) {
return nil, errors.New("not implemented")
}
Expand All @@ -208,14 +195,12 @@ func (p *Provider) UpByOne(ctx context.Context) (*MigrationResult, error) {
//
// For instance, if there are three new migrations (9,10,11) and the current database version is 8
// with a requested version of 10, only versions 9 and 10 will be applied.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) UpTo(ctx context.Context, version int64) ([]*MigrationResult, error) {
return nil, errors.New("not implemented")
}

// Down rolls back the most recently applied migration. If there are no migrations to apply, this
// method returns [ErrNoNextVersion].
// Experimental: This API is experimental and may change in the future.
func (p *Provider) Down(ctx context.Context) (*MigrationResult, error) {
return nil, errors.New("not implemented")
}
Expand All @@ -224,7 +209,6 @@ func (p *Provider) Down(ctx context.Context) (*MigrationResult, error) {
//
// For instance, if the current database version is 11, and the requested version is 9, only
// migrations 11 and 10 will be rolled back.
// Experimental: This API is experimental and may change in the future.
func (p *Provider) DownTo(ctx context.Context, version int64) ([]*MigrationResult, error) {
return nil, errors.New("not implemented")
}

0 comments on commit 7040b22

Please sign in to comment.