mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 01:58:07 +00:00
Fix FLEXIAPI-172 Fix drop_aliases_table migration when there is more than one alias
This commit is contained in:
parent
4f79ddca2b
commit
905c440fde
1 changed files with 4 additions and 5 deletions
|
|
@ -5,8 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
|
|||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
return new class () extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
|
|
@ -14,7 +13,7 @@ return new class extends Migration
|
|||
});
|
||||
|
||||
DB::table('accounts')->update([
|
||||
'phone' => DB::raw('(select alias from aliases where aliases.account_id = accounts.id)')
|
||||
'phone' => DB::raw('(select alias from (select * from aliases where id in (select min(id) from aliases group by account_id)) as a where a.account_id = accounts.id)')
|
||||
]);
|
||||
|
||||
Schema::dropIfExists('aliases');
|
||||
|
|
@ -39,9 +38,9 @@ return new class extends Migration
|
|||
->insertUsing(
|
||||
['account_id','alias', 'domain'],
|
||||
DB::table('accounts')
|
||||
->select('id','phone','domain')
|
||||
->select('id', 'phone', 'domain')
|
||||
->whereNotNull('phone')
|
||||
);
|
||||
);
|
||||
|
||||
Schema::table('accounts', function (Blueprint $table) {
|
||||
$table->dropColumn('phone');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue