40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
"""Cache 3x-ui inbounds and user availability flags
|
|
|
|
Revision ID: 0007_xui_panel_inbounds
|
|
Revises: 0006_xui_site_clients
|
|
Create Date: 2026-07-25
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0007_xui_panel_inbounds"
|
|
down_revision: Union[str, None] = "0006_xui_site_clients"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"xui_panel_inbounds",
|
|
sa.Column("id", sa.Integer(), primary_key=True),
|
|
sa.Column("panel_id", sa.Integer(), sa.ForeignKey("xui_panels.id", ondelete="CASCADE"), nullable=False),
|
|
sa.Column("inbound_id", sa.Integer(), nullable=False),
|
|
sa.Column("protocol", sa.String(length=32), nullable=False),
|
|
sa.Column("remark", sa.String(length=255), nullable=True),
|
|
sa.Column("port", sa.Integer(), nullable=True),
|
|
sa.Column("enable", sa.Boolean(), nullable=False, server_default=sa.text("true")),
|
|
sa.Column("is_available_for_users", sa.Boolean(), nullable=False, server_default=sa.text("false")),
|
|
sa.Column("last_synced_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
|
sa.UniqueConstraint("panel_id", "inbound_id", name="uq_xui_panel_inbound"),
|
|
)
|
|
op.create_index("ix_xui_panel_inbounds_panel_id", "xui_panel_inbounds", ["panel_id"])
|
|
op.create_index("ix_xui_panel_inbounds_protocol", "xui_panel_inbounds", ["protocol"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("xui_panel_inbounds")
|