@@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
$app = require dirname(__DIR__).'/bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$db = Illuminate\Support\Facades\DB::connection();
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
$db = DB::connection();
|
||||
$report = $db->transaction(function () use ($db) {
|
||||
$db->statement('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY');
|
||||
|
||||
return [
|
||||
'generated_at' => date(DATE_ATOM),
|
||||
'target' => $db->selectOne('select current_database() as database, inet_server_port() as port'),
|
||||
@@ -20,12 +24,14 @@ $report = $db->transaction(function () use ($db) {
|
||||
'opportunity_projects' => $db->table('opportunity_projects')->get(),
|
||||
'opportunities' => $db->table('opportunities')->get(),
|
||||
'profiles' => $db->table('opportunity_profiles')->get(),
|
||||
'locations' => $db->table('geo_locations')->get(['id','name','location_type','parent_id','source_system','external_id','data_classification','deleted_at']),
|
||||
'geometries' => $db->table('geo_geometries')->select(['id','geo_location_id','geometry_type','source_system','external_id','data_classification','deleted_at'])->selectRaw('ST_AsGeoJSON(geom) as geometry')->get(),
|
||||
'locations' => $db->table('geo_locations')->get(['id', 'name', 'location_type', 'parent_id', 'source_system', 'external_id', 'data_classification', 'deleted_at']),
|
||||
'geometries' => $db->table('geo_geometries')->select(['id', 'geo_location_id', 'geometry_type', 'source_system', 'external_id', 'data_classification', 'deleted_at'])->selectRaw('ST_AsGeoJSON(geom) as geometry')->get(),
|
||||
];
|
||||
});
|
||||
$directory = storage_path('app/private/anchor-project-reconciliation');
|
||||
if (! is_dir($directory)) mkdir($directory, 0700, true);
|
||||
if (! is_dir($directory)) {
|
||||
mkdir($directory, 0700, true);
|
||||
}
|
||||
$file = $directory.'/inventory-'.date('Ymd-His').'.json';
|
||||
file_put_contents($file, json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
|
||||
echo $file.PHP_EOL;
|
||||
|
||||
Reference in New Issue
Block a user