{"modulePath":"github.com/apito-io/engine","version":"v1.7.4","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sqlcommon\n\n## Functions\n\n```go\nfunc BuildPostgresDSN(c *models.DriverCredentials) (string, error)\n```\nBuildPostgresDSN builds a libpq URL for pgdriver from credentials.\n\n```go\nfunc ErrCredentialsRequired() error\n```\nErrCredentialsRequired is returned when driver credentials are missing.\n\n```go\nfunc ExecAlterIgnoreDuplicate(ctx context.Context, db *bun.DB, sql string) error\n```\nExecAlterIgnoreDuplicate runs ALTER DDL and ignores duplicate-column errors.\n\n```go\nfunc IsDuplicateColumnError(err error) bool\n```\nIsDuplicateColumnError reports duplicate column DDL errors.\n\n```go\nfunc IsSQLUniqueViolation(err error) bool\n```\nIsSQLUniqueViolation reports primary/unique constraint violations across SQL engines.\n\n```go\nfunc NormalizeEngine(engine string) string\n```\nNormalizeEngine returns the canonical engine constant.\n\n```go\nfunc OpenMariaDB(cred *models.DriverCredentials) (*bun.DB, error)\n```\nOpenMariaDB opens a MariaDB system database (same driver as MySQL).\n\n```go\nfunc OpenMySQL(cred *models.DriverCredentials) (*bun.DB, error)\n```\nOpenMySQL opens a MySQL system database.\n\n```go\nfunc OpenPostgres(cred *models.DriverCredentials) (*bun.DB, error)\n```\nOpenPostgres opens a PostgreSQL system database.\n\n```go\nfunc OpenSQLite(cfg *models.Config, cred *models.DriverCredentials) (*bun.DB, error)\n```\nOpenSQLite opens a local SQLite system database.\n\n```go\nfunc RegisterSystemSQLSchemaModels(orm *bun.DB)\n```\nRegisterSystemSQLSchemaModels 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).\n\n```go\nfunc SupportedEngine(engine string) bool\n```\nSupportedEngine reports whether the engine string is a supported open-core system SQL engine.\n\n```go\nfunc SystemSQLSchemaModels() []interface{}\n```\nSystemSQLSchemaModels returns the full ordered list of tables for RunMigration.\n\n## Types\n\n```go\ntype Base struct {\n\tConf             *models.Config\n\tORM              *bun.DB\n\tDriverCredential *models.DriverCredentials\n}\n```\nBase holds shared Bun ORM state for all SQL system drivers.\n\n```go\ntype Driver struct {\n\tBase\n}\n```\nDriver embeds Base for system SQL drivers.\n\n```go\ntype OrganizationProjectRow struct {\n\tbun.BaseModel `bun:\"table:organization_projects\"`\n\n\tOrganizationID string `bun:\"organization_id,type:uuid,pk\"`\n\tProjectID      string `bun:\"project_id,type:uuid,pk\"`\n\tAssignedBy     string `bun:\"assigned_by,type:uuid,nullzero\"`\n\tAssignedAt     string `bun:\"assigned_at,type:timestamp,nullzero\"`\n}\n```\n\n```go\ntype ProjectTeamRow struct {\n\tbun.BaseModel `bun:\"table:project_teams\"`\n\n\tProjectID string `bun:\"project_id,type:uuid,pk\"`\n\tUserID    string `bun:\"user_id,type:uuid,pk\"`\n}\n```\n\n```go\ntype RawDataRow struct {\n\tbun.BaseModel `bun:\"table:raw_data\"`\n\n\tID         string `bun:\"id,pk,type:uuid\"`\n\tCollection string `bun:\"collection,type:text\"`\n\tData       string `bun:\"data,type:text\"`\n}\n```\n\n```go\ntype TeamMetadataRow struct {\n\tbun.BaseModel `bun:\"table:team_metadata\"`\n\n\tID   string `bun:\"id,pk,type:uuid\"`\n\tData string `bun:\"data,type:text\"`\n}\n```\n\n```go\ntype TokenBlacklistRow struct {\n\tbun.BaseModel `bun:\"table:token_blacklist\"`\n\n\tTokenID string `bun:\"token_id,pk,type:text\"`\n\tData    string `bun:\"data,type:text\"`\n}\n```\n\n```go\ntype UserMetadataRow struct {\n\tbun.BaseModel `bun:\"table:user_metadata\"`\n\n\tID   string `bun:\"id,pk,type:uuid\"`\n\tData string `bun:\"data,type:text\"`\n}\n```\n\n","path":"github.com/apito-io/engine/database/system/sqlcommon","name":"sqlcommon","synopsis":"","isRedistributable":true}
