mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 21:20:36 +08:00

* feat(sqlmigration): update the alertmanager tables * feat(sqlmigration): update the alertmanager tables * feat(sqlmigration): make the preference package multi tenant * feat(preference): address nit pick comments * feat(preference): added the cascade delete for preferences * feat(sqlmigration): update apdex and TTL status tables (#7481) * feat(sqlmigration): update the apdex and ttl tables * feat(sqlmigration): register the new migration and rename table * feat(sqlmigration): fix the ttl queries * feat(sqlmigration): update the TTL and apdex tables * feat(sqlmigration): update the TTL and apdex tables * feat(sqlmigration): fix the reset password and pat tables (#7482) * feat(sqlmigration): fix the reset password and pat tables * feat(sqlmigration): revert PAT changes * feat(sqlmigration): register and rename the new migration * feat(sqlmigration): handle updates for user tables * feat(sqlmigration): remove unwanted changes
50 lines
1.8 KiB
Go
50 lines
1.8 KiB
Go
package sqlstore
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
"github.com/uptrace/bun"
|
|
)
|
|
|
|
type SQLStoreTxOptions = sql.TxOptions
|
|
|
|
type SQLStore interface {
|
|
// SQLDB returns the underlying sql.DB.
|
|
SQLDB() *sql.DB
|
|
|
|
// BunDB returns an instance of bun.DB. This is the recommended way to interact with the database.
|
|
BunDB() *bun.DB
|
|
|
|
// SQLxDB returns an instance of sqlx.DB. This is the legacy ORM used.
|
|
SQLxDB() *sqlx.DB
|
|
|
|
// Returns the dialect of the database.
|
|
Dialect() SQLDialect
|
|
|
|
// RunInTxCtx runs the given callback in a transaction. It creates and injects a new context with the transaction.
|
|
// If a transaction is present in the context, it will be used.
|
|
RunInTxCtx(ctx context.Context, opts *SQLStoreTxOptions, cb func(ctx context.Context) error) error
|
|
|
|
// BunDBCtx returns an instance of bun.IDB for the given context.
|
|
// If a transaction is present in the context, it will be used. Otherwise, the default will be used.
|
|
BunDBCtx(ctx context.Context) bun.IDB
|
|
}
|
|
|
|
type SQLStoreHook interface {
|
|
bun.QueryHook
|
|
}
|
|
|
|
type SQLDialect interface {
|
|
MigrateIntToTimestamp(context.Context, bun.IDB, string, string) error
|
|
MigrateIntToBoolean(context.Context, bun.IDB, string, string) error
|
|
AddNotNullDefaultToColumn(context.Context, bun.IDB, string, string, string, string) error
|
|
GetColumnType(context.Context, bun.IDB, string, string) (string, error)
|
|
ColumnExists(context.Context, bun.IDB, string, string) (bool, error)
|
|
RenameColumn(context.Context, bun.IDB, string, string, string) (bool, error)
|
|
RenameTableAndModifyModel(context.Context, bun.IDB, interface{}, interface{}, []string, func(context.Context) error) error
|
|
UpdatePrimaryKey(context.Context, bun.IDB, interface{}, interface{}, string, func(context.Context) error) error
|
|
AddPrimaryKey(context.Context, bun.IDB, interface{}, interface{}, string, func(context.Context) error) error
|
|
}
|