Databases
python
Intermediate
Alembic Migration Boilerplate
Alembic migration file with upgrade and downgrade steps and proper op helpers.
python
"""Add modules table"""
revision = 'abc123'
down_revision = None
from alembic import op
import sqlalchemy as sa
def upgrade() -> None:
op.create_table('modules',
sa.Column('id', sa.Integer(), primary_key=True),
sa.Column('slug', sa.String(255), unique=True, nullable=False),
sa.Column('title', sa.String(255), nullable=False),
sa.Column('code', sa.Text(), nullable=False),
)
def downgrade() -> None:
op.drop_table('modules')
Prerequisites
- alembic
- sqlalchemy
Pro Tips
- → Always implement downgrade() for safe rollbacks.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- python
- Level
- Intermediate
- Read time
- 3 min
- Published
- Mar 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
MySQL Replication Status Check
Script to check MySQL/MariaDB replication lag and alert if it exceeds threshold.
sql
·
Intermediate
DB Connection Pool Monitor
Query to check active connections, idle connections and pool usage in PostgreSQL.
sql
·
Intermediate
Cursor-based Pagination Query
Implement cursor-based (keyset) pagination in SQL — faster than OFFSET for large tables.
sql
·
Intermediate