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

constraint that there is only one prefix set to active #210

Open
sjib opened this issue Apr 17, 2024 · 7 comments
Open

constraint that there is only one prefix set to active #210

sjib opened this issue Apr 17, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@sjib
Copy link
Contributor

sjib commented Apr 17, 2024

To not corrupt generate_oid we should add a constraint or conditiion that checks whether more than one prefix is set to active. I don't know yet how to formulate that - but maybe the best way is that you have to set all to inactive before you can set another one to active.

@sjib sjib added the enhancement New feature or request label Apr 17, 2024
@sjib
Copy link
Contributor Author

sjib commented Apr 17, 2024

Ideas for implementation:

create unique index on tww_sys.oid_prefixes(active) 
where active = true;

https://stackoverflow.com/questions/28166915/postgresql-constraint-only-one-row-can-have-flag-set

20240417_oid_prefixes_unique_index_acitve

@sjib
Copy link
Contributor Author

sjib commented Apr 17, 2024

@cymed @ponceta What do you think? Any other ideas or thoughts?

@cymed
Copy link
Contributor

cymed commented Apr 17, 2024

I deem it smarter to keep it as is and allow multitenancy in a second step

@sjib
Copy link
Contributor Author

sjib commented Apr 17, 2024

When would you want to have several prefixes active at the same time?
May be we need to discuss and collect some use cases here first and give this to the user group.

@cymed
Copy link
Contributor

cymed commented Apr 17, 2024

When you want to allow multitenancy (i.e. to store all cadastres on one database), you need to alter the system with which you choose the prefix

@ponceta
Copy link
Member

ponceta commented Apr 18, 2024

As I remember from a past discussion, we would want an option on the plugin to select and change the oidprefix on the fly. It would actually be possible but for one user only, as soon as multiple users would edit data simultaneously it would fail since the setting is yet in the database.

  • What happens on the new 2020 model?

If provider A defines dataset for infrastructure maintener B.
Entities will be tagged with default fk_provider and fk_dataowner data and prefixed with the dataowner oid or provider oid?

  • What are oid prefixes for if we constraint our users to set fk_provider and fk_dataowner?

@cymed
Copy link
Contributor

cymed commented Apr 18, 2024

  1. We do not constraint our users to set fk_provider and fk_dataowner, we only give them an option to set their own default on the db side.
  2. I would strongly discourage to define the default dataowner and provider in the plugin. When working with multiple databases, it is common to copy-paste the qgis project and alter the pg service name. It is safer to define the default per database or (once we support multitenancy) to define it per tenant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants