sqlcommon

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPostgresDSN

func BuildPostgresDSN(c *models.DriverCredentials) (string, error)

BuildPostgresDSN builds a libpq URL for pgdriver from credentials.

func ErrCredentialsRequired

func ErrCredentialsRequired() error

ErrCredentialsRequired is returned when driver credentials are missing.

func ExecAlterIgnoreDuplicate

func ExecAlterIgnoreDuplicate(ctx context.Context, db *bun.DB, sql string) error

ExecAlterIgnoreDuplicate runs ALTER DDL and ignores duplicate-column errors.

func IsDuplicateColumnError

func IsDuplicateColumnError(err error) bool

IsDuplicateColumnError reports duplicate column DDL errors.

func IsSQLUniqueViolation

func IsSQLUniqueViolation(err error) bool

IsSQLUniqueViolation reports primary/unique constraint violations across SQL engines.

func NormalizeEngine

func NormalizeEngine(engine string) string

NormalizeEngine returns the canonical engine constant.

func OpenMariaDB

func OpenMariaDB(cred *models.DriverCredentials) (*bun.DB, error)

OpenMariaDB opens a MariaDB system database (same driver as MySQL).

func OpenMySQL

func OpenMySQL(cred *models.DriverCredentials) (*bun.DB, error)

OpenMySQL opens a MySQL system database.

func OpenPostgres

func OpenPostgres(cred *models.DriverCredentials) (*bun.DB, error)

OpenPostgres opens a PostgreSQL system database.

func OpenSQLite

func OpenSQLite(cfg *models.Config, cred *models.DriverCredentials) (*bun.DB, error)

OpenSQLite opens a local SQLite system database.

func RegisterSystemSQLSchemaModels

func RegisterSystemSQLSchemaModels(orm *bun.DB)

RegisterSystemSQLSchemaModels registers m2m join types (user_projects, etc.) on this *bun.DB. Required for any query touching models with bun m2m tags — not only during RunMigration. Call once per opened system DB connection (idempotent).

func SupportedEngine

func SupportedEngine(engine string) bool

SupportedEngine reports whether the engine string is a supported open-core system SQL engine.

func SystemSQLSchemaModels

func SystemSQLSchemaModels() []interface{}

SystemSQLSchemaModels returns the full ordered list of tables for RunMigration.

Types

type Base

type Base struct {
	Conf             *models.Config
	ORM              *bun.DB
	DriverCredential *models.DriverCredentials
}

Base holds shared Bun ORM state for all SQL system drivers.

type Driver

type Driver struct {
	Base
}

Driver embeds Base for system SQL drivers.

type OrganizationProjectRow

type OrganizationProjectRow struct {
	bun.BaseModel `bun:"table:organization_projects"`

	OrganizationID string `bun:"organization_id,type:uuid,pk"`
	ProjectID      string `bun:"project_id,type:uuid,pk"`
	AssignedBy     string `bun:"assigned_by,type:uuid,nullzero"`
	AssignedAt     string `bun:"assigned_at,type:timestamp,nullzero"`
}

type ProjectTeamRow

type ProjectTeamRow struct {
	bun.BaseModel `bun:"table:project_teams"`

	ProjectID string `bun:"project_id,type:uuid,pk"`
	UserID    string `bun:"user_id,type:uuid,pk"`
}

type RawDataRow

type RawDataRow struct {
	bun.BaseModel `bun:"table:raw_data"`

	ID         string `bun:"id,pk,type:uuid"`
	Collection string `bun:"collection,type:text"`
	Data       string `bun:"data,type:text"`
}

type TeamMetadataRow

type TeamMetadataRow struct {
	bun.BaseModel `bun:"table:team_metadata"`

	ID   string `bun:"id,pk,type:uuid"`
	Data string `bun:"data,type:text"`
}

type TokenBlacklistRow

type TokenBlacklistRow struct {
	bun.BaseModel `bun:"table:token_blacklist"`

	TokenID string `bun:"token_id,pk,type:text"`
	Data    string `bun:"data,type:text"`
}

type UserMetadataRow

type UserMetadataRow struct {
	bun.BaseModel `bun:"table:user_metadata"`

	ID   string `bun:"id,pk,type:uuid"`
	Data string `bun:"data,type:text"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL