34 lines
933 B
Python
34 lines
933 B
Python
"""0008 inventory fields
|
|
|
|
Adds location, connection_params, vendor columns to devices.
|
|
|
|
Revision ID: 0008
|
|
Revises: 0007
|
|
Create Date: 2026-04-07
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
|
|
revision = "0008"
|
|
down_revision = "0007"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("devices", sa.Column("vendor", sa.String(255), nullable=True))
|
|
op.add_column("devices", sa.Column("location", sa.String(20), nullable=True))
|
|
op.add_column(
|
|
"devices",
|
|
sa.Column("connection_params", JSONB, nullable=False, server_default="{}"),
|
|
)
|
|
op.create_index("ix_devices_location", "devices", ["location"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_devices_location", table_name="devices")
|
|
op.drop_column("devices", "connection_params")
|
|
op.drop_column("devices", "location")
|
|
op.drop_column("devices", "vendor")
|