-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AC 1427]Add New Organisation Properties Update DB Objects and create migration #2980
[AC 1427]Add New Organisation Properties Update DB Objects and create migration #2980
Conversation
@@ -81,6 +86,11 @@ public OrganizationResponseModel(Organization organization, string obj = "organi | |||
public bool UseCustomPermissions { get; set; } | |||
public bool SelfHost { get; set; } | |||
public bool HasPublicAndPrivateKeys { get; set; } | |||
public bool UsePasswordManager { get; set; } = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This default initialization value seems to be ignored since it's already initialized by the constructor. What's the reason for including it here? Perhaps just to document the intended default value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, what do you think @cyprain-okeke?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cy's response (@cyprain-okeke looks like you accidentally edited my comment instead, so I'm just posting this separately for you)
I agree with you but The = true part of the declaration assigns a default value to the property. It means that if no value is explicitly assigned to UsePasswordManager, it will default to true.
So, in this case, the property UsePasswordManager will default to true if no value is explicitly assigned to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but it's a non-nullable bool
, so it will always have a value assigned in the constructor, and this default assignment will never be used. (Please correct me if I'm wrong!)
public int? SmSeats { get; set; } | ||
public int? SmServiceAccounts { get; set; } | ||
public int? MaxAutoscaleSmSeats { get; set; } = null; | ||
public int? MaxAutoscaleSmServiceAccounts { get; set; } = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifying null
as the default value is redundant here given the datatype is already an int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value is 0
, not null
: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/default-values
I agree with your comment above though that these default assignments are probably not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null has been removed. I agree with Conner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry, the default value is indeed null
for a nullable type. d'oh.
@cyprain-okeke This change is not showing, please double check that you've removed these assignments and pushed to remote.
…bjects_and_create_migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration file is missing sp_refreshsqlmodule
for the dependant stored procedures.
Other than that is looks good to me but left some questions/suggestions.
util/Migrator/DbScripts/2023-05-27_00_OrganizationSecretsManagerBillingColumns.sql
Show resolved
Hide resolved
util/MySqlMigrations/Migrations/20230530114306_AddSecretsManagerBillingFieldToOrganization.cs
Outdated
Show resolved
Hide resolved
.../PostgresMigrations/Migrations/20230530114251_AddSecretsManagerBillingFieldToOrganization.cs
Outdated
Show resolved
Hide resolved
util/SqliteMigrations/Migrations/20230530114320_AddSecretsManagerBillingFieldToOrganization.cs
Outdated
Show resolved
Hide resolved
…eate_migration' of https://github.com/bitwarden/server into ac-1427/add_new_org_properties_update_db_objects_and_create_migration
…bjects_and_create_migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewed EF migrations on the assumption that @cturnbull-bitwarden and @r-tome already reviewed them (thank you both!). Just a few questions/comments.
This seems safe to merge into master
because we're not using any of these values yet, but we do need to decide whether we're using a feature branch or feature flagging. I've raised that in #team-eng-adminconsole
and we should make a decision there before merging. (This PR itself would not be feature flagged, but if we're going to use a feature branch then it should go there.)
public int? SmSeats { get; set; } | ||
public int? SmServiceAccounts { get; set; } | ||
public int? MaxAutoscaleSmSeats { get; set; } = null; | ||
public int? MaxAutoscaleSmServiceAccounts { get; set; } = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value is 0
, not null
: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/default-values
I agree with your comment above though that these default assignments are probably not necessary.
@@ -81,6 +86,11 @@ public OrganizationResponseModel(Organization organization, string obj = "organi | |||
public bool UseCustomPermissions { get; set; } | |||
public bool SelfHost { get; set; } | |||
public bool HasPublicAndPrivateKeys { get; set; } | |||
public bool UsePasswordManager { get; set; } = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, what do you think @cyprain-okeke?
util/Migrator/DbScripts/2023-05-27_00_OrganizationSecretsManagerBillingColumns.sql
Show resolved
Hide resolved
…bjects_and_create_migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I believe the only outstanding changes are those requested by @cturnbull-bitwarden in OrganizationResponseModel.cs
, you said you agreed but I can't see the updated code.
PS. As discussed in the team channel, it looks like we'll be feature flagging this initiative rather than using a feature branch. Because these are database updates that do not affect any existing functionality, it's fine to target master
.
@cyprain-okeke The changes suggested by @cturnbull-bitwarden have been done. Thanks for reminding me of that.
…eate_migration' of https://github.com/bitwarden/server into ac-1427/add_new_org_properties_update_db_objects_and_create_migration
…bjects_and_create_migration
…eate_migration' of https://github.com/bitwarden/server into ac-1427/add_new_org_properties_update_db_objects_and_create_migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm as well, thanks Cy!
…bjects_and_create_migration
Type of change
Objective
In preparation for the organization's secret manager billing feature, the
UsePasswordManager
,SmSeats
,SmServiceAccounts
,MaxAutoscaleSmSeats
andMaxAutoscaleSmSeats
columns need to be added to theOrganization
table, relevant db objects need to be updated, and migrations need to be created for the different database providers.Code changes
Organization
entity class with theUsePasswordManager
,SmSeats
,SmServiceAccounts
,MaxAutoscaleSmSeats
andMaxAutoscaleSmSeats
properties, updated the organization table, stored procedures and functions SQL scripts, and created migrations for SQL server and EF core (SQLite, MySQL and Postgres).Organization
response models to include the new columns and updated ef core queries to return the new columns.Before you submit
dotnet format --verify-no-changes
) (required)