CREATE TABLE IF NOT EXISTS tester_users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL, -- Storing plain text for simplicity as per likely requirement, but hash recommended
    device_id VARCHAR(255),
    last_active DATETIME,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS tester_logs (
    id INT AUTO_INCREMENT PRIMARY KEY,
    tester_id INT NOT NULL,
    app_id INT NOT NULL,
    action VARCHAR(50) NOT NULL, -- Install, Open, Review
    details TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (tester_id) REFERENCES tester_users (id) ON DELETE CASCADE
);

-- Insert default 12 testers
INSERT IGNORE INTO
    tester_users (username, password)
VALUES ('Tester1', '123456'),
    ('Tester2', '123456'),
    ('Tester3', '123456'),
    ('Tester4', '123456'),
    ('Tester5', '123456'),
    ('Tester6', '123456'),
    ('Tester7', '123456'),
    ('Tester8', '123456'),
    ('Tester9', '123456'),
    ('Tester10', '123456'),
    ('Tester11', '123456'),
    ('Tester12', '123456');