USE db_abos_v0.1;

CREATE TABLE IF NOT EXISTS dim_physical_assets (
    id INT AUTO_INCREMENT PRIMARY KEY,
    tenant_id INT NOT NULL,
    business_id INT NULL,
    asset_tag VARCHAR(100) NOT NULL,
    name VARCHAR(255) NOT NULL,
    category VARCHAR(100) NULL,
    status VARCHAR(50) NOT NULL DEFAULT 'Available',
    purchase_date DATE NULL,
    purchase_cost DECIMAL(15,2) NULL,
    location VARCHAR(255) NULL,
    notes TEXT NULL,
    created_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6),
    created_by INT NULL,
    updated_at TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
    updated_by INT NULL,
    is_deleted TINYINT NOT NULL DEFAULT 0,
    INDEX idx_dim_physical_assets_tenant (tenant_id),
    INDEX idx_dim_physical_assets_status (tenant_id, status),
    INDEX idx_dim_physical_assets_asset_tag (tenant_id, asset_tag)
);
