mirror of
https://github.com/zitadel/zitadel.git
synced 2026-07-25 18:28:00 +00:00
## 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 <iraq+github@zitadel.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Marco A. <marco@zitadel.com> Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package postgres
|
|
|
|
import (
|
|
"net"
|
|
"os"
|
|
|
|
embeddedpostgres "github.com/fergusstrange/embedded-postgres"
|
|
"github.com/zitadel/logging"
|
|
)
|
|
|
|
func StartEmbedded() (embeddedpostgres.Config, func()) {
|
|
path, err := os.MkdirTemp("", "zitadel-embedded-postgres-*")
|
|
logging.OnError(err).Fatal("unable to create temp dir")
|
|
|
|
port, close := getPort()
|
|
|
|
config := embeddedpostgres.DefaultConfig().Version(embeddedpostgres.V17).Port(uint32(port)).RuntimePath(path)
|
|
embedded := embeddedpostgres.NewDatabase(config)
|
|
|
|
close()
|
|
err = embedded.Start()
|
|
logging.OnError(err).Fatal("unable to start db")
|
|
|
|
return config, func() {
|
|
logging.OnError(embedded.Stop()).Error("unable to stop db")
|
|
}
|
|
}
|
|
|
|
// getPort returns a free port and locks it until close is called
|
|
func getPort() (port uint16, close func()) {
|
|
l, err := net.Listen("tcp", ":0")
|
|
logging.OnError(err).Fatal("unable to get port")
|
|
port = uint16(l.Addr().(*net.TCPAddr).Port)
|
|
logging.WithFields("port", port).Info("Port is available")
|
|
return port, func() {
|
|
logging.OnError(l.Close()).Error("unable to close port listener")
|
|
}
|
|
}
|