DB 시간포멧 수정. access log 추가

This commit is contained in:
Lectom C Han
2025-12-10 11:53:48 +09:00
parent c1af8f1b61
commit 02a9734961
5 changed files with 127 additions and 6 deletions

View File

@@ -49,6 +49,8 @@ var (
timeLayouts = []string{
"2006-01-02 15:04:05.000",
"2006-01-02 15:04:05",
time.RFC3339,
"2006-01-02T15:04:05.000Z07:00",
}
)
@@ -63,6 +65,10 @@ func EnsureUserProgramReplica(ctx context.Context, conn *pgx.Conn, csvPath, sche
logDir = "log"
}
if err := ensureSchema(ctx, conn, schema); err != nil {
return err
}
if err := createReplicaTable(ctx, conn, schema, ReplicaTable); err != nil {
return err
}
@@ -143,6 +149,14 @@ CREATE TABLE IF NOT EXISTS %s (
return err
}
func ensureSchema(ctx context.Context, conn *pgx.Conn, schema string) error {
if schema == "" {
return nil
}
_, err := conn.Exec(ctx, fmt.Sprintf(`CREATE SCHEMA IF NOT EXISTS %s`, pgx.Identifier{schema}.Sanitize()))
return err
}
type importResult struct {
rowsCopied int64
rowsUpserted int64