Skip to content

Commit

Permalink
Add 'system' provider
Browse files Browse the repository at this point in the history
Add 'system' provider because nulls are treated as distinct values in database
  • Loading branch information
amvanbaren committed Nov 11, 2024
1 parent c123517 commit 1a0609f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ public void applicationStarted(ApplicationStartedEvent event) {
@Transactional
public UserData createExtensionControlUser() {
var userName = "ExtensionControlUser";
var user = repositories.findUserByLoginName(null, userName);
var user = repositories.findUserByLoginName("system", userName);
if(user == null) {
user = new UserData();
user.setProvider("system");
user.setLoginName(userName);
entityManager.persist(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public FixTargetPlatformsService(RepositoryService repositories, EntityManager e
@Transactional
public UserData getUser() {
var userName = "FixTargetPlatformMigration";
var user = repositories.findUserByLoginName(null, userName);
var user = repositories.findUserByLoginName("system", userName);
if(user == null) {
user = new UserData();
user.setProvider("system");
user.setLoginName(userName);
entityManager.persist(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,21 @@ public List<ExtensionVersion> getExtensionTargetVersions(String namespaceName, S

@Transactional
public UserData createMirrorUser() {
var user = repositories.findUserByLoginName(null, userName);
if(user == null) {
user = new UserData();
user.setLoginName(userName);
entityManager.persist(user);
var user = repositories.findUserByLoginName("system", userName);
if(user != null) {
return user;
}

user = repositories.findUserByLoginName(null, userName);
if(user != null) {
user.setProvider("system");
return user;
}

user = new UserData();
user.setProvider("system");
user.setLoginName(userName);
entityManager.persist(user);
return user;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE user_data SET provider = 'system' WHERE login_name IN ('ExtensionControlUser', 'FixTargetPlatformMigration');

0 comments on commit 1a0609f

Please sign in to comment.