Add Phase 1 distributed lean workstation agent foundation
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""distributed lean workstation agent phase 1
|
||||
|
||||
Revision ID: 20260822_lean_agent_p1
|
||||
Revises: 20260811_normal_review
|
||||
Create Date: 2026-08-22
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "20260822_lean_agent_p1"
|
||||
down_revision = "20260811_normal_review"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"erp_workstation_agents",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("tenant_id", sa.Integer(), sa.ForeignKey("tenants.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("branch_id", sa.Integer(), sa.ForeignKey("branches.id", ondelete="SET NULL"), nullable=True),
|
||||
sa.Column("storage_node_id", sa.Integer(), sa.ForeignKey("branch_storage_nodes.id", ondelete="CASCADE"), nullable=False),
|
||||
sa.Column("agent_instance_id", sa.String(length=64), nullable=False),
|
||||
sa.Column("machine_fingerprint", sa.String(length=64), nullable=False),
|
||||
sa.Column("machine_name", sa.String(length=200), nullable=False),
|
||||
sa.Column("platform_name", sa.String(length=120), nullable=True),
|
||||
sa.Column("agent_version", sa.String(length=40), nullable=True),
|
||||
sa.Column("capabilities_json", sa.Text(), nullable=True),
|
||||
sa.Column("tally_connected", sa.Boolean(), nullable=False, server_default=sa.false()),
|
||||
sa.Column("tally_company_count", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("tally_companies_json", sa.Text(), nullable=True),
|
||||
sa.Column("status", sa.String(length=30), nullable=False, server_default="online"),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False, server_default=sa.true()),
|
||||
sa.Column("first_seen_at_utc", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("last_seen_at_utc", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("last_seen_ip", sa.String(length=80), nullable=True),
|
||||
sa.UniqueConstraint("storage_node_id", "agent_instance_id", name="uq_erp_workstation_agent_instance"),
|
||||
)
|
||||
for name, cols in [
|
||||
("ix_erp_workstation_agents_tenant_id", ["tenant_id"]), ("ix_erp_workstation_agents_branch_id", ["branch_id"]),
|
||||
("ix_erp_workstation_agents_storage_node_id", ["storage_node_id"]), ("ix_erp_workstation_agents_agent_instance_id", ["agent_instance_id"]),
|
||||
("ix_erp_workstation_agents_machine_fingerprint", ["machine_fingerprint"]), ("ix_erp_workstation_agents_agent_version", ["agent_version"]),
|
||||
("ix_erp_workstation_agents_tally_connected", ["tally_connected"]), ("ix_erp_workstation_agents_status", ["status"]),
|
||||
("ix_erp_workstation_agents_is_active", ["is_active"]), ("ix_erp_workstation_agents_last_seen_at_utc", ["last_seen_at_utc"]),
|
||||
]:
|
||||
op.create_index(name, "erp_workstation_agents", cols)
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table("erp_workstation_agents")
|
||||
Reference in New Issue
Block a user