sql

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterSystemSQLSchemaModels added in v1.6.1

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).

Types

type CreateStarterProjectFn added in v1.6.1

type CreateStarterProjectFn func(ctx context.Context, userID string, proj *models.Project) error

CreateStarterProjectFn creates the starter project row when it does not exist yet. proj has ID, Name, and Description set from bootstrap metadata.

type SystemSQLDriver added in v1.6.1

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

SystemSQLDriver is the open-core system DB implementation for PostgreSQL, MySQL/MariaDB, and SQLite.

func GetSystemSQLDriver

func GetSystemSQLDriver(cfg *models.Config, driverCredentials *models.DriverCredentials) (*SystemSQLDriver, error)

GetSystemSQLDriver opens a Bun-backed system database for PostgreSQL, MySQL, MariaDB, or SQLite only.

func (*SystemSQLDriver) AddATeamMemberToProject added in v1.6.1

func (p *SystemSQLDriver) AddATeamMemberToProject(ctx context.Context, req *models.TeamMemberAddRequest) error

AddATeamMemberToProject adds a team member to a project using SQL

func (*SystemSQLDriver) AddSystemUserMetaInfo added in v1.6.1

AddSystemUserMetaInfo adds metadata to a system user using SQL

func (*SystemSQLDriver) AddTeamMetaInfo added in v1.6.1

func (p *SystemSQLDriver) AddTeamMetaInfo(ctx context.Context, docs []*models.SystemUser) ([]*models.SystemUser, error)

AddTeamMetaInfo adds metadata to team members using SQL

func (*SystemSQLDriver) AddWebhookToProject added in v1.6.1

func (p *SystemSQLDriver) AddWebhookToProject(ctx context.Context, doc *models.Webhook) (*models.Webhook, error)

AddWebhookToProject adds a webhook to a project using SQL

func (*SystemSQLDriver) AssignProjectToOrganization added in v1.6.1

func (p *SystemSQLDriver) AssignProjectToOrganization(ctx context.Context, orgId, userId, projectId string) error

AssignProjectToOrganization assigns a project to an organization using SQL

func (*SystemSQLDriver) AssignTeamToOrganization added in v1.6.1

func (p *SystemSQLDriver) AssignTeamToOrganization(ctx context.Context, orgId, userId, teamId string) error

AssignTeamToOrganization assigns a team to an organization using SQL

func (*SystemSQLDriver) BlacklistAToken added in v1.6.1

func (p *SystemSQLDriver) BlacklistAToken(ctx context.Context, token map[string]interface{}) error

BlacklistAToken adds a token to the blacklist using SQL

func (*SystemSQLDriver) CheckProjectName added in v1.6.1

func (p *SystemSQLDriver) CheckProjectName(ctx context.Context, name string) error

CheckProjectName checks if a project name already exists using SQL

func (*SystemSQLDriver) CheckProjectWithRoles added in v1.6.1

func (p *SystemSQLDriver) CheckProjectWithRoles(ctx context.Context, userId, projectId string) (*models.ProjectWithRoles, error)

CheckProjectWithRoles checks if a user belongs to a project and returns roles/permissions using SQL

func (*SystemSQLDriver) CheckTeamMemberExists added in v1.6.1

func (p *SystemSQLDriver) CheckTeamMemberExists(ctx context.Context, projectId string, memberID string) error

CheckTeamMemberExists checks if a team member exists in a project using SQL

func (*SystemSQLDriver) CheckTokenBlacklisted added in v1.6.1

func (p *SystemSQLDriver) CheckTokenBlacklisted(ctx context.Context, tokenId string) error

CheckTokenBlacklisted checks if a token is blacklisted using SQL

func (*SystemSQLDriver) Close added in v1.6.1

func (p *SystemSQLDriver) Close() error

Close releases the underlying *sql.DB.

func (*SystemSQLDriver) CreateOrganization added in v1.6.1

func (p *SystemSQLDriver) CreateOrganization(ctx context.Context, org *models.Organization) (*models.Organization, error)

CreateOrganization creates a new organization using SQL

func (*SystemSQLDriver) CreateProject added in v1.6.1

func (p *SystemSQLDriver) CreateProject(ctx context.Context, userId string, project *models.Project) (*models.Project, error)

CreateProject creates a new project using SQL

func (*SystemSQLDriver) CreateSystemUser added in v1.6.1

func (p *SystemSQLDriver) CreateSystemUser(ctx context.Context, user *models.SystemUser) (*models.SystemUser, error)

CreateSystemUser creates a new system user using SQL

func (*SystemSQLDriver) CreateTeam added in v1.6.1

func (p *SystemSQLDriver) CreateTeam(ctx context.Context, team *models.Team) (*models.Team, error)

CreateTeam creates a new team using SQL

