- dms/ai/workflow: qa0x-Pakete nach internal/gates/<thema> verschoben, Paketname = Thema
- internal/migration{acl,audit,...} -> internal/migration/{acl,audit,...}
- Importpfade, Gate-Skripte und zwei relative Migrationspfade angepasst
- keine Logikaenderung; mail-Gates bewusst unveraendert (pfadabhaengig)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
// Package migrationtenant implementiert COR-01: die Uebernahme
|
|
// zusammengefuehrter Tenant-Datensaetze aus der freigegebenen
|
|
// tenant_migration_map (MAP-02) in Core TEN-01.
|
|
package migrationtenant
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
)
|
|
|
|
// MapEntry ist eine Zeile der tenant_migration_map.
|
|
type MapEntry struct {
|
|
ID int64
|
|
ArchivmailTenantID *int64
|
|
ArchivdmsTenantID *int64
|
|
NexarchTenantID string
|
|
Slug string
|
|
Name string
|
|
ApprovedBy *string
|
|
}
|
|
|
|
// MapStore kapselt den lesenden Zugriff auf tenant_migration_map in der
|
|
// Registry-Datenbank.
|
|
type MapStore struct {
|
|
pool *pgxpool.Pool
|
|
}
|
|
|
|
func NewMapStore(pool *pgxpool.Pool) *MapStore {
|
|
return &MapStore{pool: pool}
|
|
}
|
|
|
|
// Approved liefert ausschliesslich Zeilen mit gesetztem approved_at
|
|
// (Akzeptanzkriterium 2: kein Tenant ohne Freigabe wird uebernommen).
|
|
func (s *MapStore) Approved(ctx context.Context) ([]MapEntry, error) {
|
|
rows, err := s.pool.Query(ctx, `
|
|
SELECT id, archivmail_tenant_id, archivdms_tenant_id, nexarch_tenant_id, slug, name, approved_by
|
|
FROM tenant_migration_map
|
|
WHERE approved_at IS NOT NULL
|
|
ORDER BY id
|
|
`)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("freigegebene tenant-map lesen: %w", err)
|
|
}
|
|
defer rows.Close()
|
|
|
|
var out []MapEntry
|
|
for rows.Next() {
|
|
var e MapEntry
|
|
if err := rows.Scan(&e.ID, &e.ArchivmailTenantID, &e.ArchivdmsTenantID, &e.NexarchTenantID, &e.Slug, &e.Name, &e.ApprovedBy); err != nil {
|
|
return nil, fmt.Errorf("tenant-map-eintrag lesen: %w", err)
|
|
}
|
|
out = append(out, e)
|
|
}
|
|
return out, rows.Err()
|
|
}
|