feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s

This commit is contained in:
Anya Tokugawa committed 2026-11-15 05:47:14 +09:00
1 parent 96065d1e89
commit 0ba1dcfef0
243 files changed
+21441 -3090

No files matched your search

+35 -18
View File
@@ -4,9 +4,12 @@ import (
"context"
"database/sql"
"encoding/json"
"errors"
"strings"
"time"
"pageswiki/internal/metadata"
"github.com/google/uuid"
)
@@ -75,25 +78,26 @@ func (s *Store) ResolvePathInDomain(
func (s *Store) ResolvePathInDomainContext(ctx context.Context, domainUUID, path string) (string, error) {
path = normalizePath(path)
if err := s.ensureLocalDomain(domainUUID); err != nil {
if err := s.ensureLocalDomainContext(ctx, domainUUID); err != nil {
return "", err
}
var objectUUID string
err := s.DB.QueryRowContext(ctx, `
SELECT object_uuid
FROM paths
WHERE domain_uuid = ?
AND path = ?
LIMIT 1
`, domainUUID, path).Scan(&objectUUID)
// The application Store remains SQLite-only until all repositories are
// ported. Share this read contract now without invoking portable bootstrap
// or changing the existing application's schema and initialization order.
backend := metadata.SQLite
if s.sqlBackend == storePostgreSQL {
backend = metadata.PostgreSQL
}
repository, err := metadata.New(s.DB, backend)
if err != nil {
return "", err
}
return objectUUID, nil
objectUUID, err := repository.ResolvePath(ctx, domainUUID, path)
if errors.Is(err, metadata.ErrNotFound) {
return "", sql.ErrNoRows
}
return objectUUID, err
}
func normalizePath(
@@ -131,15 +135,16 @@ func (s *Store) ListChildrenInDomain(
domainUUID string,
prefix string,
) ([]string, error) {
prefix = strings.TrimRight(normalizePath(prefix), "/")
rows, err := s.DB.Query(`
SELECT path
FROM paths
WHERE domain_uuid = ?
AND path LIKE ?
WHERE domain_uuid = `+s.sqlParam(1)+`
AND path >= `+s.sqlParam(2)+` AND path < `+s.sqlParam(3)+`
ORDER BY path
`,
domainUUID,
prefix+"/%",
prefix+"/", prefix+"0",
)
if err != nil {
@@ -182,8 +187,8 @@ func (s *Store) PathExistsInDomain(
row := s.DB.QueryRow(`
SELECT COUNT(*)
FROM paths
WHERE domain_uuid = ?
AND path = ?
WHERE domain_uuid = `+s.sqlParam(1)+`
AND path = `+s.sqlParam(2)+`
`, domainUUID, normalizePath(path))
var count int
@@ -207,6 +212,18 @@ func (s *Store) CreatePageAtPathInDomain(
domainUUID string,
path string,
) (string, error) {
if s.ReadOnly {
return "", ErrReadOnly
}
if s.sqlBackend == storePostgreSQL {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
repo, err := metadata.NewApplication(s.DB, metadata.PostgreSQL)
if err != nil {
return "", err
}
return repo.CreatePage(ctx, domainUUID, normalizePath(path))
}
if err := s.ensureLocalDomain(domainUUID); err != nil {
return "", err
}