--liquibase formatted sql

--changeset kelvin:add 2fi user and grant all permissions (if not)

INSERT INTO user (username, password, name, fullname) SELECT '2fi', '$2a$10$65S7/AhKn8MldlYmvFN5JOfr1yaULwFNDIhTskLTuUCKgbbs8sFAi', '2fi', '2fi'
WHERE NOT EXISTS (SELECT 1 FROM (SELECT username, password, name, fullname FROM user WHERE username = '2fi') temp );

SELECT id INTO @su FROM user WHERE username = '2fi';

INSERT INTO user_authority (userId, authId)
	WITH RECURSIVE numbers AS (
		SELECT 1 AS n
		UNION ALL
		SELECT n + 1 FROM numbers WHERE n < 30
	) SELECT @su, n FROM numbers
ON DUPLICATE KEY UPDATE userId = userId, authId = authId; 