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

users and users_preference tables design cleanup #776

Closed
ehuelsmann opened this issue Aug 31, 2015 · 3 comments
Closed

users and users_preference tables design cleanup #776

ehuelsmann opened this issue Aug 31, 2015 · 3 comments
Assignees
Labels
needs-cleanup needs-design type:enhancement Proposed improvement, new feature, or extension -- not a defect
Milestone

Comments

@ehuelsmann
Copy link
Member

The users table maps user names to user IDs (and to entities). The user_preference table lists the user's preferences based on the user's ID. The problem is that it does so by listing all preferences on a single row. This way, the users and user_prefence tables can be merged; another option (much more flexible) would be to list each preference on a separate row in the user_preference table.

@einhverfr
Copy link
Member

The reason I currently split them up is that the permissions are different for the two sides.

I also agree that one row per preference would be more flexible and allow for add-ons to extend this.

@ehuelsmann ehuelsmann modified the milestones: 1.6, 1.7 Dec 17, 2017
@ehuelsmann ehuelsmann added type:enhancement Proposed improvement, new feature, or extension -- not a defect and removed type:enhancement Proposed improvement, new feature, or extension -- not a defect Major Enhancement labels Dec 17, 2017
@ehuelsmann ehuelsmann modified the milestones: 1.7, 1.8 Jun 23, 2019
@ehuelsmann ehuelsmann modified the milestones: 1.8, 1.9, 1.10 May 17, 2020
@ehuelsmann ehuelsmann self-assigned this Dec 9, 2020
@ehuelsmann
Copy link
Member Author

Impact assessment:

  • Need both a table with user-specific preferences and one with global preferences; possibly with some settings/defaults/preferences being restricted to the global scope only (much like settings);
  • admin.sql has user preference functions
    • user__save_preferences() with a fixed list of preference "names"
    • user__get_preferences() which returns a fixed list of preferences (as "columns")
    • admin__save_user() instantiates user_preference record for any created users (but should not, to make the user's prefs and defaults fall back to the company-wide ones!)

ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Dec 11, 2020
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Dec 11, 2020
@ehuelsmann
Copy link
Member Author

Proposed design:

  • Pivot user preferences table from current row-based setup to 2-column based key-value setup
  • in case of explicitly requested setting: Query user settings primarily from user_preferences table, but in case of missing key, query defaults table (which returns the company-wide preference)
  • in case of generic "select all" query: Query (for now) the keys (and values) from the users_preferences table unionized with the keys and settings from the defaults table

(It'll be some later change to factor out the company settings from the company wide defaults.)

ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Dec 25, 2020
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 7, 2021
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 7, 2021
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 7, 2021
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 7, 2021
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 7, 2021
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 7, 2021
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 8, 2021
ehuelsmann added a commit to ehuelsmann/LedgerSMB that referenced this issue Mar 8, 2021
ehuelsmann added a commit that referenced this issue Mar 9, 2021
Close #776: Move from row-based to column based preference storage
ylavoie pushed a commit to ylavoie/LedgerSMB that referenced this issue Mar 10, 2021
…torage

By moving from a row to column based setup, there's (much) more flexibility
to define preferences, including allowing preferences to be defined by plugins.

Note too that this commit no longer stores the default values for the prefs in
the DDL (schema), but has moved the default values into the user_preference table,
thus allowing e.g. CoAs or other locale specific configurations to specify
default preferences with other values than the ones that were hard-coded in the
schema (as well as that they'll be able to specify more/different default
preferences).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cleanup needs-design type:enhancement Proposed improvement, new feature, or extension -- not a defect
Projects
None yet
Development

No branches or pull requests

2 participants