Fix migration check: detect unmigrated data by checking data/customers.json
The previous check (directory existence) failed on production because git pull created data/companies/ from committed config.json, causing the migration to be skipped while customer data remained in data/ root. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
api.php
12
api.php
@@ -120,18 +120,16 @@ function saveCompanyConfig(array $config): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runMigration(): void {
|
function runMigration(): void {
|
||||||
// Tarkista onko migraatio jo tehty
|
|
||||||
$companiesDir = DATA_DIR . '/companies';
|
$companiesDir = DATA_DIR . '/companies';
|
||||||
if (file_exists($companiesDir) && is_dir($companiesDir)) return;
|
|
||||||
|
|
||||||
// Tarkista onko vanha data olemassa (pre-multitenant)
|
// Tarkista onko vanha data olemassa juuressa (pre-multitenant)
|
||||||
$oldCustomers = DATA_DIR . '/customers.json';
|
$oldCustomers = DATA_DIR . '/customers.json';
|
||||||
if (!file_exists($oldCustomers)) return;
|
if (!file_exists($oldCustomers)) return; // Ei vanhaa dataa → ei migraatiota
|
||||||
|
|
||||||
// Luo yritykshakemisto
|
// Vanha data löytyy juuresta → siirretään yrityksen alle
|
||||||
mkdir($companiesDir, 0755, true);
|
if (!file_exists($companiesDir)) mkdir($companiesDir, 0755, true);
|
||||||
$cuitunetDir = $companiesDir . '/cuitunet';
|
$cuitunetDir = $companiesDir . '/cuitunet';
|
||||||
mkdir($cuitunetDir, 0755, true);
|
if (!file_exists($cuitunetDir)) mkdir($cuitunetDir, 0755, true);
|
||||||
|
|
||||||
// Luo companies.json
|
// Luo companies.json
|
||||||
$companies = [[
|
$companies = [[
|
||||||
|
|||||||
Reference in New Issue
Block a user