Add latest changes
Dieser Commit ist enthalten in:
@@ -570,6 +570,37 @@ BEGIN
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- Migration: Add max_concurrent_sessions column to licenses if it doesn't exist
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'licenses' AND column_name = 'max_concurrent_sessions') THEN
|
||||
ALTER TABLE licenses ADD COLUMN max_concurrent_sessions INTEGER DEFAULT 1 CHECK (max_concurrent_sessions >= 1);
|
||||
-- Set initial value to same as max_devices for existing licenses
|
||||
UPDATE licenses SET max_concurrent_sessions = max_devices WHERE max_concurrent_sessions IS NULL;
|
||||
-- Add constraint to ensure concurrent sessions don't exceed device limit
|
||||
ALTER TABLE licenses ADD CONSTRAINT check_concurrent_sessions CHECK (max_concurrent_sessions <= max_devices);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- Migration: Remove UNIQUE constraint on license_sessions.license_id to allow multiple concurrent sessions
|
||||
DO $$
|
||||
BEGIN
|
||||
-- Check if the unique constraint exists and drop it
|
||||
IF EXISTS (SELECT 1 FROM pg_constraint
|
||||
WHERE conname = 'license_sessions_license_id_key'
|
||||
AND conrelid = 'license_sessions'::regclass) THEN
|
||||
ALTER TABLE license_sessions DROP CONSTRAINT license_sessions_license_id_key;
|
||||
END IF;
|
||||
|
||||
-- Add a compound index for better performance on concurrent session queries
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_indexes
|
||||
WHERE tablename = 'license_sessions'
|
||||
AND indexname = 'idx_license_sessions_license_hardware') THEN
|
||||
CREATE INDEX idx_license_sessions_license_hardware ON license_sessions(license_id, hardware_id);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
|
||||
-- Migration: Add device_type column to device_registrations table
|
||||
DO $$
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren