mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 00:11:35 +02:00
Multi-db support
This commit is contained in:
parent
95cbbc2dc9
commit
068666a58b
@ -106,6 +106,7 @@ class InitLookup extends Command
|
||||
LookupUser::create([
|
||||
'lookup_account_id' => $lookupAccount->id,
|
||||
'email' => $user['email'],
|
||||
'user_id' => $user['user_id'],
|
||||
]);
|
||||
}
|
||||
foreach ($account['contacts'] as $contact) {
|
||||
@ -154,24 +155,34 @@ class InitLookup extends Command
|
||||
'tokens' => [],
|
||||
];
|
||||
|
||||
$users = DB::table('users')->whereAccountId($accountId)->orderBy('id')->get(['email']);
|
||||
$users = DB::table('users')->whereAccountId($accountId)->orderBy('id')->get(['email', 'id']);
|
||||
foreach ($users as $user) {
|
||||
$data['users'][] = ['email' => $user->email];
|
||||
$data['users'][] = [
|
||||
'email' => $user->email,
|
||||
'user_id' => $user->id,
|
||||
];
|
||||
}
|
||||
|
||||
$contacts = DB::table('contacts')->whereAccountId($accountId)->orderBy('id')->get(['contact_key']);
|
||||
foreach ($contacts as $contact) {
|
||||
$data['contacts'][] = ['contact_key' => $contact->contact_key];
|
||||
$data['contacts'][] = [
|
||||
'contact_key' => $contact->contact_key,
|
||||
];
|
||||
}
|
||||
|
||||
$invitations = DB::table('invitations')->whereAccountId($accountId)->orderBy('id')->get(['invitation_key', 'message_id']);
|
||||
foreach ($invitations as $invitation) {
|
||||
$data['invitations'][] = ['invitation_key' => $invitation->invitation_key, 'message_id' => $invitation->message_id];
|
||||
$data['invitations'][] = [
|
||||
'invitation_key' => $invitation->invitation_key,
|
||||
'message_id' => $invitation->message_id,
|
||||
];
|
||||
}
|
||||
|
||||
$tokens = DB::table('account_tokens')->whereAccountId($accountId)->orderBy('id')->get(['token']);
|
||||
foreach ($tokens as $token) {
|
||||
$data['tokens'][] = ['token' => $token->token];
|
||||
$data['tokens'][] = [
|
||||
'token' => $token->token,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -15,6 +15,7 @@ class LookupUser extends LookupModel
|
||||
protected $fillable = [
|
||||
'lookup_account_id',
|
||||
'email',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -415,12 +415,9 @@ class User extends Authenticatable
|
||||
|
||||
User::creating(function ($user)
|
||||
{
|
||||
if (! $user->registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
LookupUser::createNew($user->account->account_key, [
|
||||
'email' => $user->email,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
});
|
||||
|
||||
|
@ -26,6 +26,11 @@ class AddMultipleDatabaseSupport extends Migration
|
||||
|
||||
Schema::table('lookup_users', function ($table) {
|
||||
$table->string('email')->change()->unique();
|
||||
$table->unsignedInteger('user_id')->index();
|
||||
});
|
||||
|
||||
Schema::table('lookup_users', function ($table) {
|
||||
$table->unique(['lookup_account_id', 'user_id']);
|
||||
});
|
||||
|
||||
Schema::table('lookup_contacts', function ($table) {
|
||||
|
Loading…
Reference in New Issue
Block a user