Create a user branch for every account

Make sure that for every account a user branch exists that has an
initial empty commit with the registration date as commit time. The
commit timestamp of the first commit on a user branch will be used as
registration timestamp when accounts are stored in NoteDb.

When an account is created create the user branch with an initial
empty commit that has the registration date as commit time.

For existing accounts add a schema migration that:

- creates the user branch with an initial empty commit that has the
  registration date as commit time if the user branch doesn't exist yet
- rewrites the user branch if it already exists and inserts an initial
  empty commit with the registration date as commit time (if such a
  commit doesn't exist yet).

Change-Id: I81491a253350a43f094fdfcb32298efde0cb086a
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-04-06 15:09:38 +02:00
parent a2b6bd9648
commit c9c54da9e1
9 changed files with 441 additions and 34 deletions

View File

@@ -69,7 +69,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
private final VersionedAuthorizedKeys.Accessor authorizedKeys;
private final SshKeyCache sshKeyCache;
private final AccountCache accountCache;
private final AccountsUpdate accountsUpdate;
private final AccountsUpdate.User accountsUpdate;
private final AccountIndexer indexer;
private final AccountByEmailCache byEmailCache;
private final AccountLoader.Factory infoLoader;
@@ -87,7 +87,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
VersionedAuthorizedKeys.Accessor authorizedKeys,
SshKeyCache sshKeyCache,
AccountCache accountCache,
AccountsUpdate accountsUpdate,
AccountsUpdate.User accountsUpdate,
AccountIndexer indexer,
AccountByEmailCache byEmailCache,
AccountLoader.Factory infoLoader,
@@ -175,7 +175,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
Account a = new Account(id, TimeUtil.nowTs());
a.setFullName(input.name);
a.setPreferredEmail(input.email);
accountsUpdate.insert(db, a);
accountsUpdate.create().insert(db, a);
for (AccountGroup.Id groupId : groups) {
AccountGroupMember m = new AccountGroupMember(new AccountGroupMember.Key(id, groupId));