-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathplayground.php
More file actions
96 lines (80 loc) · 2.25 KB
/
Copy pathplayground.php
File metadata and controls
96 lines (80 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Playground for Migration Library Tests
*
* A place to test and debug the Migration Library stuff
*/
require_once __DIR__.'/vendor/autoload.php';
use Dotenv\Dotenv;
use Utopia\Migration\Destinations\Appwrite as AppwriteDestination;
use Utopia\Migration\Destinations\Local;
use Utopia\Migration\Resource;
use Utopia\Migration\Sources\Appwrite;
use Utopia\Migration\Sources\Firebase;
use Utopia\Migration\Sources\NHost;
use Utopia\Migration\Sources\Supabase;
use Utopia\Migration\Transfer;
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
/**
* Initialise All Source Adapters
*/
$sourceAppwrite = new Appwrite(
$_ENV['SOURCE_APPWRITE_TEST_PROJECT'],
$_ENV['SOURCE_APPWRITE_TEST_ENDPOINT'],
$_ENV['SOURCE_APPWRITE_TEST_KEY']
);
$firebase = json_decode($_ENV['FIREBASE_TEST_ACCOUNT'], true);
$sourceFirebase = new Firebase(
$firebase,
$firebase['project_id'] ?? '',
);
$sourceNHost = new NHost(
$_ENV['NHOST_TEST_SUBDOMAIN'] ?? '',
$_ENV['NHOST_TEST_REGION'] ?? '',
$_ENV['NHOST_TEST_SECRET'] ?? '',
$_ENV['NHOST_TEST_DATABASE'] ?? '',
$_ENV['NHOST_TEST_USERNAME'] ?? '',
$_ENV['NHOST_TEST_PASSWORD'] ?? '',
);
$sourceSupabase = new Supabase(
$_ENV['SUPABASE_TEST_ENDPOINT'] ?? '',
$_ENV['SUPABASE_TEST_KEY'] ?? '',
$_ENV['SUPABASE_TEST_HOST'] ?? '',
$_ENV['SUPABASE_TEST_DATABASE'] ?? '',
$_ENV['SUPABASE_TEST_USERNAME'] ?? '',
$_ENV['SUPABASE_TEST_PASSWORD'] ?? '',
);
/**
* Initialise All Destination Adapters
*/
$destinationAppwrite = new AppwriteDestination(
$_ENV['DESTINATION_APPWRITE_TEST_PROJECT'],
$_ENV['DESTINATION_APPWRITE_TEST_ENDPOINT'],
$_ENV['DESTINATION_APPWRITE_TEST_KEY']
);
$destinationLocal = new Local(__DIR__.'/localBackup/');
/**
* Initialise Transfer Class
*/
$transfer = new Transfer(
$sourceFirebase,
$destinationLocal
);
$sourceFirebase->report();
// /**
// * Run Transfer
// */
$transfer->run($sourceFirebase->getSupportedResources(),
function (array $resources) {
}
);
$report = [];
$cache = $transfer->getCache()->getAll();
// foreach ($cache as $type => $resources) {
// foreach ($resources as $resource) {
// if ($resource->getStatus() !== Resource::STATUS_ERROR) {
// continue;
// }
// }
// }