Skip to content

Multi-tenancy#159

Merged
nhoening merged 19 commits intomainfrom
issue-158-Multi-tenancy
Aug 27, 2021
Merged

Multi-tenancy#159
nhoening merged 19 commits intomainfrom
issue-158-Multi-tenancy

Conversation

@create-issue-branch
Copy link
Copy Markdown
Contributor

@create-issue-branch create-issue-branch bot commented Aug 11, 2021

closes #158

  • Adds an account table and links users and generic assets to it.
  • adds CLI tasks to add/delete accounts
  • many small items coming from this change, e.g. in the UI

Upgrading the database

Verify that the current revision is b6d49ed7cceb or higher before checking out this branch.

The upgrade should be straightforward:

flexmeasures db upgrade

This will:

  • Make sure each user has an account, creating new accounts based on their email address domain.
  • drop generic_asset.owner_id associations (and move them to generic_asset.account_id, using the accounts from step 1). This will be backed up locally, should you want to db downgrade later.

Note:

You can add custom user-account relationships, e.g.:

flexmeasures db upgrade +1 -x '{"1": "Seita", "3": "CustomerA", "30": "CustomerB"}'  

This would associate users 1, 3 and 30 to accounts with the names "Seita", "CustomerA" and "CustomerB", respectively, creating these accounts on the go.

@nhoening
Copy link
Copy Markdown
Contributor

To be discussed: Can sensors be orphans? I.e. when we delete a GenericAsset, should assorted sensors be deleted automatically? For now, I found code that suggests so and followed through.

@nhoening nhoening marked this pull request as ready for review August 17, 2021 14:19
@nhoening nhoening requested a review from Flix6x August 17, 2021 14:19
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Mostly I just request some documentation, and a short Marshmallow validator for account_id. I also found one or two potential small issues.

Concerning the cascading deletion of sensors and their data, rather than keeping around orphaned data, the way you implemented it here is in line with my preference. That said, I'd recommend being more explicit about the effects of deleting an account.

@nhoening nhoening force-pushed the issue-158-Multi-tenancy branch from c1ef6ea to b95811f Compare August 26, 2021 11:03
@nhoening
Copy link
Copy Markdown
Contributor

I re-based this PR on main (should make it easier to view changes) and fixed a few small things.

@nhoening nhoening requested a review from Flix6x August 26, 2021 15:29
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Congratulations on this milestone achievement!

@Flix6x Flix6x added this to the 0.6.0 milestone Aug 27, 2021
@nhoening nhoening merged commit 247c747 into main Aug 27, 2021
@Flix6x Flix6x deleted the issue-158-Multi-tenancy branch March 1, 2022 00:15
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.

Multi-tenancy

2 participants