This Psalm is short enough to quote…
Psa 87:1 A Psalm or Song for the sons of Korah. His foundation is in the holy mountains.
Psa 87:2 The LORD loveth the gates of Zion more than all the dwellings of Jacob.
Psa 87:3 Glorious things are spoken of thee, O city of God. Selah.
Psa 87:4 I will make mention of Rahab and Babylon to them that know me: behold Philistia, and Tyre, with Ethiopia; this man was born there.
Psa 87:5 And of Zion it shall be said, This and that man was born in her: and the highest himself shall establish her.
Psa 87:6 The LORD shall count, when he writeth up the people, that this man was born there. Selah.
Psa 87:7 As well the singers as the players on instruments shall be there: all my springs are in thee.
John Gill comments on verse 6, note his reference not to the original writing of believers names in the book of life but to their numbering in the effectual call.
The Lord shall count when he writeth up the people, Not in the Lamb’s book of life; for that was written from eternity, Rev 13:8 but in the writing of the house of Israel, among the living in Jerusalem, and with his righteous ones; which is done at effectual calling, and when admitted members of Gospel churches, whereby they openly appear to be the children of God, and are taken into the list and catalogue of saints; see Eze 13:9 or in the last day, when the Lord will take the number of his people,
and cause them again to pass under the rod of him that telleth them; and will make up his jewels, complete the number of them in conversion, and collect them all together; and his counting and writing them may denote his exact knowledge of them, and his care that he lose none; but this will only concern regenerate persons; the Lord will not count nor make any account of any others, as follows:
that this man was born there; and the man that is born in Zion, even every regenerate man, will be counted and numbered by him, and declared to be his, when he makes a general survey and muster of his saints another day.
Selah. See Gill on Psa 3:2.
Rev 13:8 And all that dwell upon the earth shall worship him, whose names are not written in the book of life of the Lamb slain from the foundation of the world.
Eze 13:9 And mine hand shall be upon the prophets that see vanity, and that divine lies: they shall not be in the assembly of my people, neither shall they be written in the writing of the house of Israel, neither shall they enter into the land of Israel; and ye shall know that I am the Lord GOD.