Dateien
Hetzner-Backup/migrations/completed/002_remove_old_hardware_columns.sql
2025-07-03 20:38:33 +00:00

38 Zeilen
1.5 KiB
SQL

-- Remove old hardware columns after migration to new names
-- This should only be run after all clients have been updated!
-- 1. Drop old columns from sessions table
ALTER TABLE sessions DROP COLUMN IF EXISTS hardware_id;
-- 2. Drop old columns from device_registrations table
ALTER TABLE device_registrations DROP COLUMN IF EXISTS hardware_id;
-- 3. Drop old columns from license_tokens table
ALTER TABLE license_tokens DROP COLUMN IF EXISTS hardware_id;
-- 4. Drop old columns from license_heartbeats table (partitioned)
ALTER TABLE license_heartbeats DROP COLUMN IF EXISTS hardware_id;
-- 5. Drop old columns from activation_events table
ALTER TABLE activation_events
DROP COLUMN IF EXISTS hardware_id,
DROP COLUMN IF EXISTS previous_hardware_id;
-- 6. Drop old columns from active_sessions table
ALTER TABLE active_sessions DROP COLUMN IF EXISTS hardware_id;
-- 7. Drop old columns from license_sessions table
ALTER TABLE license_sessions DROP COLUMN IF EXISTS hardware_id;
-- 8. Drop old columns from session_history table
ALTER TABLE session_history DROP COLUMN IF EXISTS hardware_id;
-- Drop old indexes that referenced hardware_id
DROP INDEX IF EXISTS idx_device_hardware;
DROP INDEX IF EXISTS idx_hardware;
DROP INDEX IF EXISTS idx_heartbeat_hardware_time;
DROP INDEX IF EXISTS idx_license_sessions_license_hardware;
-- Note: The activations table in the license server database
-- still uses machine_id and hardware_hash columns.
-- Those are handled separately in the license server.