-- First, rename api_password to api_token and change its properties
ALTER TABLE users 
    CHANGE COLUMN api_password api_token VARCHAR(100) NOT NULL;

-- Update any existing records to ensure they have a default API token
UPDATE users 
SET api_token = CONCAT(api_username, '_default_token') 
WHERE api_token = '$argon2id$v=19$m=65536,t=4,p=1$[hash]' 
   OR api_token LIKE '$argon2id%';

-- For the admin user specifically
UPDATE users 
SET api_token = 'admin_default_token' 
WHERE username = 'admin'; 