pdf-quiz-generator/backend/alembic/versions/f2a1c9d4e801_comments.py
Daniel 0fa8d0a689 feat: shareable quiz links, moderated comments and AI authoring
Quiz share links replace the PIN copy with a public /share/{token} landing page; owners can enable/revoke without showing the full link. Moderated article/question comments with approval flow, bounds and rate limits. Educator AI article drafts/refine and private card generation with Celery job polling. Migrations f2a1c9d4e801 and g4b7e2f5a903. 50 backend and 85 frontend tests pass.
2026-09-07 17:10:08 +02:00

31 lines
1,015 B
Python

"""Moderated discussion comments.
Revision ID: f2a1c9d4e801
Revises: e8d4f1a27c93
"""
from alembic import op
revision = "f2a1c9d4e801"
down_revision = "e8d4f1a27c93"
branch_labels = None
depends_on = None
def upgrade():
op.execute("""
CREATE TABLE IF NOT EXISTS comments (
id SERIAL PRIMARY KEY,
article_id INTEGER REFERENCES articles(id) ON DELETE CASCADE,
question_id INTEGER REFERENCES questions(id) ON DELETE CASCADE,
user_id INTEGER REFERENCES users(id) ON DELETE SET NULL,
content TEXT NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'pending',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
)""")
op.execute("CREATE INDEX IF NOT EXISTS ix_comments_id ON comments (id)")
op.execute("CREATE INDEX IF NOT EXISTS ix_comments_article_id ON comments (article_id)")
op.execute("CREATE INDEX IF NOT EXISTS ix_comments_question_id ON comments (question_id)")
def downgrade():
op.execute("DROP TABLE IF EXISTS comments")