<?php

namespace App\OldDataMigrations;

class SystemConfigMigration extends BaseOldDataMigration
{
    public function priority(): int
    {
        return 11;
    }

    public function migrate(): array
    {
        $results = [];

        $results['system_configurations'] = $this->migrateTable('system_configurations');
        $results['push_subscriptions'] = $this->migrateTable('push_subscriptions', function ($row) {
            if (isset($row['user_id']) && $row['user_id'] !== null) {
                $row['subscribable_type'] = 'App\\Models\\User';
                $row['subscribable_id'] = $row['user_id'];
            }
            unset($row['user_id']);

            return $row;
        });
        $results['homepage_configurations'] = $this->migrateTable('homepage_configurations');
        $results['notifications'] = $this->migrateTable('notifications');

        return $results;
    }
}
