mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
fix migration error
This commit is contained in:
@ -41,6 +41,7 @@ class UpdateCustomerIdInAllTables extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($user->addresses()->exists()) {
|
||||||
$user->addresses->map(function ($address) use ($newCustomer) {
|
$user->addresses->map(function ($address) use ($newCustomer) {
|
||||||
if ($address) {
|
if ($address) {
|
||||||
$address->customer_id = $newCustomer->id;
|
$address->customer_id = $newCustomer->id;
|
||||||
@ -48,7 +49,9 @@ class UpdateCustomerIdInAllTables extends Migration
|
|||||||
$address->save();
|
$address->save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->expenses()->exists()) {
|
||||||
$user->expenses->map(function ($expense) use ($newCustomer) {
|
$user->expenses->map(function ($expense) use ($newCustomer) {
|
||||||
if ($expense) {
|
if ($expense) {
|
||||||
$expense->customer_id = $newCustomer->id;
|
$expense->customer_id = $newCustomer->id;
|
||||||
@ -56,7 +59,9 @@ class UpdateCustomerIdInAllTables extends Migration
|
|||||||
$expense->save();
|
$expense->save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->estimates()->exists()) {
|
||||||
$user->estimates->map(function ($estimate) use ($newCustomer) {
|
$user->estimates->map(function ($estimate) use ($newCustomer) {
|
||||||
if ($estimate) {
|
if ($estimate) {
|
||||||
$estimate->customer_id = $newCustomer->id;
|
$estimate->customer_id = $newCustomer->id;
|
||||||
@ -64,7 +69,9 @@ class UpdateCustomerIdInAllTables extends Migration
|
|||||||
$estimate->save();
|
$estimate->save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->invoices()->exists()) {
|
||||||
$user->invoices->map(function ($invoice) use ($newCustomer) {
|
$user->invoices->map(function ($invoice) use ($newCustomer) {
|
||||||
if ($invoice) {
|
if ($invoice) {
|
||||||
$invoice->customer_id = $newCustomer->id;
|
$invoice->customer_id = $newCustomer->id;
|
||||||
@ -72,7 +79,9 @@ class UpdateCustomerIdInAllTables extends Migration
|
|||||||
$invoice->save();
|
$invoice->save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->payments()->exists()) {
|
||||||
$user->payments->map(function ($payment) use ($newCustomer) {
|
$user->payments->map(function ($payment) use ($newCustomer) {
|
||||||
if ($payment) {
|
if ($payment) {
|
||||||
$payment->customer_id = $newCustomer->id;
|
$payment->customer_id = $newCustomer->id;
|
||||||
@ -81,6 +90,7 @@ class UpdateCustomerIdInAllTables extends Migration
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Schema::table('estimates', function (Blueprint $table) {
|
Schema::table('estimates', function (Blueprint $table) {
|
||||||
if (config('database.default') !== 'sqlite') {
|
if (config('database.default') !== 'sqlite') {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class AddOwnerIdToCompaniesTable extends Migration
|
|||||||
|
|
||||||
$companies = Company::all();
|
$companies = Company::all();
|
||||||
|
|
||||||
if ($companies) {
|
if ($companies && $user) {
|
||||||
foreach ($companies as $company) {
|
foreach ($companies as $company) {
|
||||||
$company->owner_id = $user->id;
|
$company->owner_id = $user->id;
|
||||||
$company->slug = Str::slug($company->name);
|
$company->slug = Str::slug($company->name);
|
||||||
|
|||||||
Reference in New Issue
Block a user