-- DEFAULT OWNER
INSERT INTO roles (tenant_id,name,is_system) VALUES
(1,'owner',1),(1,'admin',1),(1,'kasir',1)
ON DUPLICATE KEY UPDATE name=name;

INSERT INTO users (tenant_id,name,email,password_hash,is_owner,is_active)
VALUES (1,'Owner','owner@rajawali.local',
'$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',1,1)
ON DUPLICATE KEY UPDATE email=email;

INSERT INTO user_roles (user_id,role_id)
SELECT u.id,r.id FROM users u JOIN roles r ON r.name='owner' WHERE u.email='owner@rajawali.local';

INSERT INTO user_locations (user_id,location_id)
SELECT u.id,l.id FROM users u JOIN locations l WHERE u.email='owner@rajawali.local' LIMIT 1;