func (*SystemSQLDriver) DeleteProjectFromSystem added in v1.6.1

func (p *SystemSQLDriver) DeleteProjectFromSystem(ctx context.Context, projectId string) error

DeleteProjectFromSystem deletes a project and all related data using SQL

func (*SystemSQLDriver) DeleteWebhook added in v1.6.1

func (p *SystemSQLDriver) DeleteWebhook(ctx context.Context, projectId, hookId string) error

DeleteWebhook deletes a webhook using SQL

func (*SystemSQLDriver) EnsureBootstrapAdmin added in v1.6.1

func (p *SystemSQLDriver) EnsureBootstrapAdmin(ctx context.Context) error

EnsureBootstrapAdmin creates the default admin user if missing (idempotent). Exported for pro layered system bootstrap (e.g. libsql starter provisioned outside OSS driver defaults).

func (*SystemSQLDriver) EnsureBootstrapOrgTeamProjectWithStarterCreate added in v1.6.1

func (p *SystemSQLDriver) EnsureBootstrapOrgTeamProjectWithStarterCreate(ctx context.Context, fn CreateStarterProjectFn) error

EnsureBootstrapOrgTeamProjectWithStarterCreate seeds default team/org and links the starter project. fn is called only when the starter project row is missing (GetProject returns sql.ErrNoRows). Exported for pro builds that replace OSS starter driver creation (e.g. Turso platform provisioning).

func (*SystemSQLDriver) EnsureBootstrapProjectSettingsRow added in v1.6.1

func (p *SystemSQLDriver) EnsureBootstrapProjectSettingsRow(ctx context.Context, projectID string) error

EnsureBootstrapProjectSettingsRow ensures a project_settings row exists (idempotent). Exported for pro layered bootstrap that skips open-core ensureStarterProjectDriver.

func (*SystemSQLDriver) EnsureSystemBootstrap added in v1.6.1

func (p *SystemSQLDriver) EnsureSystemBootstrap(ctx context.Context) error

EnsureSystemBootstrap creates idempotent first-run data (default admin, org/team/project) like Mongo/Arango.

func (*SystemSQLDriver) FindOrganizationAdmin added in v1.6.1

func (p *SystemSQLDriver) FindOrganizationAdmin(ctx context.Context, orgId string) (*models.SystemUser, error)

FindOrganizationAdmin implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) FindUserOrganizations added in v1.6.1

func (p *SystemSQLDriver) FindUserOrganizations(ctx context.Context, userId string) ([]*models.Organization, error)

FindUserOrganizations retrieves all organizations for a given user using SQL

func (*SystemSQLDriver) FindUserProjects added in v1.6.1

func (p *SystemSQLDriver) FindUserProjects(ctx context.Context, userId string) ([]*models.Project, error)

FindUserProjects retrieves all projects for a given user using SQL

func (*SystemSQLDriver) FindUserProjectsWithRoles added in v1.6.1

func (p *SystemSQLDriver) FindUserProjectsWithRoles(ctx context.Context, userId string) ([]*models.ProjectWithRoles, error)

FindUserProjectsWithRoles implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) FindUserTeams added in v1.6.1

func (p *SystemSQLDriver) FindUserTeams(ctx context.Context, userId string) ([]*models.Team, error)

FindUserTeams retrieves all teams for a given user using SQL

func (*SystemSQLDriver) GetOrganizations added in v1.6.1

func (p *SystemSQLDriver) GetOrganizations(ctx context.Context, userId string) (*models.SearchResponse[models.Organization], error)

GetOrganizations implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) GetProject added in v1.6.1

func (p *SystemSQLDriver) GetProject(ctx context.Context, id string) (*models.Project, error)

GetProject retrieves a project by ID using SQL

func (*SystemSQLDriver) GetProjectTeams added in v1.6.1

func (p *SystemSQLDriver) GetProjectTeams(ctx context.Context, projectId string) (*models.Team, error)

GetProjectTeams retrieves team information for a project using SQL

func (*SystemSQLDriver) GetProjectWithRolesAndPermission added in v1.6.1

func (p *SystemSQLDriver) GetProjectWithRolesAndPermission(ctx context.Context, userId string) ([]*models.ProjectWithRoles, error)

GetProjectWithRolesAndPermission retrieves projects with roles and permissions for a user using SQL

func (*SystemSQLDriver) GetProjects added in v1.6.1

func (p *SystemSQLDriver) GetProjects(ctx context.Context, keys []string) ([]*models.Project, error)

GetProjects retrieves multiple projects by their IDs using SQL

func (*SystemSQLDriver) GetSystemUser added in v1.6.1

func (p *SystemSQLDriver) GetSystemUser(ctx context.Context, id string) (*models.SystemUser, error)

