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

persistence: add tenant db #26

Merged
merged 5 commits into from Jun 16, 2017
Merged

Conversation

diegodelemos
Copy link
Member

Signed-off-by: Diego Rodriguez diego.rodriguez@cern.ch

@diegodelemos diegodelemos self-assigned this Jun 7, 2017
@diegodelemos diegodelemos added this to the Client-Server milestone Jun 8, 2017
@diegodelemos diegodelemos force-pushed the add-tenant-db branch 5 times, most recently from c61d4d1 to 12fc845 Compare June 8, 2017 13:39
# granted to it by virtue of its status as an Intergovernmental Organization or
# submit itself to any jurisdiction.

"""REANA Workflow Controller Rest API."""
Copy link
Member

Choose a reason for hiding this comment

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

It may be good to ponder renaming of api.py to restapi.py, so that we distinguish more clearly here and in other REANA packages between:

  • API = Pythonic API, CLI API
  • RESTAPI = REST API

While some REANA components won't have much of a Pythonic API, and they will be used exclusively over REST API, it may be good to have some naming consistency across all packages for ease of development across packages?

TBD @diegodelemos @hjhsalo


def create_app():
Copy link
Member

Choose a reason for hiding this comment

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

As discussed IRL, let's put factory creation into factory.py and let's leave app.py to instantiate the application out of it.

class Tenant(db.Model):
"""Tenant model."""

id_ = db.Column(db.String(36), primary_key=True)
Copy link
Member

Choose a reason for hiding this comment

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

sqlalchemy-utils has a UUIDType that we could use, see invenio-records.

"""Tenant model."""

id_ = db.Column(db.String(36), primary_key=True)
email = db.Column(db.String(120), unique=True)
Copy link
Member

Choose a reason for hiding this comment

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

Is 120 enough? Perhaps max out to 255?

from .app import db


class Tenant(db.Model):
Copy link
Member

Choose a reason for hiding this comment

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

We may want to have some user accounting information, so let's think of new columns like:

  • create_date
  • last_active_date

CC @diegodelemos @hjhsalo

Copy link
Member

Choose a reason for hiding this comment

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

(and we could even think of future Alembic DB upgrade recipes 😄 to be fully future-proof)

def default_tenant(db):
"""Create users."""
default_tenant = Tenant('00000000-0000-0000-0000-000000000000',
'default@reana.io',
Copy link
Member

Choose a reason for hiding this comment

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

info@reana.io

Diego Rodriguez added 4 commits June 16, 2017 10:27
Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
* Removes usage of default database. Uses only SQLAlchemy binds.

Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
* (closes reanahub#27).

Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
@tiborsimko
Copy link
Member

(let's ignore coveralls since this code will go away soon, see #28)

@diegodelemos diegodelemos merged commit 9e9046f into reanahub:master Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants