improved logging
This commit is contained in:
@@ -36,6 +36,14 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
|
||||||
|
logshell:
|
||||||
|
image: alpine:3.22
|
||||||
|
container_name: timetracker-logshell
|
||||||
|
restart: unless-stopped
|
||||||
|
command: ["sh", "-c", "tail -f /dev/null"]
|
||||||
|
volumes:
|
||||||
|
- applogs:/logs:ro
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
pgdata:
|
pgdata:
|
||||||
name: timetracker_pgdata
|
name: timetracker_pgdata
|
||||||
|
|||||||
@@ -231,6 +231,11 @@ using (var scope = app.Services.CreateScope())
|
|||||||
await conn.OpenAsync();
|
await conn.OpenAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var tableName in new[] { "Users", "Tenants", "AppSettings", "WorkDays", "BreakEntries", "VacationDays", "PublicHolidays" })
|
||||||
|
{
|
||||||
|
await EnsurePostgresIntegerPrimaryKeyDefaultAsync(conn, tableName);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if column IsTenantAdmin in Users table is of type integer
|
// Check if column IsTenantAdmin in Users table is of type integer
|
||||||
using (var cmdCheckType = conn.CreateCommand())
|
using (var cmdCheckType = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
@@ -902,6 +907,31 @@ static string ComputePasswordHash(string password, string salt)
|
|||||||
return Convert.ToBase64String(hash);
|
return Convert.ToBase64String(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async Task EnsurePostgresIntegerPrimaryKeyDefaultAsync(System.Data.Common.DbConnection conn, string tableName)
|
||||||
|
{
|
||||||
|
using var cmd = conn.CreateCommand();
|
||||||
|
cmd.CommandText = $@"
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
sequence_name text := '" + @"" + @"' || '{tableName}_Id_seq';
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_schema = 'public'
|
||||||
|
AND table_name = '{tableName}'
|
||||||
|
AND column_name = 'Id'
|
||||||
|
AND column_default IS NULL
|
||||||
|
) THEN
|
||||||
|
EXECUTE 'CREATE SEQUENCE IF NOT EXISTS public.""{tableName}_Id_seq""';
|
||||||
|
EXECUTE 'ALTER SEQUENCE public.""{tableName}_Id_seq"" OWNED BY public.""{tableName}"".""Id""';
|
||||||
|
EXECUTE 'ALTER TABLE public.""{tableName}"" ALTER COLUMN ""Id"" SET DEFAULT nextval(''''public.""{tableName}_Id_seq""'''')';
|
||||||
|
EXECUTE 'SELECT setval(''''public.""{tableName}_Id_seq""'''', COALESCE((SELECT MAX(""Id"") FROM public.""{tableName}""), 0) + 1, false)';
|
||||||
|
END IF;
|
||||||
|
END $$;";
|
||||||
|
await cmd.ExecuteNonQueryAsync();
|
||||||
|
}
|
||||||
|
|
||||||
// ── Models for Request Bodies ──────────────────────────────────────────────────
|
// ── Models for Request Bodies ──────────────────────────────────────────────────
|
||||||
public record LoginRequest(string Username, string Password);
|
public record LoginRequest(string Username, string Password);
|
||||||
public record RegisterRequest(string Username, string Password, string? Honeypot = null);
|
public record RegisterRequest(string Username, string Password, string? Honeypot = null);
|
||||||
|
|||||||
Reference in New Issue
Block a user