AiderSQLDatabase

SQL Aider Conventions

Aider conventions for SQL and database migrations: naming, formatting, and migration patterns.

CONVENTIONS.md
- Use snake_case for all database object names: tables, columns, indexes, functions
- Name indexes: idx_<table>_<columns> for regular, uq_<table>_<columns> for unique
- Name foreign keys: fk_<child_table>_<parent_table> for clarity
- Use timestamptz (not timestamp) for all timestamp columns to avoid timezone bugs
- Write migration files as: YYYYMMDDHHMMSS_<verb>_<subject>.sql
- Never modify existing migration files; always create new migrations for changes
- Add comments to all tables and columns in the migration SQL
- Test rollback migration before shipping the forward migration

How to use with Aider

Create a `CONVENTIONS.md` file in your project root. Aider reads this and respects your conventions when generating changes.

#sql#aider#migrations#naming#coding-rules

Related Rules