Add idempotent Alembic migrations, auto-migrate on startup, update summary

Rewrite migrations to raw SQL with IF NOT EXISTS/EXCEPTION guards for
full idempotency. Add notes table migration (0001), fix migration chain,
and run alembic upgrade head in Dockerfile CMD on container start.
Update summary.md with Phase 3.5 changes and Alembic instructions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-09 23:55:40 -05:00
parent 22a3a3c1d1
commit e2338918b0
4 changed files with 232 additions and 95 deletions
@@ -0,0 +1,33 @@
"""create notes table
Revision ID: 0001
Revises:
Create Date: 2025-01-01 00:00:00.000000
"""
from alembic import op
revision = "0001"
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
op.execute("""
CREATE TABLE IF NOT EXISTS notes (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL DEFAULT '',
body TEXT NOT NULL DEFAULT '',
tags TEXT[] NOT NULL DEFAULT '{}',
parent_id INTEGER REFERENCES notes(id) ON DELETE SET NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
)
""")
op.execute("CREATE INDEX IF NOT EXISTS ix_notes_tags ON notes USING gin (tags)")
def downgrade() -> None:
op.execute("DROP INDEX IF EXISTS ix_notes_tags")
op.execute("DROP TABLE IF EXISTS notes")