Skip to content

Commit b1709ad

Browse files
committed
feat(migration): add player connection history cleanup trigger
1 parent 16ebe4b commit b1709ad

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Knex } from "knex";
2+
3+
4+
export async function up(knex: Knex): Promise<void> {
5+
await knex.raw(`
6+
CREATE TRIGGER player_connection_history_cleanup
7+
AFTER INSERT ON player_connection_history
8+
BEGIN
9+
DELETE FROM player_connection_history
10+
WHERE timestamp < datetime('now', '-90 days');
11+
END;
12+
`);
13+
}
14+
15+
16+
export async function down(knex: Knex): Promise<void> {
17+
await knex.raw("DROP TRIGGER IF EXISTS player_connection_history_cleanup;");
18+
}
19+

0 commit comments

Comments
 (0)