aboutsummaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/mariadb/init.sql10
1 files changed, 10 insertions, 0 deletions
diff --git a/docker/mariadb/init.sql b/docker/mariadb/init.sql
index 2cc0d6f..29f0733 100644
--- a/docker/mariadb/init.sql
+++ b/docker/mariadb/init.sql
@@ -28,6 +28,16 @@ CREATE TABLE IF NOT EXISTS likes (
FOREIGN KEY (post_id) REFERENCES posts(id) ON DELETE CASCADE
);
+-- Tracks actions per IP for rate limiting (e.g. failed logins, password resets).
+-- Old rows are cleaned up on each check so the table doesn't grow unbounded.
+CREATE TABLE IF NOT EXISTS rate_limits (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ ip VARCHAR(45) NOT NULL,
+ action VARCHAR(30) NOT NULL,
+ attempted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ INDEX idx_rate_limits_lookup (ip, action, attempted_at)
+);
+
CREATE TABLE IF NOT EXISTS comments (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,