Skip to content

Add altcha_challenge table to migrations#330

Merged
Brutus5000 merged 1 commit intodevelopfrom
feature/altcha-challenge
Apr 4, 2026
Merged

Add altcha_challenge table to migrations#330
Brutus5000 merged 1 commit intodevelopfrom
feature/altcha-challenge

Conversation

@Brutus5000
Copy link
Copy Markdown
Member

@Brutus5000 Brutus5000 commented Mar 31, 2026

Summary by CodeRabbit

  • Chores
    • Added backend storage for short-lived challenge tokens used by verification/auth flows. Tokens are persisted with automatic expiration handling to ensure timely cleanup and improve security and reliability of challenge-based operations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 279fac46-b914-4b5c-993a-ca8fc052e42e

📥 Commits

Reviewing files that changed from the base of the PR and between ad3fbfc and 1fed28f.

📒 Files selected for processing (1)
  • migrations/V142__add_altcha_challenge_table.sql
🚧 Files skipped from review as they are similar to previous changes (1)
  • migrations/V142__add_altcha_challenge_table.sql

📝 Walkthrough

Walkthrough

Adds a new SQL migration (V142) that creates an altcha_challenge table with challenge (VARCHAR(64) primary key) and expires_at (DATETIME) plus an index on expires_at.

Changes

Cohort / File(s) Summary
Database Migration
migrations/V142__add_altcha_challenge_table.sql
Adds altcha_challenge table: challenge VARCHAR(64) NOT NULL (PK), expires_at DATETIME NOT NULL; creates index idx_altcha_challenge_expires_at on expires_at.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thumped a key, I dug a row, 🐇
A tiny table soft and new,
Challenges stored where sunsets go,
Timestamps ticking, tidy too,
Hooray for schema — hop, review!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new database table called altcha_challenge to the migrations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/altcha-challenge

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@migrations/V142__add_altcha_challenge_table.sql`:
- Line 3: The migration defines expires_at as DATETIME on the altcha_challenge
table and lacks an index; update the migration so the expires_at column uses the
project-convention timestamp type (use TIMESTAMP NOT NULL to match avatar/other
tables) and add an index on expires_at (e.g., CREATE INDEX on
altcha_challenge(expires_at) or include INDEX expires_at in the CREATE TABLE) so
queries like WHERE expires_at < ... can use the index; modify the
V142__add_altcha_challenge_table.sql migration accordingly referencing the
altcha_challenge table and expires_at column.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9732c667-7f11-48e9-a99f-dcc13db4bf61

📥 Commits

Reviewing files that changed from the base of the PR and between 57b8db4 and ad3fbfc.

📒 Files selected for processing (1)
  • migrations/V142__add_altcha_challenge_table.sql

@@ -0,0 +1,5 @@
CREATE TABLE altcha_challenge (
challenge VARCHAR(64) NOT NULL,
expires_at DATETIME NOT NULL,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find how expiration/time columns are modeled in other migrations
rg -n --type-add 'sql:*.sql' --type sql -C2 '\b(expires_at|expire|expiration|TIMESTAMP|DATETIME)\b' migrations

Repository: FAForever/db

Length of output: 2878


🏁 Script executed:

#!/bin/bash
# Search for cleanup queries or queries filtering by expiration
rg -n 'expires_at\s*[<>=]' --type-add 'sql:*.sql' --type sql migrations

Repository: FAForever/db

Length of output: 38


🏁 Script executed:

#!/bin/bash
# Also check application code for altcha_challenge queries
rg -n 'altcha_challenge' --type-list | head -20
rg -rn 'altcha' --type-add 'ts:*.ts' --type-add 'js:*.js' -A 3 -B 3 2>/dev/null | head -50

Repository: FAForever/db

Length of output: 773


🏁 Script executed:

#!/bin/bash
# Check the full migration file to understand context
cat migrations/V142__add_altcha_challenge_table.sql

Repository: FAForever/db

Length of output: 182


🏁 Script executed:

#!/bin/bash
# Search for altcha references in the entire repository (outside migrations)
find . -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" -o -name "*.java" \) ! -path "./migrations/*" -exec grep -l "altcha" {} \; 2>/dev/null | head -20

Repository: FAForever/db

Length of output: 38


🏁 Script executed:

#!/bin/bash
# Check repository structure to find application code
ls -la | grep -E '^d'
find . -maxdepth 2 -type d -name "src" -o -name "app" -o -name "server" -o -name "backend" 2>/dev/null

Repository: FAForever/db

Length of output: 507


🏁 Script executed:

#!/bin/bash
# Search for any expiration cleanup patterns in the codebase to see if this pattern is used elsewhere
rg -n 'WHERE.*<\s*(CURRENT|NOW|UNIX_TIMESTAMP)' --type-add 'sql:*.sql' --type sql 2>/dev/null | head -20

Repository: FAForever/db

Length of output: 38


Add an index on expires_at and align timestamp column type with project convention.

This table uses DATETIME for expiration, but the codebase mixes DATETIME and TIMESTAMP (see avatar table uses TIMESTAMP, ban table uses DATETIME). Clarify which convention applies and ensure consistency. Additionally, if the application code queries expired challenges with WHERE expires_at < ..., an index on this column will prevent full table scans.

💡 Proposed migration adjustment
 CREATE TABLE altcha_challenge (
   challenge VARCHAR(64) NOT NULL,
   expires_at DATETIME NOT NULL,
   PRIMARY KEY (challenge)
 );
+
+CREATE INDEX idx_altcha_challenge_expires_at
+  ON altcha_challenge (expires_at);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expires_at DATETIME NOT NULL,
CREATE TABLE altcha_challenge (
challenge VARCHAR(64) NOT NULL,
expires_at DATETIME NOT NULL,
PRIMARY KEY (challenge)
);
CREATE INDEX idx_altcha_challenge_expires_at
ON altcha_challenge (expires_at);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@migrations/V142__add_altcha_challenge_table.sql` at line 3, The migration
defines expires_at as DATETIME on the altcha_challenge table and lacks an index;
update the migration so the expires_at column uses the project-convention
timestamp type (use TIMESTAMP NOT NULL to match avatar/other tables) and add an
index on expires_at (e.g., CREATE INDEX on altcha_challenge(expires_at) or
include INDEX expires_at in the CREATE TABLE) so queries like WHERE expires_at <
... can use the index; modify the V142__add_altcha_challenge_table.sql migration
accordingly referencing the altcha_challenge table and expires_at column.

@Brutus5000 Brutus5000 force-pushed the feature/altcha-challenge branch from ad3fbfc to 1fed28f Compare April 4, 2026 07:07
@Brutus5000 Brutus5000 merged commit 3020887 into develop Apr 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant