GUACAMOLE-52: Foreign keys in history table should be ON DELETE SET NULL. For sake of context, always store username and connection name in history table.

This commit is contained in:
Michael Jumper
2016-04-27 13:12:31 -07:00
parent 673fe42631
commit f4a3c5b31e
7 changed files with 225 additions and 39 deletions

View File

@@ -37,17 +37,15 @@
<select id="select" resultMap="ConnectionRecordResultMap">
SELECT
guacamole_connection.connection_id,
guacamole_connection.connection_name,
guacamole_user.user_id,
guacamole_user.username,
guacamole_connection_history.connection_id,
guacamole_connection_history.connection_name,
guacamole_connection_history.user_id,
guacamole_connection_history.username,
guacamole_connection_history.start_date,
guacamole_connection_history.end_date
FROM guacamole_connection_history
JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id
WHERE
guacamole_connection.connection_id = #{identifier,jdbcType=INTEGER}::integer
guacamole_connection_history.connection_id = #{identifier,jdbcType=INTEGER}::integer
ORDER BY
guacamole_connection_history.start_date DESC,
guacamole_connection_history.end_date DESC
@@ -59,13 +57,18 @@
INSERT INTO guacamole_connection_history (
connection_id,
connection_name,
user_id,
username,
start_date,
end_date
)
VALUES (
#{record.connectionIdentifier,jdbcType=INTEGER}::integer,
#{record.userID,jdbcType=INTEGER},
#{record.connectionName,jdbcType=VARCHAR},
(SELECT user_id FROM guacamole_user
WHERE username = #{record.username,jdbcType=VARCHAR}),
#{record.username,jdbcType=VARCHAR},
#{record.startDate,jdbcType=TIMESTAMP},
#{record.endDate,jdbcType=TIMESTAMP}
)
@@ -77,14 +80,12 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection.connection_name,
guacamole_connection_history.connection_name,
guacamole_connection_history.user_id,
guacamole_user.username,
guacamole_connection_history.username,
guacamole_connection_history.start_date,
guacamole_connection_history.end_date
FROM guacamole_connection_history
LEFT JOIN guacamole_connection ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
LEFT JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id
<!-- Search terms -->
<foreach collection="terms" item="term"
@@ -132,9 +133,9 @@
SELECT
guacamole_connection_history.connection_id,
guacamole_connection.connection_name,
guacamole_connection_history.connection_name,
guacamole_connection_history.user_id,
guacamole_user.username,
guacamole_connection_history.username,
guacamole_connection_history.start_date,
guacamole_connection_history.end_date
FROM guacamole_connection_history