Lab references deep-link to article sections or external sources, show linked cards with study links, and educators can attach cards and article targets. Grouped panel layout. Migration i2d3e4f5a607. 57 backend and 93 frontend tests pass.
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
"""Lab reference article deep links and card associations.
|
|
|
|
Revision ID: i2d3e4f5a607
|
|
Revises: h1c2d3e4f506
|
|
"""
|
|
from alembic import op
|
|
|
|
revision = "i2d3e4f5a607"
|
|
down_revision = "h1c2d3e4f506"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
op.execute("ALTER TABLE lab_reference_values ADD COLUMN IF NOT EXISTS article_id INTEGER REFERENCES articles(id) ON DELETE SET NULL")
|
|
op.execute("ALTER TABLE lab_reference_values ADD COLUMN IF NOT EXISTS article_section_id VARCHAR(64)")
|
|
op.execute("""
|
|
CREATE TABLE IF NOT EXISTS lab_reference_card_links (
|
|
id SERIAL PRIMARY KEY,
|
|
lab_reference_id INTEGER NOT NULL REFERENCES lab_reference_values(id) ON DELETE CASCADE,
|
|
flashcard_id INTEGER NOT NULL REFERENCES flashcards(id) ON DELETE CASCADE,
|
|
CONSTRAINT uq_lab_card_link UNIQUE (lab_reference_id, flashcard_id)
|
|
)""")
|
|
op.execute("CREATE INDEX IF NOT EXISTS ix_lab_reference_card_links_lab ON lab_reference_card_links (lab_reference_id)")
|
|
|
|
|
|
def downgrade():
|
|
op.execute("DROP TABLE IF EXISTS lab_reference_card_links")
|
|
op.execute("ALTER TABLE lab_reference_values DROP COLUMN IF EXISTS article_section_id")
|
|
op.execute("ALTER TABLE lab_reference_values DROP COLUMN IF EXISTS article_id")
|