mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-04 11:25:52 +08:00

### Summary feat(.): initialize all factories #### Related Issues / PR's Removed all redundant commits of https://github.com/SigNoz/signoz/pull/6843 Closes https://github.com/SigNoz/signoz/pull/6782
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package sqlmigration
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/uptrace/bun"
|
|
"github.com/uptrace/bun/migrate"
|
|
"go.signoz.io/signoz/pkg/factory"
|
|
)
|
|
|
|
type addPipelines struct{}
|
|
|
|
func NewAddPipelinesFactory() factory.ProviderFactory[SQLMigration, Config] {
|
|
return factory.NewProviderFactory(factory.MustNewName("add_pipelines"), newAddPipelines)
|
|
}
|
|
|
|
func newAddPipelines(_ context.Context, _ factory.ProviderSettings, _ Config) (SQLMigration, error) {
|
|
return &addPipelines{}, nil
|
|
}
|
|
|
|
func (migration *addPipelines) Register(migrations *migrate.Migrations) error {
|
|
if err := migrations.Register(migration.Up, migration.Down); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (migration *addPipelines) Up(ctx context.Context, db *bun.DB) error {
|
|
if _, err := db.ExecContext(ctx, `CREATE TABLE IF NOT EXISTS pipelines(
|
|
id TEXT PRIMARY KEY,
|
|
order_id INTEGER,
|
|
enabled BOOLEAN,
|
|
created_by TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
name VARCHAR(400) NOT NULL,
|
|
alias VARCHAR(20) NOT NULL,
|
|
description TEXT,
|
|
filter TEXT NOT NULL,
|
|
config_json TEXT
|
|
);`); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (migration *addPipelines) Down(ctx context.Context, db *bun.DB) error {
|
|
return nil
|
|
}
|