You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7KB

  1. # @name: models.py
  2. # @version: 0.1
  3. # @creation_date: 2021-10-20
  4. # @license: The MIT License <https://opensource.org/licenses/MIT>
  5. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  6. # @purpose: Database models for tables in the database
  7. # @acknowledgements:
  8. # https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login
  9. from flask_login import UserMixin
  10. from . import db
  11. from datetime import datetime
  12. # table for users
  13. class User(UserMixin, db.Model):
  14. __tablename__ = 'User'
  15. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  16. email = db.Column(db.String(100), unique=True)
  17. password = db.Column(db.String(100))
  18. name = db.Column(db.String(1000))
  19. # table for resources
  20. class Resource(db.Model):
  21. __tablename__ = 'Resource'
  22. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  23. created = db.Column(db.DateTime, default=datetime.utcnow)
  24. type = db.Column(db.Text)
  25. name = db.Column(db.Text)
  26. description = db.Column(db.Text)
  27. projectUrl = db.Column(db.Text)
  28. repositoryUrl = db.Column(db.Text)
  29. expertiseToUse = db.Column(db.Text)
  30. expertiseToHost = db.Column(db.Text)
  31. dependencies = db.Column(db.Text)
  32. ingestFormats = db.Column(db.Text)
  33. outputFormats = db.Column(db.Text)
  34. status = db.Column(db.Text)
  35. publisherUrl = db.Column(db.Text)
  36. zoteroUrl = db.Column(db.Text)
  37. # table for relationships
  38. class Relationships(db.Model):
  39. __tablename__ = 'Relationships'
  40. id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
  41. first_resource_id = db.Column(db.Integer)
  42. second_resource_id = db.Column(db.Integer)