GetSystemUser retrieves a system user by ID using SQL

func (*SystemSQLDriver) GetSystemUserByEmail added in v1.6.1

func (p *SystemSQLDriver) GetSystemUserByEmail(ctx context.Context, email string) (*models.SystemUser, error)

GetSystemUserByEmail retrieves a system user by email using SQL

func (*SystemSQLDriver) GetSystemUsers added in v1.6.1

func (p *SystemSQLDriver) GetSystemUsers(ctx context.Context, keys []string) ([]*models.SystemUser, error)

GetSystemUsers retrieves multiple system users by their IDs using SQL

func (*SystemSQLDriver) GetTeams added in v1.6.1

func (p *SystemSQLDriver) GetTeams(ctx context.Context, userId string) ([]*models.Team, error)

GetTeams implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) GetTeamsMembers added in v1.6.1

func (p *SystemSQLDriver) GetTeamsMembers(ctx context.Context, projectId string) ([]*models.SystemUser, error)

GetTeamsMembers implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) GetWebHook added in v1.6.1

func (p *SystemSQLDriver) GetWebHook(ctx context.Context, projectId, hookId string) (*models.Webhook, error)

GetWebHook retrieves a specific webhook by ID using SQL

func (*SystemSQLDriver) ListAllProjects added in v1.6.1

func (p *SystemSQLDriver) ListAllProjects(ctx context.Context, userId string) ([]*models.Project, error)

ListAllProjects lists all projects for a user (with admin check) using SQL

func (*SystemSQLDriver) ListAllUsers added in v1.6.1

func (p *SystemSQLDriver) ListAllUsers(ctx context.Context) ([]*models.SystemUser, error)

ListAllUsers lists all system users using SQL

func (*SystemSQLDriver) ListTeams added in v1.6.1

func (p *SystemSQLDriver) ListTeams(ctx context.Context, projectId string) ([]*models.SystemUser, error)

ListTeams lists team members for a project using SQL

func (*SystemSQLDriver) Ping added in v1.6.1

func (p *SystemSQLDriver) Ping() error

Ping verifies the database connection.

func (*SystemSQLDriver) RemoveATeamFromOrganization added in v1.6.1

func (p *SystemSQLDriver) RemoveATeamFromOrganization(ctx context.Context, orgId, userId, teamId string) error

RemoveATeamFromOrganization removes a team from an organization using SQL

func (*SystemSQLDriver) RemoveATeamMemberFromProject added in v1.6.1

func (p *SystemSQLDriver) RemoveATeamMemberFromProject(ctx context.Context, projectId string, memberID string) error

RemoveATeamMemberFromProject removes a team member from a project using SQL

func (*SystemSQLDriver) RemoveProjectFromOrganization added in v1.6.1

func (p *SystemSQLDriver) RemoveProjectFromOrganization(ctx context.Context, orgId, userId, projectId string) error

RemoveProjectFromOrganization removes a project from an organization using SQL

func (*SystemSQLDriver) RunMigration added in v1.6.1

func (p *SystemSQLDriver) RunMigration(ctx context.Context) error

RunMigration creates core system tables if they do not exist.

func (*SystemSQLDriver) SaveAuditLog added in v1.6.1

func (p *SystemSQLDriver) SaveAuditLog(ctx context.Context, auditLog *models.AuditLogs) error

SaveAuditLog implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) SaveRawData added in v1.6.1

func (p *SystemSQLDriver) SaveRawData(ctx context.Context, collection string, data map[string]interface{}) error

SaveRawData saves raw data using SQL for payment-related operations

func (*SystemSQLDriver) SearchAuditLogs added in v1.6.1

SearchAuditLogs implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) SearchFunctions added in v1.6.1

SearchFunctions searches for cloud functions in a project using SQL

func (*SystemSQLDriver) SearchProjects added in v1.6.1

SearchProjects searches for projects based on common system parameters using SQL

func (*SystemSQLDriver) SearchResource added in v1.6.1

SearchResource implements interfaces.ApitoSystemDB.

func (*SystemSQLDriver) SearchUsers added in v1.6.1

SearchUsers searches for system users based on parameters using SQL

func (*SystemSQLDriver) SearchWebHooks added in v1.6.1

SearchWebHooks searches for webhooks in a project using SQL

func (*SystemSQLDriver) UpdateProject added in v1.6.1

func (p *SystemSQLDriver) UpdateProject(ctx context.Context, project *models.Project, replace bool) error

UpdateProject updates a project using SQL

func (*SystemSQLDriver) UpdateSystemUser added in v1.6.1

func (p *SystemSQLDriver) UpdateSystemUser(ctx context.Context, user *models.SystemUser, replace bool) error

UpdateSystemUser updates a system user using SQL

Jump to

Keyboard shortcuts

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