diff --git a/crates/database/.sqlx/query-0015a7a31c40e78d17b400b11f19a352d7d614002255b956f7277ed23855d1d3.json b/crates/database/.sqlx/query-0015a7a31c40e78d17b400b11f19a352d7d614002255b956f7277ed23855d1d3.json deleted file mode 100644 index e52504298..000000000 --- a/crates/database/.sqlx/query-0015a7a31c40e78d17b400b11f19a352d7d614002255b956f7277ed23855d1d3.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM webauthn_ceremonies\n WHERE ctid IN (\n SELECT ctid\n FROM webauthn_ceremonies\n WHERE expires_at < now()\n OR consumed_at < now() - interval '1 day'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "0015a7a31c40e78d17b400b11f19a352d7d614002255b956f7277ed23855d1d3" -} diff --git a/crates/database/.sqlx/query-0b1e6403255951193fd80ef1c4fbfaf8c1f34161aca0b286c7e543f21f00e65b.json b/crates/database/.sqlx/query-0b1e6403255951193fd80ef1c4fbfaf8c1f34161aca0b286c7e543f21f00e65b.json new file mode 100644 index 000000000..8a7f2fdbf --- /dev/null +++ b/crates/database/.sqlx/query-0b1e6403255951193fd80ef1c4fbfaf8c1f34161aca0b286c7e543f21f00e65b.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM notifications WHERE ctid IN (SELECT ctid FROM notifications WHERE created_at < now() - interval '1 year' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "0b1e6403255951193fd80ef1c4fbfaf8c1f34161aca0b286c7e543f21f00e65b" +} diff --git a/crates/database/.sqlx/query-0d786a6ed79f853b1d9c9adbde54d68ab5fda8b03bf1fcdc57ee6d7792401978.json b/crates/database/.sqlx/query-0d786a6ed79f853b1d9c9adbde54d68ab5fda8b03bf1fcdc57ee6d7792401978.json deleted file mode 100644 index 0929f3e8e..000000000 --- a/crates/database/.sqlx/query-0d786a6ed79f853b1d9c9adbde54d68ab5fda8b03bf1fcdc57ee6d7792401978.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM notifications\n WHERE ctid IN (\n SELECT ctid\n FROM notifications\n WHERE created_at < now() - interval '1 year'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "0d786a6ed79f853b1d9c9adbde54d68ab5fda8b03bf1fcdc57ee6d7792401978" -} diff --git a/crates/database/.sqlx/query-13e7a32572117990a0eb67e49daae24346c47d3eca4a0a73b0542c94ccc8029e.json b/crates/database/.sqlx/query-13e7a32572117990a0eb67e49daae24346c47d3eca4a0a73b0542c94ccc8029e.json new file mode 100644 index 000000000..65f71659b --- /dev/null +++ b/crates/database/.sqlx/query-13e7a32572117990a0eb67e49daae24346c47d3eca4a0a73b0542c94ccc8029e.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM dashboard_sessions WHERE ctid IN (SELECT ctid FROM dashboard_sessions WHERE expires_at < now() LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "13e7a32572117990a0eb67e49daae24346c47d3eca4a0a73b0542c94ccc8029e" +} diff --git a/crates/database/.sqlx/query-1677e180168b55d131bb166f469cf718fb022b4a80a80fc1933aa47d1c8881ac.json b/crates/database/.sqlx/query-1677e180168b55d131bb166f469cf718fb022b4a80a80fc1933aa47d1c8881ac.json deleted file mode 100644 index 6ef9ac95a..000000000 --- a/crates/database/.sqlx/query-1677e180168b55d131bb166f469cf718fb022b4a80a80fc1933aa47d1c8881ac.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM passkey_credentials\n WHERE ctid IN (\n SELECT ctid\n FROM passkey_credentials\n WHERE revoked_at < now() - interval '90 days'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "1677e180168b55d131bb166f469cf718fb022b4a80a80fc1933aa47d1c8881ac" -} diff --git a/crates/database/.sqlx/query-17694894d73ef83c3208368da6e4386b0a7bb8445079e1a9bad2ab7dbfd7a829.json b/crates/database/.sqlx/query-17694894d73ef83c3208368da6e4386b0a7bb8445079e1a9bad2ab7dbfd7a829.json new file mode 100644 index 000000000..9d87a0002 --- /dev/null +++ b/crates/database/.sqlx/query-17694894d73ef83c3208368da6e4386b0a7bb8445079e1a9bad2ab7dbfd7a829.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM passkey_credentials WHERE ctid IN (SELECT ctid FROM passkey_credentials WHERE revoked_at < now() - interval '90 days' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "17694894d73ef83c3208368da6e4386b0a7bb8445079e1a9bad2ab7dbfd7a829" +} diff --git a/crates/database/.sqlx/query-1b753be9686ca0f9370e1fcdafa235128994ad3bf8069c5bc86cf5e6d969c0c2.json b/crates/database/.sqlx/query-1b753be9686ca0f9370e1fcdafa235128994ad3bf8069c5bc86cf5e6d969c0c2.json deleted file mode 100644 index 92f0f83dc..000000000 --- a/crates/database/.sqlx/query-1b753be9686ca0f9370e1fcdafa235128994ad3bf8069c5bc86cf5e6d969c0c2.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM known_devices\n WHERE ctid IN (\n SELECT ctid\n FROM known_devices\n WHERE last_seen_at < now() - interval '400 days'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "1b753be9686ca0f9370e1fcdafa235128994ad3bf8069c5bc86cf5e6d969c0c2" -} diff --git a/crates/database/.sqlx/query-1d4a9a1f67bcf68592dc09d37a700c7a523d8175c6022af0075c1ca36e9c191a.json b/crates/database/.sqlx/query-1d4a9a1f67bcf68592dc09d37a700c7a523d8175c6022af0075c1ca36e9c191a.json new file mode 100644 index 000000000..6edbef9f3 --- /dev/null +++ b/crates/database/.sqlx/query-1d4a9a1f67bcf68592dc09d37a700c7a523d8175c6022af0075c1ca36e9c191a.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM handles WHERE ctid IN (SELECT ctid FROM handles WHERE user_id IS NULL AND released_at < now() - interval '1 year' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "1d4a9a1f67bcf68592dc09d37a700c7a523d8175c6022af0075c1ca36e9c191a" +} diff --git a/crates/database/.sqlx/query-3f68a50372f386a30304be409ba577447bf1483d582fd25c2f63468568954816.json b/crates/database/.sqlx/query-3f68a50372f386a30304be409ba577447bf1483d582fd25c2f63468568954816.json new file mode 100644 index 000000000..afe47f118 --- /dev/null +++ b/crates/database/.sqlx/query-3f68a50372f386a30304be409ba577447bf1483d582fd25c2f63468568954816.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM federation_transactions WHERE ctid IN (SELECT ctid FROM federation_transactions WHERE expires_at < now()\n OR consumed_at < now() - interval '1 day' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "3f68a50372f386a30304be409ba577447bf1483d582fd25c2f63468568954816" +} diff --git a/crates/database/.sqlx/query-458f34f5477f8874fab6c21f56db9686ac6fe6b9473cfb9923b3efd5d249c540.json b/crates/database/.sqlx/query-458f34f5477f8874fab6c21f56db9686ac6fe6b9473cfb9923b3efd5d249c540.json new file mode 100644 index 000000000..7ce3ebfa6 --- /dev/null +++ b/crates/database/.sqlx/query-458f34f5477f8874fab6c21f56db9686ac6fe6b9473cfb9923b3efd5d249c540.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM known_devices WHERE ctid IN (SELECT ctid FROM known_devices WHERE last_seen_at < now() - interval '400 days' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "458f34f5477f8874fab6c21f56db9686ac6fe6b9473cfb9923b3efd5d249c540" +} diff --git a/crates/database/.sqlx/query-467b762803df1cda514948abe73ff992d7a41598c70dccf99d3a22e128d23fc7.json b/crates/database/.sqlx/query-467b762803df1cda514948abe73ff992d7a41598c70dccf99d3a22e128d23fc7.json deleted file mode 100644 index 28ebb8bda..000000000 --- a/crates/database/.sqlx/query-467b762803df1cda514948abe73ff992d7a41598c70dccf99d3a22e128d23fc7.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM account_recoveries\n WHERE ctid IN (\n SELECT ctid\n FROM account_recoveries\n WHERE CASE WHEN completed_at IS NULL THEN least(expires_at, cancelled_at)\n ELSE least(undone_at, settles_at) END < now() - interval '90 days'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "467b762803df1cda514948abe73ff992d7a41598c70dccf99d3a22e128d23fc7" -} diff --git a/crates/database/.sqlx/query-7476979003c65646ab74ca2cd9e1e7f77f19b99d521a33372c63b87c153ed519.json b/crates/database/.sqlx/query-7476979003c65646ab74ca2cd9e1e7f77f19b99d521a33372c63b87c153ed519.json deleted file mode 100644 index e829074e5..000000000 --- a/crates/database/.sqlx/query-7476979003c65646ab74ca2cd9e1e7f77f19b99d521a33372c63b87c153ed519.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM handles\n WHERE ctid IN (\n SELECT ctid\n FROM handles\n WHERE user_id IS NULL AND released_at < now() - interval '1 year'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "7476979003c65646ab74ca2cd9e1e7f77f19b99d521a33372c63b87c153ed519" -} diff --git a/crates/database/.sqlx/query-7666eb01b7ccef00b5b1dea80a7a8043f25d0c615f8a51ed98293332233f6b95.json b/crates/database/.sqlx/query-7666eb01b7ccef00b5b1dea80a7a8043f25d0c615f8a51ed98293332233f6b95.json deleted file mode 100644 index 4506ebe2f..000000000 --- a/crates/database/.sqlx/query-7666eb01b7ccef00b5b1dea80a7a8043f25d0c615f8a51ed98293332233f6b95.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM external_login_identities\n WHERE ctid IN (\n SELECT ctid\n FROM external_login_identities\n WHERE revoked_at < now() - interval '90 days'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "7666eb01b7ccef00b5b1dea80a7a8043f25d0c615f8a51ed98293332233f6b95" -} diff --git a/crates/database/.sqlx/query-839eb35bacf2588e48f01b9d0a363d4547527f2868b48a9d4840552d75b47193.json b/crates/database/.sqlx/query-839eb35bacf2588e48f01b9d0a363d4547527f2868b48a9d4840552d75b47193.json deleted file mode 100644 index ccfbe71d2..000000000 --- a/crates/database/.sqlx/query-839eb35bacf2588e48f01b9d0a363d4547527f2868b48a9d4840552d75b47193.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM federation_transactions\n WHERE ctid IN (\n SELECT ctid\n FROM federation_transactions\n WHERE expires_at < now()\n OR consumed_at < now() - interval '1 day'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "839eb35bacf2588e48f01b9d0a363d4547527f2868b48a9d4840552d75b47193" -} diff --git a/crates/database/.sqlx/query-85d9468b047ff386f202a5e3227dc492c0c86eeb42903168dfd54d2b7a4645e9.json b/crates/database/.sqlx/query-85d9468b047ff386f202a5e3227dc492c0c86eeb42903168dfd54d2b7a4645e9.json new file mode 100644 index 000000000..88db74a56 --- /dev/null +++ b/crates/database/.sqlx/query-85d9468b047ff386f202a5e3227dc492c0c86eeb42903168dfd54d2b7a4645e9.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM pending_federation WHERE ctid IN (SELECT ctid FROM pending_federation WHERE expires_at < now() LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "85d9468b047ff386f202a5e3227dc492c0c86eeb42903168dfd54d2b7a4645e9" +} diff --git a/crates/database/.sqlx/query-87e29879d0a7d0923d65b8ca193e77a19e5223003dd0b5b4339a5e01b1bc050e.json b/crates/database/.sqlx/query-87e29879d0a7d0923d65b8ca193e77a19e5223003dd0b5b4339a5e01b1bc050e.json new file mode 100644 index 000000000..0cbcf1e04 --- /dev/null +++ b/crates/database/.sqlx/query-87e29879d0a7d0923d65b8ca193e77a19e5223003dd0b5b4339a5e01b1bc050e.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM webauthn_ceremonies WHERE ctid IN (SELECT ctid FROM webauthn_ceremonies WHERE expires_at < now()\n OR consumed_at < now() - interval '1 day' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "87e29879d0a7d0923d65b8ca193e77a19e5223003dd0b5b4339a5e01b1bc050e" +} diff --git a/crates/database/.sqlx/query-886e43137c08600a7fdd6821818e3b1394718b273926df9323d4662fa486d6ad.json b/crates/database/.sqlx/query-886e43137c08600a7fdd6821818e3b1394718b273926df9323d4662fa486d6ad.json new file mode 100644 index 000000000..6d7cc12c6 --- /dev/null +++ b/crates/database/.sqlx/query-886e43137c08600a7fdd6821818e3b1394718b273926df9323d4662fa486d6ad.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM external_login_identities WHERE ctid IN (SELECT ctid FROM external_login_identities WHERE revoked_at < now() - interval '90 days' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "886e43137c08600a7fdd6821818e3b1394718b273926df9323d4662fa486d6ad" +} diff --git a/crates/database/.sqlx/query-8b20d21d0913ee69fd46ada6e63af79e529c10ce0e0144a896e52bb2fc2f6118.json b/crates/database/.sqlx/query-8b20d21d0913ee69fd46ada6e63af79e529c10ce0e0144a896e52bb2fc2f6118.json deleted file mode 100644 index e58fc143a..000000000 --- a/crates/database/.sqlx/query-8b20d21d0913ee69fd46ada6e63af79e529c10ce0e0144a896e52bb2fc2f6118.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM invitations\n WHERE ctid IN (\n SELECT ctid\n FROM invitations\n WHERE expires_at < now()\n OR redeemed_at < now() - interval '1 day'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "8b20d21d0913ee69fd46ada6e63af79e529c10ce0e0144a896e52bb2fc2f6118" -} diff --git a/crates/database/.sqlx/query-8f529870012b54461c249efdfeed0a5843ec6b9c5a97e76336cbea8409a7cd56.json b/crates/database/.sqlx/query-8f529870012b54461c249efdfeed0a5843ec6b9c5a97e76336cbea8409a7cd56.json deleted file mode 100644 index 955f7193a..000000000 --- a/crates/database/.sqlx/query-8f529870012b54461c249efdfeed0a5843ec6b9c5a97e76336cbea8409a7cd56.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM authorization_requests\n WHERE ctid IN (\n SELECT ctid\n FROM authorization_requests\n WHERE expires_at < now()\n OR consumed_at < now() - interval '1 day'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "8f529870012b54461c249efdfeed0a5843ec6b9c5a97e76336cbea8409a7cd56" -} diff --git a/crates/database/.sqlx/query-94405ea4ea79665d1306c3d7c6cab9f0b52b1fb44d9097169324681ff3e600a3.json b/crates/database/.sqlx/query-94405ea4ea79665d1306c3d7c6cab9f0b52b1fb44d9097169324681ff3e600a3.json deleted file mode 100644 index d6c39eada..000000000 --- a/crates/database/.sqlx/query-94405ea4ea79665d1306c3d7c6cab9f0b52b1fb44d9097169324681ff3e600a3.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM dashboard_handoffs\n WHERE ctid IN (\n SELECT ctid\n FROM dashboard_handoffs\n WHERE expires_at < now()\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "94405ea4ea79665d1306c3d7c6cab9f0b52b1fb44d9097169324681ff3e600a3" -} diff --git a/crates/database/.sqlx/query-a25d691356e678ef3ef65aefb62eaec18df6ce522121fd55fb6fbc48a15f7f73.json b/crates/database/.sqlx/query-a25d691356e678ef3ef65aefb62eaec18df6ce522121fd55fb6fbc48a15f7f73.json deleted file mode 100644 index 14fe877f5..000000000 --- a/crates/database/.sqlx/query-a25d691356e678ef3ef65aefb62eaec18df6ce522121fd55fb6fbc48a15f7f73.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM pending_federation\n WHERE ctid IN (\n SELECT ctid\n FROM pending_federation\n WHERE expires_at < now()\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "a25d691356e678ef3ef65aefb62eaec18df6ce522121fd55fb6fbc48a15f7f73" -} diff --git a/crates/database/.sqlx/query-be832e00fd156f8eb6a099f62c6b3c469bafbf26e4adb86c414c01d3788f5c1a.json b/crates/database/.sqlx/query-be832e00fd156f8eb6a099f62c6b3c469bafbf26e4adb86c414c01d3788f5c1a.json deleted file mode 100644 index 55f1e2e9d..000000000 --- a/crates/database/.sqlx/query-be832e00fd156f8eb6a099f62c6b3c469bafbf26e4adb86c414c01d3788f5c1a.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM event_personal_data\n WHERE ctid IN (\n SELECT ctid\n FROM event_personal_data\n WHERE created_at < now() - interval '90 days'\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "be832e00fd156f8eb6a099f62c6b3c469bafbf26e4adb86c414c01d3788f5c1a" -} diff --git a/crates/database/.sqlx/query-c320da751bb997b2a754370f42ef2cc1dd5a571b2a30b9dbd402dd771ef8361e.json b/crates/database/.sqlx/query-c320da751bb997b2a754370f42ef2cc1dd5a571b2a30b9dbd402dd771ef8361e.json new file mode 100644 index 000000000..dfca56433 --- /dev/null +++ b/crates/database/.sqlx/query-c320da751bb997b2a754370f42ef2cc1dd5a571b2a30b9dbd402dd771ef8361e.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM invitations WHERE ctid IN (SELECT ctid FROM invitations WHERE expires_at < now()\n OR redeemed_at < now() - interval '1 day' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "c320da751bb997b2a754370f42ef2cc1dd5a571b2a30b9dbd402dd771ef8361e" +} diff --git a/crates/database/.sqlx/query-d75d045352aaa9aeb2746fa4298283d3bd9c080d34a3124cecd1f4452b145c79.json b/crates/database/.sqlx/query-d75d045352aaa9aeb2746fa4298283d3bd9c080d34a3124cecd1f4452b145c79.json new file mode 100644 index 000000000..28f5f3ed8 --- /dev/null +++ b/crates/database/.sqlx/query-d75d045352aaa9aeb2746fa4298283d3bd9c080d34a3124cecd1f4452b145c79.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM account_recoveries WHERE ctid IN (SELECT ctid FROM account_recoveries WHERE CASE WHEN completed_at IS NULL THEN least(expires_at, cancelled_at)\n ELSE least(undone_at, settles_at) END < now() - interval '90 days' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "d75d045352aaa9aeb2746fa4298283d3bd9c080d34a3124cecd1f4452b145c79" +} diff --git a/crates/database/.sqlx/query-da1ea4df7b04ce065148aaa24982ebd1ab61dd30551624b92b580287dd5d8679.json b/crates/database/.sqlx/query-da1ea4df7b04ce065148aaa24982ebd1ab61dd30551624b92b580287dd5d8679.json new file mode 100644 index 000000000..46e2d9d13 --- /dev/null +++ b/crates/database/.sqlx/query-da1ea4df7b04ce065148aaa24982ebd1ab61dd30551624b92b580287dd5d8679.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM authorization_requests WHERE ctid IN (SELECT ctid FROM authorization_requests WHERE expires_at < now()\n OR consumed_at < now() - interval '1 day' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "da1ea4df7b04ce065148aaa24982ebd1ab61dd30551624b92b580287dd5d8679" +} diff --git a/crates/database/.sqlx/query-e1b82dcff5286c2e267048a3261b8d584390fc374340cc1b78f71d79f8be4748.json b/crates/database/.sqlx/query-e1b82dcff5286c2e267048a3261b8d584390fc374340cc1b78f71d79f8be4748.json new file mode 100644 index 000000000..caa17ba95 --- /dev/null +++ b/crates/database/.sqlx/query-e1b82dcff5286c2e267048a3261b8d584390fc374340cc1b78f71d79f8be4748.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM event_personal_data WHERE ctid IN (SELECT ctid FROM event_personal_data WHERE created_at < now() - interval '90 days' LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "e1b82dcff5286c2e267048a3261b8d584390fc374340cc1b78f71d79f8be4748" +} diff --git a/crates/database/.sqlx/query-e26adc5e8dd9dfd42dfcb63617179a968f577302301c589ff3504fb8dfade97c.json b/crates/database/.sqlx/query-e26adc5e8dd9dfd42dfcb63617179a968f577302301c589ff3504fb8dfade97c.json new file mode 100644 index 000000000..befaabda3 --- /dev/null +++ b/crates/database/.sqlx/query-e26adc5e8dd9dfd42dfcb63617179a968f577302301c589ff3504fb8dfade97c.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM request_limits WHERE ctid IN (SELECT ctid FROM request_limits WHERE expires_at < now() LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "e26adc5e8dd9dfd42dfcb63617179a968f577302301c589ff3504fb8dfade97c" +} diff --git a/crates/database/.sqlx/query-eb6bb66024947f552c3fa7e1e8b56725209b50a104c12f5027cc569852403506.json b/crates/database/.sqlx/query-eb6bb66024947f552c3fa7e1e8b56725209b50a104c12f5027cc569852403506.json new file mode 100644 index 000000000..fc31a024d --- /dev/null +++ b/crates/database/.sqlx/query-eb6bb66024947f552c3fa7e1e8b56725209b50a104c12f5027cc569852403506.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM dashboard_handoffs WHERE ctid IN (SELECT ctid FROM dashboard_handoffs WHERE expires_at < now() LIMIT $1 FOR UPDATE SKIP LOCKED)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "eb6bb66024947f552c3fa7e1e8b56725209b50a104c12f5027cc569852403506" +} diff --git a/crates/database/.sqlx/query-ecf64133f9a1f146f7244e6cb05e2d0aa5e25ef03fc3cdc684f94ee6ac89c359.json b/crates/database/.sqlx/query-ecf64133f9a1f146f7244e6cb05e2d0aa5e25ef03fc3cdc684f94ee6ac89c359.json deleted file mode 100644 index 4fcfc4310..000000000 --- a/crates/database/.sqlx/query-ecf64133f9a1f146f7244e6cb05e2d0aa5e25ef03fc3cdc684f94ee6ac89c359.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM dashboard_sessions\n WHERE ctid IN (\n SELECT ctid\n FROM dashboard_sessions\n WHERE expires_at < now()\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "ecf64133f9a1f146f7244e6cb05e2d0aa5e25ef03fc3cdc684f94ee6ac89c359" -} diff --git a/crates/database/.sqlx/query-fb8ad58c1be4603e48f6e397d5ca91f9a7eae83fea6929d6aeaa573590a7a14f.json b/crates/database/.sqlx/query-fb8ad58c1be4603e48f6e397d5ca91f9a7eae83fea6929d6aeaa573590a7a14f.json deleted file mode 100644 index 3634c2a3a..000000000 --- a/crates/database/.sqlx/query-fb8ad58c1be4603e48f6e397d5ca91f9a7eae83fea6929d6aeaa573590a7a14f.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "DELETE FROM request_limits\n WHERE ctid IN (\n SELECT ctid\n FROM request_limits\n WHERE expires_at < now()\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n )", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8" - ] - }, - "nullable": [] - }, - "hash": "fb8ad58c1be4603e48f6e397d5ca91f9a7eae83fea6929d6aeaa573590a7a14f" -} diff --git a/crates/database/src/repositories/maintenance/mod.rs b/crates/database/src/repositories/maintenance/mod.rs index edecc5d0a..83f5af4c7 100644 --- a/crates/database/src/repositories/maintenance/mod.rs +++ b/crates/database/src/repositories/maintenance/mod.rs @@ -99,34 +99,38 @@ impl MaintenanceRepository<'_> { ) -> Result { let limit = i64::from(batch_size.clamp(1, MAX_PURGE_BATCH)); // Runs each statement in order, each removing at most `$1` expired rows - // that no live request has locked. A checked query needs a literal, and - // each has its own type, so the statements cannot share a loop. + // that no live request has locked, and adds up what they removed. A + // checked query needs a literal, and each has its own type, so the + // statements cannot share a loop. Most delete the rows of one table that + // match a condition, which `$table where $condition` writes; the rest + // join, lock only some of the tables they read (`FOR UPDATE OF`), or + // check other tables against the row, so they keep their full SQL. The + // second arm's `+` pieces are only for the first arm to pass through. + let mut purged = 0; macro_rules! purge { - ($($statement:literal,)+) => { - Ok(0 $(+ run!(self, execute, sqlx::query!($statement, limit))?.rows_affected())+) + ($table:literal where $condition:literal) => { + purge!( + "DELETE FROM " + + $table + + " WHERE ctid IN (SELECT ctid FROM " + + $table + + " WHERE " + + $condition + + " LIMIT $1 FOR UPDATE SKIP LOCKED)" + ) + }; + ($statement:literal $(+ $more:literal)*) => { + purged += run!(self, execute, sqlx::query!($statement $(+ $more)*, limit))? + .rows_affected() }; } + purge!("request_limits" where "expires_at < now()"); + purge!("invitations" where "expires_at < now() + OR redeemed_at < now() - interval '1 day'"); + // An unverified address goes with its expired verification link; the + // secret's row cascades. Both rows are locked, skipping any a + // verification holds, so cleanup never waits on one. purge!( - "DELETE FROM request_limits - WHERE ctid IN ( - SELECT ctid - FROM request_limits - WHERE expires_at < now() - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - "DELETE FROM invitations - WHERE ctid IN ( - SELECT ctid - FROM invitations - WHERE expires_at < now() - OR redeemed_at < now() - interval '1 day' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - // An unverified address goes with its expired verification link; the - // secret's row cascades. Both rows are locked, skipping any a - // verification holds, so cleanup never waits on one. "DELETE FROM user_emails WHERE id IN ( SELECT secret.email_id @@ -136,66 +140,26 @@ impl MaintenanceRepository<'_> { AND email.verified_at IS NULL LIMIT $1 FOR UPDATE OF secret, email SKIP LOCKED - )", - "DELETE FROM pending_federation - WHERE ctid IN ( - SELECT ctid - FROM pending_federation - WHERE expires_at < now() - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - "DELETE FROM federation_transactions - WHERE ctid IN ( - SELECT ctid - FROM federation_transactions - WHERE expires_at < now() - OR consumed_at < now() - interval '1 day' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - "DELETE FROM webauthn_ceremonies - WHERE ctid IN ( - SELECT ctid - FROM webauthn_ceremonies - WHERE expires_at < now() - OR consumed_at < now() - interval '1 day' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - "DELETE FROM dashboard_handoffs - WHERE ctid IN ( - SELECT ctid - FROM dashboard_handoffs - WHERE expires_at < now() - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - // A session that went unused too long has ended too, but stays until - // its `expires_at`, which comes soon after. - "DELETE FROM dashboard_sessions - WHERE ctid IN ( - SELECT ctid - FROM dashboard_sessions - WHERE expires_at < now() - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - "DELETE FROM authorization_requests - WHERE ctid IN ( - SELECT ctid - FROM authorization_requests - WHERE expires_at < now() - OR consumed_at < now() - interval '1 day' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - // A redeemed code stays while a replay could still revoke something: an - // unrevoked family it produced whose session is live (refresh tokens expire - // with the session). The first day after redemption is kept regardless, so - // replays are still recorded even for codes that produced no refresh family. - // Retained codes are rechecked on every pass, so this scan grows with - // every redeemed code past its first day, not only with purgeable ones. + )" + ); + purge!("pending_federation" where "expires_at < now()"); + purge!("federation_transactions" where "expires_at < now() + OR consumed_at < now() - interval '1 day'"); + purge!("webauthn_ceremonies" where "expires_at < now() + OR consumed_at < now() - interval '1 day'"); + purge!("dashboard_handoffs" where "expires_at < now()"); + // A session that went unused too long has ended too, but stays until + // its `expires_at`, which comes soon after. + purge!("dashboard_sessions" where "expires_at < now()"); + purge!("authorization_requests" where "expires_at < now() + OR consumed_at < now() - interval '1 day'"); + // A redeemed code stays while a replay could still revoke something: an + // unrevoked family it produced whose session is live (refresh tokens expire + // with the session). The first day after redemption is kept regardless, so + // replays are still recorded even for codes that produced no refresh family. + // Retained codes are rechecked on every pass, so this scan grows with + // every redeemed code past its first day, not only with purgeable ones. + purge!( "DELETE FROM authorization_codes c WHERE c.ctid IN ( SELECT code.ctid @@ -215,7 +179,9 @@ impl MaintenanceRepository<'_> { ) LIMIT $1 FOR UPDATE OF code SKIP LOCKED - )", + )" + ); + purge!( "DELETE FROM refresh_tokens t WHERE t.ctid IN ( SELECT token.ctid @@ -225,7 +191,9 @@ impl MaintenanceRepository<'_> { OR family.revoked_at < now() - interval '1 day' LIMIT $1 FOR UPDATE OF token SKIP LOCKED - )", + )" + ); + purge!( "DELETE FROM refresh_token_families f WHERE f.ctid IN ( SELECT family.ctid @@ -241,7 +209,9 @@ impl MaintenanceRepository<'_> { ) LIMIT $1 FOR UPDATE SKIP LOCKED - )", + )" + ); + purge!( "DELETE FROM browser_session_secrets b WHERE b.ctid IN ( SELECT secret.ctid @@ -251,69 +221,29 @@ impl MaintenanceRepository<'_> { OR session.revoked_at < now() - interval '1 day' LIMIT $1 FOR UPDATE OF secret SKIP LOCKED - )", - // A browser unused for 400 days has lost its device cookie, which - // lives as long: its next sign-in is a new device's either way. - "DELETE FROM known_devices - WHERE ctid IN ( - SELECT ctid - FROM known_devices - WHERE last_seen_at < now() - interval '400 days' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - // Events are kept indefinitely; the personal data beside them is not. - // A purge erasing its apps' origins may hold some of these rows. - "DELETE FROM event_personal_data - WHERE ctid IN ( - SELECT ctid - FROM event_personal_data - WHERE created_at < now() - interval '90 days' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - // An account's ended records go once its history no longer shows their - // events' details, 90 days on, as event personal data does. - "DELETE FROM passkey_credentials - WHERE ctid IN ( - SELECT ctid - FROM passkey_credentials - WHERE revoked_at < now() - interval '90 days' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - "DELETE FROM external_login_identities - WHERE ctid IN ( - SELECT ctid - FROM external_login_identities - WHERE revoked_at < now() - interval '90 days' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - // A recovery ends when it is undone or its probation settles, or, - // unused, when its link is cancelled or expires, whichever comes first: - // cancelling an expired link, as the next start does, ends nothing. - "DELETE FROM account_recoveries - WHERE ctid IN ( - SELECT ctid - FROM account_recoveries - WHERE CASE WHEN completed_at IS NULL THEN least(expires_at, cancelled_at) - ELSE least(undone_at, settles_at) END < now() - interval '90 days' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - "DELETE FROM notifications - WHERE ctid IN ( - SELECT ctid - FROM notifications - WHERE created_at < now() - interval '1 year' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", - // Who received an announcement goes with the inbox copies, a year on. - // One to every account stays, as the administrators' record of what - // they said; one to chosen accounts may concern them, so it goes - // with its last recipient, as a purge does. + )" + ); + // A browser unused for 400 days has lost its device cookie, which + // lives as long: its next sign-in is a new device's either way. + purge!("known_devices" where "last_seen_at < now() - interval '400 days'"); + // Events are kept indefinitely; the personal data beside them is not. + // A purge erasing its apps' origins may hold some of these rows. + purge!("event_personal_data" where "created_at < now() - interval '90 days'"); + // An account's ended records go once its history no longer shows their + // events' details, 90 days on, as event personal data does. + purge!("passkey_credentials" where "revoked_at < now() - interval '90 days'"); + purge!("external_login_identities" where "revoked_at < now() - interval '90 days'"); + // A recovery ends when it is undone or its probation settles, or, + // unused, when its link is cancelled or expires, whichever comes first: + // cancelling an expired link, as the next start does, ends nothing. + purge!("account_recoveries" where "CASE WHEN completed_at IS NULL THEN least(expires_at, cancelled_at) + ELSE least(undone_at, settles_at) END < now() - interval '90 days'"); + purge!("notifications" where "created_at < now() - interval '1 year'"); + // Who received an announcement goes with the inbox copies, a year on. + // One to every account stays, as the administrators' record of what + // they said; one to chosen accounts may concern them, so it goes + // with its last recipient, as a purge does. + purge!( "DELETE FROM announcement_recipients r WHERE r.ctid IN ( SELECT recipient.ctid @@ -322,7 +252,9 @@ impl MaintenanceRepository<'_> { WHERE a.sent_at < now() - interval '1 year' LIMIT $1 FOR UPDATE OF recipient SKIP LOCKED - )", + )" + ); + purge!( "DELETE FROM announcements a WHERE a.ctid IN ( SELECT announcement.ctid @@ -335,18 +267,13 @@ impl MaintenanceRepository<'_> { ) LIMIT $1 FOR UPDATE SKIP LOCKED - )", - // A purged account's handles were released at its purge (the - // `handles_release_purged` trigger), and stay reserved a year, so - // nobody takes one to pass for it. - "DELETE FROM handles - WHERE ctid IN ( - SELECT ctid - FROM handles - WHERE user_id IS NULL AND released_at < now() - interval '1 year' - LIMIT $1 - FOR UPDATE SKIP LOCKED - )", + )" + ); + // A purged account's handles were released at its purge (the + // `handles_release_purged` trigger), and stay reserved a year, so + // nobody takes one to pass for it. + purge!("handles" where "user_id IS NULL AND released_at < now() - interval '1 year'"); + purge!( "DELETE FROM deliveries d WHERE d.ctid IN ( SELECT delivery.ctid @@ -358,7 +285,9 @@ impl MaintenanceRepository<'_> { ) LIMIT $1 FOR UPDATE SKIP LOCKED - )", + )" + ); + purge!( "DELETE FROM sessions s WHERE s.ctid IN ( SELECT session.ctid @@ -379,8 +308,9 @@ impl MaintenanceRepository<'_> { ) LIMIT $1 FOR UPDATE SKIP LOCKED - )", - ) + )" + ); + Ok(purged) } }