|
3 | 3 | namespace ProcessMaker\Console\Commands; |
4 | 4 |
|
5 | 5 | use Illuminate\Console\Command; |
| 6 | +use Illuminate\Encryption\Encrypter; |
6 | 7 | use Illuminate\Support\Env; |
7 | 8 | use Illuminate\Support\Facades\Artisan; |
| 9 | +use Illuminate\Support\Facades\Crypt; |
8 | 10 | use Illuminate\Support\Facades\DB; |
9 | 11 | use Illuminate\Support\Facades\File; |
10 | 12 | use ProcessMaker\Multitenancy\Tenant; |
@@ -54,19 +56,22 @@ public function handle() |
54 | 56 | return; |
55 | 57 | } |
56 | 58 |
|
| 59 | + $key = 'base64:' . base64_encode( |
| 60 | + Encrypter::generateKey(config('app.cipher')) |
| 61 | + ); |
| 62 | + $key = Crypt::encryptString($key); |
| 63 | + |
57 | 64 | // insert into the tenants table |
58 | | - $tenant = Tenant::updateOrCreate([ |
| 65 | + $tenant = Tenant::create([ |
59 | 66 | 'domain' => $domain, |
60 | | - ], [ |
61 | 67 | 'name' => $this->option('name'), |
62 | 68 | 'database' => $this->option('database'), |
63 | 69 | 'username' => $this->option('username', null), |
64 | 70 | 'password' => $this->option('password', null), |
65 | | - 'config' => ['app.url' => $this->option('url')], |
| 71 | + 'config' => ['app.url' => $this->option('url'), 'app.key' => $key], |
66 | 72 | ]); |
67 | 73 |
|
68 | 74 | // Setup storage |
69 | | - |
70 | 75 | $tenantStoragePath = base_path('storage/tenant_' . $tenant->id); |
71 | 76 | $needsStorage = true; |
72 | 77 |
|
@@ -112,20 +117,18 @@ public function handle() |
112 | 117 | } |
113 | 118 |
|
114 | 119 | // Setup database |
115 | | - |
116 | | - $tenantDbExists = DB::select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '{$this->option('database')}'"); |
| 120 | + // DB::select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '{$this->option('database')}'"); |
| 121 | + DB::statement("CREATE DATABASE `{$this->option('database')}`"); |
117 | 122 |
|
118 | 123 | // Create the database |
119 | | - if (!$tenantDbExists) { |
120 | | - DB::statement("CREATE DATABASE `{$this->option('database')}`"); |
121 | | - $this->tenantArtisan('migrate --seed --force', $tenant->id); |
| 124 | + // SKIPPING - migrate/upgrade should be done on its own |
| 125 | + // if (!$tenantDbExists) { |
| 126 | + // DB::statement("CREATE DATABASE `{$this->option('database')}`"); |
| 127 | + // $this->tenantArtisan('migrate --seed --force', $tenant->id); |
122 | 128 |
|
123 | | - // Add passport keys |
124 | | - $this->tenantArtisan('passport:keys', $tenant->id); |
125 | | - |
126 | | - // Call the upgrade commands |
127 | | - $this->tenantArtisan('upgrade', $tenant->id); |
128 | | - } |
| 129 | + // // Call the upgrade commands |
| 130 | + // $this->tenantArtisan('upgrade', $tenant->id); |
| 131 | + // } |
129 | 132 |
|
130 | 133 | // Crate the config cache subfolder |
131 | 134 | // |
|
0 commit comments