Upgrading Metabase from v0.46.6.4 to v0.53.8 took too much time

Hey there!
I upgraded from Metabase v0.46.6.4 to v0.53.8 by launching Metabase. jar.
But the log has been stuck at the position shown in the picture for more than ten hours.
I checked the executing SQL and the program got stuck in the following SQL text:
I have checked the current data volume of these tables:

metabase_table: 46265
permissions_group: 1370
data_permissions: 1356679

May I ask if there is a way to solve this problem without spending too much time?

INSERT INTO data_permissions (group_id, perm_type, db_id, schema_name, table_id, perm_value)
SELECT
    pg.id AS group_id,
    'perms/data-access' AS perm_type,
    mt.db_id,
    mt.schema AS schema_name,
    mt.id AS table_id,
    'no-self-service' AS perm_value
FROM permissions_group pg
CROSS JOIN metabase_table mt
WHERE NOT EXISTS (
    SELECT 1
    FROM data_permissions dp
    WHERE dp.group_id = pg.id
      AND dp.db_id = mt.db_id
      AND (dp.table_id = mt.id
           OR dp.table_id IS NULL)
      AND dp.perm_type = 'perms/data-access'
)
AND pg.name != 'Administrators';

Yeah I remember that migration you're actually stuck in version 50 cause that migration migrates permissions to a new DB structure:

I remember some users flagging this and experiencing around 15 hrs for the migration to finish. What RAM and CPU does your Application Database have (maybe for this specific case you can scale those up just for the migration)? After this future migrations were done in a more divide and concur approach but unfortunately there is nothing to do here except to wait.

You can see migrations that run via teh databasechangelog table