/* Replace with your SQL commands */
UPDATE members m
    JOIN account_states s ON m.state_id = s.id
SET m.state_legacy = s.name;

ALTER TABLE members DROP FOREIGN KEY fk_members_state_id,
    DROP INDEX idx_members_state_id,
    DROP COLUMN state_id;

ALTER TABLE members
    RENAME COLUMN state_legacy TO state;
    
DROP TABLE IF EXISTS member_state_history;
DROP TABLE IF EXISTS account_states;