diff --git a/internal/pgengine/access.go b/internal/pgengine/access.go index 484da93e..9cf4380c 100644 --- a/internal/pgengine/access.go +++ b/internal/pgengine/access.go @@ -30,11 +30,12 @@ func (pge *PgEngine) IsAlive() bool { // LogTaskExecution will log current chain element execution status including retcode func (pge *PgEngine) LogTaskExecution(ctx context.Context, task *ChainTask, retCode int, output string) { _, err := pge.ConfigDb.Exec(ctx, `INSERT INTO timetable.execution_log ( -chain_id, task_id, command, kind, last_run, finished, returncode, pid, output, client_name, txid) -VALUES ($1, $2, $3, $4, clock_timestamp() - $5 :: interval, clock_timestamp(), $6, $7, NULLIF($8, ''), $9, $10)`, +chain_id, task_id, command, kind, last_run, finished, returncode, pid, output, client_name, txid, ignore_error) +VALUES ($1, $2, $3, $4, clock_timestamp() - $5 :: interval, clock_timestamp(), $6, $7, NULLIF($8, ''), $9, $10, $11)`, task.ChainID, task.TaskID, task.Script, task.Kind, fmt.Sprintf("%f seconds", float64(task.Duration)/1000000), - retCode, pge.Getsid(), strings.TrimSpace(output), pge.ClientName, task.Txid) + retCode, pge.Getsid(), strings.TrimSpace(output), pge.ClientName, task.Txid, + task.IgnoreError) if err != nil { pge.l.WithError(err).Error("Failed to log chain element execution status") } diff --git a/internal/pgengine/migration.go b/internal/pgengine/migration.go index 46f8e844..6394eb6c 100644 --- a/internal/pgengine/migration.go +++ b/internal/pgengine/migration.go @@ -135,6 +135,12 @@ var Migrations func() migrator.Option = func() migrator.Option { return ExecuteMigrationScript(ctx, tx, "00575.sql") }, }, + &migrator.Migration{ + Name: "00629 Add ignore_error column to timetable.execution_log", + Func: func(ctx context.Context, tx pgx.Tx) error { + return ExecuteMigrationScript(ctx, tx, "00629.sql") + }, + }, // adding new migration here, update "timetable"."migration" in "sql/init.sql" // and "dbapi" variable in main.go! diff --git a/internal/pgengine/sql/ddl.sql b/internal/pgengine/sql/ddl.sql index 5ff288f0..90e8e288 100644 --- a/internal/pgengine/sql/ddl.sql +++ b/internal/pgengine/sql/ddl.sql @@ -105,17 +105,18 @@ COMMENT ON TABLE timetable.log IS 'Stores log entries of active sessions'; CREATE TABLE timetable.execution_log ( - chain_id BIGINT, - task_id BIGINT, - txid BIGINT NOT NULL, - last_run TIMESTAMPTZ DEFAULT now(), - finished TIMESTAMPTZ, - pid BIGINT, - returncode INTEGER, - kind timetable.command_kind, - command TEXT, - output TEXT, - client_name TEXT NOT NULL + chain_id BIGINT, + task_id BIGINT, + txid BIGINT NOT NULL, + last_run TIMESTAMPTZ DEFAULT now(), + finished TIMESTAMPTZ, + pid BIGINT, + returncode INTEGER, + ignore_error BOOLEAN, + kind timetable.command_kind, + command TEXT, + output TEXT, + client_name TEXT NOT NULL ); COMMENT ON TABLE timetable.execution_log IS diff --git a/internal/pgengine/sql/init.sql b/internal/pgengine/sql/init.sql index 3a6657f4..875ea9d0 100644 --- a/internal/pgengine/sql/init.sql +++ b/internal/pgengine/sql/init.sql @@ -25,4 +25,5 @@ VALUES (9, '00534 Use cron_split_to_arrays() in cron domain check'), (10, '00560 Alter txid column to bigint'), (11, '00573 Add ability to start a chain with delay'), - (12, '00575 Add on_error handling'); \ No newline at end of file + (12, '00575 Add on_error handling'), + (13, '00629 Add ignore_error column to timetable.execution_log'); \ No newline at end of file diff --git a/internal/pgengine/sql/migrations/00629.sql b/internal/pgengine/sql/migrations/00629.sql new file mode 100644 index 00000000..0ec37073 --- /dev/null +++ b/internal/pgengine/sql/migrations/00629.sql @@ -0,0 +1,2 @@ +ALTER TABLE timetable.execution_log + ADD COLUMN ignore_error BOOLEAN; \ No newline at end of file diff --git a/main.go b/main.go index 7b7db5d1..cb9a85f4 100644 --- a/main.go +++ b/main.go @@ -54,7 +54,7 @@ var ( commit = "000000" version = "master" date = "unknown" - dbapi = "00573" + dbapi = "00629" ) func printVersion() {