Compare commits
1 Commits
680d879d03
...
f/clean_au
Author | SHA1 | Date | |
---|---|---|---|
bceab9d9f6 |
@@ -69,6 +69,8 @@ where table_schema = 'public'
|
|||||||
order by 4 desc;
|
order by 4 desc;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
### Flow table
|
||||||
|
|
||||||
log "Cleaning flow table..."
|
log "Cleaning flow table..."
|
||||||
|
|
||||||
REMAINING_ELMTS="${LIMIT}"
|
REMAINING_ELMTS="${LIMIT}"
|
||||||
@@ -105,6 +107,8 @@ EOF
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
### Authentication session table
|
||||||
|
|
||||||
log "Cleaning authentication_session table..."
|
log "Cleaning authentication_session table..."
|
||||||
|
|
||||||
BATCH_SIZE="${BATCH_SIZE_ORIG}"
|
BATCH_SIZE="${BATCH_SIZE_ORIG}"
|
||||||
@@ -134,15 +138,15 @@ log "${OUTPUT}"
|
|||||||
while [ "${REMAINING_ELMTS}" -gt 0 ]; do
|
while [ "${REMAINING_ELMTS}" -gt 0 ]; do
|
||||||
|
|
||||||
OUTPUT=$(psql "${DSN}" <<EOF
|
OUTPUT=$(psql "${DSN}" <<EOF
|
||||||
WITH cte AS (
|
WITH childless_auth_session_batch AS (
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM hydra_cleaner.hydra_childless_auth_session
|
FROM hydra_cleaner.hydra_childless_auth_session
|
||||||
LIMIT ${BATCH_SIZE}
|
LIMIT ${BATCH_SIZE}
|
||||||
),
|
),
|
||||||
auth_session_deleted as (
|
auth_session_deleted AS (
|
||||||
DELETE
|
DELETE
|
||||||
FROM hydra_oauth2_authentication_session
|
FROM hydra_oauth2_authentication_session
|
||||||
WHERE hydra_oauth2_authentication_session.id in (select * from cte)
|
WHERE hydra_oauth2_authentication_session.id IN (SELECT * FROM childless_auth_session_batch)
|
||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM hydra_oauth2_flow
|
FROM hydra_oauth2_flow
|
||||||
@@ -151,7 +155,7 @@ auth_session_deleted as (
|
|||||||
)
|
)
|
||||||
DELETE
|
DELETE
|
||||||
FROM hydra_cleaner.hydra_childless_auth_session
|
FROM hydra_cleaner.hydra_childless_auth_session
|
||||||
WHERE hydra_cleaner.hydra_childless_auth_session.id in (select * from cte);
|
WHERE hydra_cleaner.hydra_childless_auth_session.id IN (SELECT * FROM childless_auth_session_batch);
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user