feat: Add DNS management resources and importer
- Implemented DomainCollection, DomainDetailResource, DomainNSCollection, DomainNSResource, and DomainResource for handling DNS domain and record data. - Created VpsServiceCollection and VpsServiceResource for VPS service management. - Added DnsManagerNS and DnsManagerUser models to represent DNS records and user associations. - Developed AdminZoneDnsSqlImporter for importing DNS data from SQL dumps, including customer and DNS domain records. - Added migration scripts to update the customers table with new fields and sync foreign key references for DNS tables. - Created a migration preview document outlining the mapping and schema changes for the admin zone DNS import.
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Imports\AdminZoneDnsSqlImporter;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ImportAdminZoneDnsSql extends Command
|
||||
{
|
||||
protected $signature = 'admin-zonedns:import
|
||||
{path? : Path to the admin_zonedns SQL dump}
|
||||
{--preview : Parse and report only, without writing to DB}
|
||||
{--customers-only : Import only tbl.users into customers}
|
||||
{--dns-only : Import only DNS tables and customer-domain links}';
|
||||
|
||||
protected $description = 'Import admin_zonedns SQL dump into portal customers and DNS tables';
|
||||
|
||||
public function handle(AdminZoneDnsSqlImporter $importer): int
|
||||
{
|
||||
$path = $this->argument('path') ?: base_path('admin_zonedns (1).sql');
|
||||
$preview = (bool) $this->option('preview');
|
||||
$customersOnly = (bool) $this->option('customers-only');
|
||||
$dnsOnly = (bool) $this->option('dns-only');
|
||||
|
||||
if ($customersOnly && $dnsOnly) {
|
||||
$this->error('Use either --customers-only or --dns-only, not both.');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
$summary = $importer->import(
|
||||
path: $path,
|
||||
preview: $preview,
|
||||
importCustomers: ! $dnsOnly,
|
||||
importDns: ! $customersOnly,
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->error($e->getMessage());
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$mode = $preview ? 'PREVIEW' : 'IMPORTED';
|
||||
$this->info("{$mode} from: {$path}");
|
||||
|
||||
$this->table(
|
||||
['Section', 'Created', 'Updated', 'Restored', 'Skipped', 'Source rows'],
|
||||
[
|
||||
[
|
||||
'customers',
|
||||
$summary['customers']['created'],
|
||||
$summary['customers']['updated'],
|
||||
$summary['customers']['restored'],
|
||||
$summary['customers']['skipped'],
|
||||
$summary['source']['users'],
|
||||
],
|
||||
[
|
||||
'dns_domains',
|
||||
$summary['dns_domains']['created'],
|
||||
$summary['dns_domains']['updated'],
|
||||
'-',
|
||||
$summary['dns_domains']['skipped'],
|
||||
$summary['source']['dns_manager_domain'],
|
||||
],
|
||||
[
|
||||
'dns_records',
|
||||
$summary['dns_records']['created'],
|
||||
$summary['dns_records']['updated'],
|
||||
'-',
|
||||
$summary['dns_records']['skipped'],
|
||||
$summary['source']['dns_manager_ns'],
|
||||
],
|
||||
[
|
||||
'dns_links',
|
||||
$summary['dns_links']['created'],
|
||||
$summary['dns_links']['updated'],
|
||||
'-',
|
||||
$summary['dns_links']['skipped'],
|
||||
$summary['source']['dns_domain_user'],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user