bmc_hub/migrations/236_mobile_recorder_provisioning.sql
Christian 9ca562745a feat(subscriptions): enhance subscription update logic to allow direct edits for drafts and add new endpoint for manual invoice processing
feat(ticket): update email integration to use new priority constants for ticket classification

feat(procurement): add procurement overview page with dynamic data loading and display

test(subscriptions): add tests for billing calendar to ensure correct invoice dates

feat(reminder): implement automated task lists with user-defined rules for reminders

feat(migrations): create tables for managing delefiber product prices and mobile recorder provisioning history

test(mobile_recorder): add tests for provisioning mobile recorders to ensure correct asset creation and updates
2026-09-07 19:05:58 +02:00

33 lines
1.7 KiB
SQL

-- Apple BMC Mobile Recorder provisioning support.
-- The serial number remains the physical-device identity. Device-specific values
-- (UDID, ECID, IMEI, Wi-Fi MAC and iOS) live in hardware_specs for extensibility.
ALTER TABLE hardware_assets
ADD COLUMN IF NOT EXISTS recorder_number INTEGER,
ADD COLUMN IF NOT EXISTS provisioned_at TIMESTAMP,
ADD COLUMN IF NOT EXISTS last_provisioned_at TIMESTAMP;
ALTER TABLE hardware_assets DROP CONSTRAINT IF EXISTS hardware_assets_asset_type_check;
ALTER TABLE hardware_assets ADD CONSTRAINT hardware_assets_asset_type_check
CHECK (asset_type IN ('pc', 'laptop', 'printer', 'skærm', 'telefon', 'server', 'netværk', 'andet', 'mobile_recorder'));
ALTER TABLE hardware_assets DROP CONSTRAINT IF EXISTS hardware_assets_status_check;
ALTER TABLE hardware_assets ADD CONSTRAINT hardware_assets_status_check
CHECK (status IN ('active', 'ready', 'faulty_reported', 'in_repair', 'replaced', 'retired', 'unsupported'));
CREATE INDEX IF NOT EXISTS idx_hardware_mobile_recorder_number
ON hardware_assets(recorder_number)
WHERE deleted_at IS NULL AND recorder_number IS NOT NULL;
CREATE TABLE IF NOT EXISTS hardware_provisioning_history (
id BIGSERIAL PRIMARY KEY,
hardware_id INTEGER NOT NULL REFERENCES hardware_assets(id) ON DELETE CASCADE,
action VARCHAR(16) NOT NULL CHECK (action IN ('created', 'updated')),
source VARCHAR(80) NOT NULL DEFAULT 'apple_configurator',
payload JSONB NOT NULL DEFAULT '{}'::jsonb,
provisioned_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_hardware_provisioning_history_asset
ON hardware_provisioning_history(hardware_id, provisioned_at DESC);