Skip to content

Database Migration Guide

NOTE: See REMAINING_FUNCTIONALITY.md for the latest implementation status.

This guide describes how to run Alembic database migrations for EvoSpikeNet.

Prerequisites - alembic installed (see requirements.txt) - DATABASE_URL environment variable set and pointing to your database (Postgres recommended) - Backup your database before applying migrations

Quick start

# install dependencies into your virtualenv
pip install -r requirements.txt

# Ensure DATABASE_URL is set, e.g.:
export DATABASE_URL=postgresql://user:pass@db-host:5432/evospikenet

# Initialize alembic (if not already initialized)
# alembic init alembic

# Generate revision (only if you modify models)
# alembic revision --autogenerate -m "describe change"

# Apply migrations
alembic upgrade head

Notes - The repository includes a migration that adds an encrypted column to data_artifacts at alembic/versions/20260304_add_dataartifact_encrypted_column.py. - Test migrations against a staging copy of your production DB before applying in production. - If you use a different DB URL for migrations, set sqlalchemy.url in alembic.ini or rely on the DATABASE_URL environment variable.

Rollback

# show history
alembic history --verbose
# downgrade to previous revision
alembic downgrade -1

If you want help adding Alembic steps into CI (GitHub Actions), I can add a recommended workflow snippet.