Add latest changes
Dieser Commit ist enthalten in:
27
migrations/completed/003_migrate_activations_table.sql
Normale Datei
27
migrations/completed/003_migrate_activations_table.sql
Normale Datei
@@ -0,0 +1,27 @@
|
||||
-- Migrate activations table to new column names
|
||||
|
||||
-- Add new columns
|
||||
ALTER TABLE activations
|
||||
ADD COLUMN IF NOT EXISTS machine_name VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS hardware_fingerprint VARCHAR(255);
|
||||
|
||||
-- Copy data from old to new columns
|
||||
UPDATE activations
|
||||
SET machine_name = COALESCE(device_name, machine_id),
|
||||
hardware_fingerprint = hardware_hash
|
||||
WHERE machine_name IS NULL OR hardware_fingerprint IS NULL;
|
||||
|
||||
-- Make new columns NOT NULL after data is copied
|
||||
ALTER TABLE activations
|
||||
ALTER COLUMN machine_name SET NOT NULL,
|
||||
ALTER COLUMN hardware_fingerprint SET NOT NULL;
|
||||
|
||||
-- Drop old columns
|
||||
ALTER TABLE activations
|
||||
DROP COLUMN IF EXISTS machine_id,
|
||||
DROP COLUMN IF EXISTS hardware_hash,
|
||||
DROP COLUMN IF EXISTS device_name;
|
||||
|
||||
-- Update any indexes
|
||||
CREATE INDEX IF NOT EXISTS idx_activations_machine_name ON activations(machine_name);
|
||||
CREATE INDEX IF NOT EXISTS idx_activations_hardware_fingerprint ON activations(hardware_fingerprint);
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren