mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
abb57e58c8
</details> PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3392 Co-authored-by: Divi <32202683+imperfect-fourth@users.noreply.github.com> GitOrigin-RevId: 9df6b0aa7d91f22571b72d3e467da23b916c9140
28 lines
712 B
Plaintext
28 lines
712 B
Plaintext
CREATE OR ALTER TRIGGER #{qualifiedTriggerName}
|
|
ON #{qualifiedTableName}
|
|
AFTER DELETE
|
|
AS
|
|
BEGIN
|
|
DECLARE @json NVARCHAR(MAX)
|
|
SET @json = (
|
|
SELECT
|
|
#{deliveryColsSQLExpression}, NULL as [payload.data.new],
|
|
'#{operation}' as [payload.op],
|
|
'#{schemaName}' as [schema_name],
|
|
'#{tableName}' as [table_name],
|
|
'#{triggerNameText}' as [trigger_name]
|
|
FROM DELETED
|
|
FOR JSON PATH, INCLUDE_NULL_VALUES
|
|
)
|
|
|
|
insert into hdb_catalog.event_log (schema_name,table_name,trigger_name,payload)
|
|
select * from OPENJSON (@json)
|
|
WITH(
|
|
schema_name NVARCHAR(MAX) '$.schema_name',
|
|
table_name NVARCHAR(MAX) '$.table_name',
|
|
trigger_name NVARCHAR(MAX) '$.trigger_name',
|
|
[payload] NVARCHAR(MAX) AS JSON
|
|
)
|
|
|
|
END;
|