repertory-api/migrations/versions/abdeb80d003e_add_tunings.py

33 lines
984 B
Python
Raw Normal View History

2026-06-09 15:07:08 -04:00
"""add tunings table and tuning_id fk on tune_by_instrument
Revision ID: abdeb80d003e
Revises: 84db90f5499e
Create Date: 2026-06-09
"""
from alembic import op
import sqlalchemy as sa
revision = "abdeb80d003e"
down_revision = "84db90f5499e"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"tunings",
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True, nullable=False),
sa.Column("name", sa.String(), nullable=False, unique=True),
)
op.drop_column("tune_by_instrument", "tuning")
op.add_column("tune_by_instrument",
sa.Column("tuning_id", sa.Integer(),
sa.ForeignKey("tunings.id", ondelete="SET NULL"),
nullable=True))
def downgrade() -> None:
op.drop_column("tune_by_instrument", "tuning_id")
op.add_column("tune_by_instrument", sa.Column("tuning", sa.String(), nullable=True))
op.drop_table("tunings")