From a5cccaca279f10732bc2c64c52dbc5739ec33e8f Mon Sep 17 00:00:00 2001 From: "bparodi@lezzo.org" <bparodi@lezzo.orgg> Date: Sat, 26 Oct 2024 12:27:00 +0200 Subject: [PATCH] db --- src/Database.fs | 7 +++++-- src/DatabaseMigrations.fs | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Database.fs b/src/Database.fs index cae6962..44aa5c3 100644 --- a/src/Database.fs +++ b/src/Database.fs @@ -50,13 +50,16 @@ let make (logger: ILogger) = use listen = new NpgsqlCommand ("LISTEN bidello_database_update;", conn) listen.ExecuteNonQuery () |> ignore + logger.Information "Successfully connected to the database." + {connection = conn} let wait_notification (ct: CancellationToken) (db: t) = db.connection.WaitAsync ct -type Requirements_ = { +[<CLIMutable>] +type Requirements = { job_name: string ``when``: string executable: string @@ -86,4 +89,4 @@ group by c.job_name, h.hostname """ new CommandDefinition (query, parameters=param, transaction=null, commandTimeout=nl, commandType=cl, flags=CommandFlags.Buffered, cancellationToken=ct) - |> db.connection.QueryAsync<Requirements_> + |> db.connection.QueryAsync<Requirements> diff --git a/src/DatabaseMigrations.fs b/src/DatabaseMigrations.fs index f1c25d8..8004b17 100644 --- a/src/DatabaseMigrations.fs +++ b/src/DatabaseMigrations.fs @@ -184,3 +184,9 @@ type ChangeBacklogDrop () = .AddColumn("exit_code").AsCustom("smallint").NotNullable() |> ignore +[<Migration(20241024_0001L)>] +type BacklogDefaultTS () = + inherit OnlyUp () + override x.Up() = + """ALTER TABLE backlog ALTER COLUMN done_at SET DEFAULT current_timestamp;""" + |> x.Execute.Sql |> ignore