e2338918b0
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>
34 lines
870 B
Python
34 lines
870 B
Python
"""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")
|