Backfill new column with values based on foreign key
You can use a correlated subquery to update all rows at once.
To determine the ordinal value, just count how many other rows for the same user come before this one when you sort them:

UPDATE devices
SET seat_ordinal = (SELECT COUNT(*)
                    FROM devices AS d2
                    WHERE d2.user_id  = devices.user_id
                      AND d2.id      &lt;= devices.id);    -- some arbitrary sort order