2025-01-20 17:45:33 +05:30
|
|
|
package sqlmigrationtest
|
2025-01-17 16:52:55 +05:30
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/uptrace/bun"
|
|
|
|
|
"github.com/uptrace/bun/migrate"
|
|
|
|
|
"go.signoz.io/signoz/pkg/factory"
|
2025-01-20 17:45:33 +05:30
|
|
|
"go.signoz.io/signoz/pkg/sqlmigration"
|
2025-01-17 16:52:55 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type noopMigration struct{}
|
|
|
|
|
|
2025-01-20 17:45:33 +05:30
|
|
|
func NoopMigrationFactory() factory.ProviderFactory[sqlmigration.SQLMigration, sqlmigration.Config] {
|
|
|
|
|
return factory.NewProviderFactory(factory.MustNewName("noop"), func(_ context.Context, _ factory.ProviderSettings, _ sqlmigration.Config) (sqlmigration.SQLMigration, error) {
|
2025-01-17 16:52:55 +05:30
|
|
|
return &noopMigration{}, nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (migration *noopMigration) Register(migrations *migrate.Migrations) error {
|
|
|
|
|
if err := migrations.Register(migration.Up, migration.Down); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (migration *noopMigration) Up(ctx context.Context, db *bun.DB) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (migration *noopMigration) Down(ctx context.Context, db *bun.DB) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|