feat(repository): implement user repository (#10967)

## Summary

This PR introduces the relational user repository for backend v3,
including schema, repository APIs, reducers/projections, and tests for
both human and machine users.

## What changed

* Added user-focused relational migrations (users, verifications,
metadata, PATs, machine keys, passkeys, identity provider links) and
related FK wiring.
* Implemented/expanded repository domain contracts and storage
implementations for human and machine user flows.
* Added support for machine secret handling and aligned access token
type modeling.
* Extended user domain models (verifications, password/email/phone/TOTP
state, passkeys, metadata, invite handling, identity provider links).
* Updated projection/reduction coverage and integration tests for key
user lifecycle events.
* Regenerated and updated mocks/enums plus supporting database
change/column utilities.

## Notes for reviewers

* This PR is large because it establishes the foundational relational
user storage layer and related test scaffolding. Sorry for that.

## Closes

Closes #10218
Closes #10224
Closes #10225
Closes #10209
Closes #10802

---------

Co-authored-by: Iraq Jaber <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Marco A. <[email protected]>
Co-authored-by: Tim Möhlmann <[email protected]>
This commit is contained in:
Silvan
2026-02-23 16:03:47 +01:00
committed by GitHub
co-authored by Iraq Jaber Copilot Marco A. Tim Möhlmann
parent 40c7b38ca1
commit 5df8a97f9d
73 changed files with 15914 additions and 1661 deletions
+46 -28
View File
@@ -2,6 +2,18 @@ package database
import "go.uber.org/mock/gomock"
// Column represents a column in a database table.
type Column interface {
gomock.Matcher
argWriter
// WriteQualified writes the column with the table name as prefix.
WriteQualified(builder *StatementBuilder)
// WriteUnqualified writes the column without the table name as prefix.
WriteUnqualified(builder *StatementBuilder)
// Equals checks if two columns are equal.
Equals(col Column) bool
}
type Columns []Column
// Matches implements [Column].
@@ -59,24 +71,22 @@ func (c Columns) Equals(col Column) bool {
return true
}
var _ Column = (Columns)(nil)
// Column represents a column in a database table.
type Column interface {
gomock.Matcher
// WriteQualified writes the column with the table name as prefix.
WriteQualified(builder *StatementBuilder)
// WriteUnqualified writes the column without the table name as prefix.
WriteUnqualified(builder *StatementBuilder)
// Equals checks if two columns are equal.
Equals(col Column) bool
// WriteArg implements [Column].
func (c Columns) WriteArg(builder *StatementBuilder) {
c.WriteQualified(builder)
}
var _ Column = (Columns)(nil)
type column struct {
table string
name string
}
func NewColumn(table, name string) Column {
return &column{table: table, name: name}
}
// Matches implements [Column].
func (c column) Matches(x any) bool {
toMatch, ok := x.(*column)
@@ -91,10 +101,6 @@ func (c column) String() string {
return "database.column"
}
func NewColumn(table, name string) Column {
return &column{table: table, name: name}
}
// WriteQualified implements [Column].
func (c column) WriteQualified(builder *StatementBuilder) {
builder.Grow(len(c.table) + len(c.name) + 1)
@@ -120,6 +126,26 @@ func (c *column) Equals(col Column) bool {
return c.table == toMatch.table && c.name == toMatch.name
}
// WriteArg implements [Column].
func (c column) WriteArg(builder *StatementBuilder) {
c.WriteQualified(builder)
}
var _ Column = (*column)(nil)
type functionColumn struct {
fn function
col Column
}
type function string
const (
_ function = ""
functionLower function = "LOWER"
functionSHA256 function = "SHA256"
)
// LowerColumn returns a column that represents LOWER(col).
func LowerColumn(col Column) Column {
return &functionColumn{fn: functionLower, col: col}
@@ -130,11 +156,6 @@ func SHA256Column(col Column) Column {
return &functionColumn{fn: functionSHA256, col: col}
}
type functionColumn struct {
fn function
col Column
}
// Matches implements [Column].
func (c *functionColumn) Matches(x any) bool {
toMatch, ok := x.(*functionColumn)
@@ -155,14 +176,6 @@ func (c *functionColumn) String() string {
return "database.functionColumn"
}
type function string
const (
_ function = ""
functionLower function = "LOWER"
functionSHA256 function = "SHA256"
)
// WriteQualified implements [Column].
func (c functionColumn) WriteQualified(builder *StatementBuilder) {
builder.Grow(len(c.fn) + 2)
@@ -193,4 +206,9 @@ func (c *functionColumn) Equals(col Column) bool {
return c.col.Equals(toMatch.col)
}
// WriteArg implements [Column].
func (c functionColumn) WriteArg(builder *StatementBuilder) {
c.WriteQualified(builder)
}
var _ Column = (*functionColumn)(nil)