Predestination had already been written..
Our Lord, Exalted be He, predestined all determinations. He knew the measures and times of all things before creating them and then brought them into existence according to His foreknowledge.
{...That is the determination of the All-Mighty, the All-Knowing.}
[Surat Yasīn: 38]
Allah Almighty decreed the destinies of His creatures thousands of years before He actually created them. The Prophet (may Allah’s peace and blessings be upon him) is authentically reported to have said:
“Allah decreed the destinies of the creatures fifty thousand years before He created the heavens and the earth, when His Throne was upon the water.”
[Narrated by Muslim]
Hence, this is part of faith. When Jibrīl (Gabriel) (peace be upon him) asked the Messenger of Allah (may Allah’s peace and blessings be upon him) about faith, he replied:
“To believe in Allah, His angels, His books, His messengers, the Last Day, and to believe in destiny, the pleasant and unpleasant aspects thereof.”
[Narrated by Al-Bukhāri and Muslim -this is the wording of Muslim -]