Skip to content
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

Add database options like TablePrefixSeparator, Schema, IdentityColumnType, and DocumentTable #12683

Merged
merged 48 commits into from
Jan 4, 2023

Conversation

MikeAlhayek
Copy link
Member

@MikeAlhayek MikeAlhayek commented Oct 21, 2022

This PR addresses the concerns #12657

Here is a summary of the changes

Both TableNameConvention and TablePrefixSeparator were removed from YesSqlOptions.
The following properties were added to the ShellSettings of each tenant

  • TablePrefixSeparator when this value does not exists we assume _ however, if empty string is found, we use no prefix for the tables.
  • Schema this was added to allow you to provide a specific schema to use.
  • IdentityColumnSize when this value is empty or invalid, we assume Int32
  • DocumentTable when this value is empty we assume "Document"

If adding a new tenant failed due to missing Encrypt=false or TrustServerCertificate=True, we add the error to the log file to provide the admin more about the issue. Address issue #12679 and #12653.

@jtkech in the remove tenant code, you can use the new ITableNameConventionFactory to create an instance of ITableNameConvention with something like this

var options = DatabaseTableOptions.Create(shellSettingsBeingRemoved);

var tableNameConvention = _tableNameConventionFactory.Create(options);

ITableNameConventionFactory is a service that we register so you can inject it in ShellDbTablesInfo to create the tableNameConvention.

Added the following fields were added to Add/Edit tenant in the tenant UI and also to the setup screen when the database isn't configured.

image

image

@hishamco
Copy link
Member

Can we merge #12363 before? One more thing I think we discussed before that the above changes could after 1.5, because the introduced changes might need testing before they got merge. All we know that this time is critical because we are so close to release 1.5 but I will leave this to @sebastienros to decide

I might review this after I finish some of my pending PRs ;)

@MikeAlhayek
Copy link
Member Author

@hishamco please hold off of merging PR #12363 since there are few things changes here. As you can see the DbValidation was changed quite bit. I think this should be merged before 1.5. In 1.5 we added tablePrefixSeparator which was causing issues so this PR fixes these issue.

@Skrypt
Copy link
Contributor

Skrypt commented Oct 21, 2022

This is getting late for 1.5

@hishamco
Copy link
Member

FYI @MikeAlhayek I'm not pushing to merge my PR ;) it's jsut refactoring notRhing else, but this PR has introduce new things that might have consequences. I'm totally agree with @Skrypt that this PR is too late, I appreciate your efforts but we are in a stable state to release 1.5, so adding anything else it will require integration, verification and validation

@jtkech
Copy link
Member

jtkech commented Oct 21, 2022

@MikeAlhayek Okay, looks now much better ;)

@MikeAlhayek
Copy link
Member Author

@jtkech glad you like the change :) If you see no further changes, please approve the PR. Thought on merging this in 1.5 to avoid having to deal with an obsolete YesSqlOptions later?

@jtkech
Copy link
Member

jtkech commented Oct 21, 2022

I will try it this night

Copy link
Member

@jtkech jtkech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a last comment, so we can select some new options while creating/editing a tenant, then not on the setup form. So how can we define them for the Default tenant on a fresh setup, if not intended that's okay knowing that it is still possible from the regular Configuration.

Yes, some issues quite easy to fix, the main concern being that we can't persist through Shell Settings an empty string, but I prefer this approach even if there are remaining things to fix.

Otherwise LGTM.

@MikeAlhayek
Copy link
Member Author

MikeAlhayek commented Oct 22, 2022

@jtkech I made all the changes including adding the same value to the API and to the workflow activities.

UPDATED

I also added the database properties to the Setup screen so even when the Default site is being setup, we can provide/change the options

@jtkech
Copy link
Member

jtkech commented Oct 22, 2022

Okay cool, I will look at it asap.

@jtkech
Copy link
Member

jtkech commented Oct 23, 2022

Only did a quick review but LGTM.

Yes for now the NULL workaround seems okay when binding from a create/edit/setup form, because we know that the separator field is there and that a value is provided even if it is binded to null.

But in other places we may need to respect the existing usage of APIs, already defined WFs and existing AutoSetup configs, meaning if nothing is changed the _ separator is still intended to be used.

Yes, this is the only remaining thing I still have to think about.

@MikeAlhayek
Copy link
Member Author

@jtkech I made the last suggested changes. Let me know if you see any last items here. Please check the update I made to the workflow and the api controller to make sure I did what you suggested.

@jtkech
Copy link
Member

jtkech commented Oct 24, 2022

@MikeAlhayek

I did a review, sorry if too long but one thing imply two others (exponential), maybe some parts could be managed in separate PR(s). One main point would be to manage new database fields like the existing ones as much as possible, which would be easier if we don't support empty separators, or if all binding sources (behaving dfferently) should provide the same dedicated value for this purpose.

@jtkech
Copy link
Member

jtkech commented Jan 2, 2023

Okay, just saw the last meeting, looks like what I did is in sync with what was suggested.

Copy link
Member Author

@MikeAlhayek MikeAlhayek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtkech

I tested out all the new changes you added to this PR. All looks good to me and it also falls inline with all the feedback we had during the meeting. I have some minor suggestions here.

src/OrchardCore.Cms.Web/appsettings.json Outdated Show resolved Hide resolved
src/docs/reference/core/Data/README.md Outdated Show resolved Hide resolved
@jtkech
Copy link
Member

jtkech commented Jan 3, 2023

@MikeAlhayek

Okay done but wait, maybe some very last little simplifications

@MikeAlhayek
Copy link
Member Author

@jtkech thanks. We'll check it tomorrow and ensure there is no more feedback from @sebastienros tomorrow before we merge it.

Copy link
Member

@hishamco hishamco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be I'm late to review this, but I suffered last two weeks from a damaged hard disk in my previous laptops. I just write down some comments that might be consider

@@ -0,0 +1,49 @@
@model EditTenantViewModel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why the partials relying on EditTenantViewModel, it would be nice to use the UI components in both Create & Edit views

@jtkech
Copy link
Member

jtkech commented Jan 3, 2023

Please wait before merging, need to check the last review / commits, at least fix unit tests.

@MikeAlhayek
Copy link
Member Author

@jtkech no worries. Either approve or merge it when you are done making changes to it. Thank you

@jtkech
Copy link
Member

jtkech commented Jan 4, 2023

I already approved it a while ago ;) I'm merging it

@jtkech jtkech merged commit 960e630 into OrchardCMS:main Jan 4, 2023
@MikeAlhayek MikeAlhayek deleted the YesSqlOptionsEnhancements branch January 5, 2023 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants