RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Cursor rules/iloveitaly/llm-ide-rules

Cursor rule

.cursor/rules/alembic-migrations.mdc

Alembic Migrations

Cursor rules

Quality

50/100

Scores the file, not the repository.

Length

175 words

6 headings · 3 code blocks

Repository

13

— · pushed 33 days ago

Last changed

3 days ago

First indexed 3 days ago.
iloveitaly/llm-ide-rules/.cursor/rules/alembic-migrations.mdcRawGitHub
1---
2description: Alembic Migrations
3globs: migrations/versions/*.py
4alwaysApply: false
5---
6## Alembic Migrations
7 
8 
9### Default Content for New Non-Nullable Columns
10 
11To add a non-nullable column and set a specific value for all existing rows without a persistent server default:
12 
13```python
14# 1. Add the column as nullable (no default needed):
15op.add_column('distribution', sa.Column('default_campaign_ending_date', sa.DateTime(timezone=True), nullable=True))
16# 2. Update existing rows with your desired value (e.g., a specific datetime)
17op.execute("UPDATE distribution SET default_campaign_ending_date = %s", [datetime.utcnow()])
18# 3. Alter the column to non-nullable:
19op.alter_column('distribution', 'default_campaign_ending_date', nullable=False)
20```
21 
22### Record Backfill Operations
23 
24For migrations that include data mutation, and not only schema modifications, use this pattern to setup a session:
25 
26```python
27from alembic import op
28from sqlmodel import Session
29from activemodel.session_manager import global_session
30from app import log
31 
32def run_migration_helper():
33 pass
34 
35def upgrade() -> None:
36 session = Session(bind=op.get_bind())
37 
38 with global_session(session):
39 run_migration_helper()
40 flip_point_coordinates()
41 backfill_screening_host_data()
42 
43 # flush before running any other operations, otherwise not all changes will persist to the transaction
44 session.flush()
45```
46 
47However, if you don't need the business logic attached to the models, you can execute a query using `op.execute`:
48 
49```python
50op.execute(
51 TheModel.__table__.update().values({"a_field": "a_value"}) # type: ignore
52)
53```
54 

Sections

  • Alembic Migrations
  • Default Content for New Non-Nullable Columns
  • 1. Add the column as nullable (no default needed):
  • 2. Update existing rows with your desired value (e.g., a specific datetime)
  • 3. Alter the column to non-nullable:
  • Record Backfill Operations

Stack — with the evidence

python

(1.00)

pytest

(0.70)

ruff

(0.70)

github-actions

(0.60)

Glob targeting

  • migrations/versions/*.py

Format

Cursor rules

The most expressive format here. Many small .mdc files, each with frontmatter declaring when it should load, so a rule about migrations only enters context when a migration is open. Costs the most to maintain and only one editor reads it.

What the corpus says about it

Repository

Owner
iloveitaly
Language
—
License
—
Archived
no

All configs in this repo

Also in iloveitaly/llm-ide-rules

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
iloveitaly/llm-ide-rules.cursor/rules/python.mdc · 13Cursor rulespythonpytest+2setupstyletypesdo-not88/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/fastapi.mdc · 13Cursor rulespythonpytest+2no sections24/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/general.mdc · 13Cursor rulespythonpytest+2teststyledo-notagent-behaviour+192/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/justfiles.mdc · 13Cursor rulespythonpytest+2do-not31/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/pytest-integration-tests.mdc · 13Cursor rulespythonpytest+2teststyletesting-strategy73/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/pytest-tests.mdc · 13Cursor rulespythonpytest+2testarchtesting-strategyapi+161/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/python-app.mdc · 13Cursor rulespythonpytest+2styledatabasedocs61/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/python-route-tests.mdc · 13Cursor rulespythonpytest+2api24/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/react-router.mdc · 13Cursor rulespythonpytest+2testing-strategy57/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/react.mdc · 13Cursor rulespythonpytest+2styletesting-strategyuido-not60/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/shell.mdc · 13Cursor rulespythonpytest+2no sections4/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/typescript.mdc · 13Cursor rulespythonpytest+2styletypessecurity63/1003 days ago
iloveitaly/llm-ide-rules.github/copilot-instructions.md · 13Copilot instructionspythonpytest+2teststyledo-notagent-behaviour+192/1003 days ago
iloveitaly/llm-ide-rules.github/instructions/alembic-migrations.instructions.md · 13Copilot instructionspythonpytest+2no sections50/1003 days ago
iloveitaly/llm-ide-rules.github/instructions/fastapi.instructions.md · 13Copilot instructionspythonpytest+2no sections16/1003 days ago
iloveitaly/llm-ide-rules.github/instructions/justfiles.instructions.md · 13Copilot instructionspythonpytest+2do-not31/1003 days ago
iloveitaly/llm-ide-rules.github/instructions/pytest-integration-tests.instructions.md · 13Copilot instructionspythonpytest+2teststyletesting-strategy65/1003 days ago
iloveitaly/llm-ide-rules.github/instructions/pytest-tests.instructions.md · 13Copilot instructionspythonpytest+2testarchtesting-strategyapi+153/1003 days ago
iloveitaly/llm-ide-rules.github/instructions/python-app.instructions.md · 13Copilot instructionspythonpytest+2styledatabasedocs61/1003 days ago
iloveitaly/llm-ide-rules.github/instructions/python-route-tests.instructions.md · 13Copilot instructionspythonpytest+2api16/1003 days ago
Diff against .cursor/rules/python.mdc Diff against .cursor/rules/fastapi.mdc Diff against .cursor/rules/general.mdc Diff against .cursor/rules/justfiles.mdc Diff against .cursor/rules/pytest-integration-tests.mdc Diff against .cursor/rules/pytest-tests.mdc Diff against .cursor/rules/python-app.mdc Diff against .cursor/rules/python-route-tests.mdc Diff against .cursor/rules/react-router.mdc Diff against .cursor/rules/react.mdc Diff against .cursor/rules/shell.mdc Diff against .cursor/rules/typescript.mdc Diff against .github/copilot-instructions.md Diff against .github/instructions/alembic-migrations.instructions.md Diff against .github/instructions/fastapi.instructions.md Diff against .github/instructions/justfiles.instructions.md Diff against .github/instructions/pytest-integration-tests.instructions.md Diff against .github/instructions/pytest-tests.instructions.md Diff against .github/instructions/python-app.instructions.md Diff against .github/instructions/python-route-tests.instructions.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45Cursor rulestypescriptpytest+15testlint-formatstylearch+5100/1003 days ago
langflow-ai/langflow.cursor/rules/docs_development.mdc · 153kCursor rulespythonnode+16setupbuildtestlint-format+797/1003 days ago
TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45Cursor rulestypescriptpytest+15teststyletesting-strategysecurity+397/1003 days ago
nerds-odd-e/doughnut.cursor/rules/cli.mdc · 49Cursor rulestypescriptcypress+14setupbuildteststyle+496/1003 days ago
iloveitaly/llm-ide-rules.cursor/rules/general.mdc · 13Cursor rulespythonpytest+2teststyledo-notagent-behaviour+192/1003 days ago
danielvm-git/bigpowers.cursor/rules/guard-git.mdc · 119Cursor rulesshellnode+8stylearchgitsecurity+289/1003 days ago
nerds-odd-e/doughnut.cursor/rules/frontend-testing.mdc · 49Cursor rulestypescriptcypress+14buildteststyletesting-strategy+289/1003 days ago
danielvm-git/bigpowers.cursor/rules/organize-workspace.mdc · 119Cursor rulesshellnode+8buildstylegitdeployment+289/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack