Exemplo n.º 1
0
class Compiler(db.Model):
    compiler_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    compiler_name = db.Column(db.String(20), unique=True)
    major_version = db.Column(db.Integer, nullable=False)
    minor_version = db.Column(db.Integer, nullable=False)
    db.UniqueConstraint("major_version", "minor_version", "compiler_name", name="compiler_exists")
    computer = db.relationship('Computer', backref='compiler_name')
Exemplo n.º 2
0
class Ucollection(db.Model):
    article_id = db.Column(db.Integer, nullable=False)
    uid = db.Column(db.Integer, nullable=False)
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    time = db.Column(db.DateTime, nullable=False, default=datetime.now)

    __table_args__ = (db.UniqueConstraint('uid', 'article_id'), )
Exemplo n.º 3
0
class Favor(db.Model):

    __tablename__ = 'favor'

    nid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_info_id = db.Column(db.Integer, db.ForeignKey('userinfo.nid'))
    news_id = db.Column(db.Integer, db.ForeignKey('news.nid'))
    # ctime = db.Column(db.TIMESTAMP)
    ctime = db.Column(db.DateTime,
                      nullable=False,
                      default=datetime.utcnow,
                      onupdate=datetime.utcnow)

    __table_args__ = (db.UniqueConstraint('user_info_id',
                                          'news_id',
                                          name='uix_uid_nid'), )
Exemplo n.º 4
0
class Workload(db.Model):
    """Data model for workloads."""

    __tablename__ = 'workloads'
    
    id = db.Column(
        db.Integer,
        primary_key=True
    )

    workload = db.Column(
        db.String(253), #https://unofficial-kubernetes.readthedocs.io/en/latest/concepts/overview/working-with-objects/names/#:~:text=Names%20are%20used%20to%20refer,resources%20have%20more%20specific%20restrictions.
        index=True,
        nullable=False
    )
    workload_type = db.Column(
        db.String(253),
        index=True,
        nullable=False
    )
    namespace = db.Column(
        db.String(253), #https://unofficial-kubernetes.readthedocs.io/en/latest/concepts/overview/working-with-objects/names/#:~:text=By%20convention%2C%20the%20names%20of,precise%20syntax%20rules%20for%20names.
        index=True,
        nullable=False
    )
    created = db.Column(
        db.DateTime,
        index=True,
        nullable=False,
        default=datetime.utcnow
    )
    
    __table_args__ = (db.UniqueConstraint('workload', 'workload_type', 'namespace', name='workload_namespace'),
                        )
    

    def __repr__(self):
        return '<{} {}.{}>'.format(self.workload_type, self.workload, self.namespace)
Exemplo n.º 5
0
from __init__ import db, app
from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash
from flask_security import Security, SQLAlchemyUserDatastore, RoleMixin
from forms import RegisterUser, LoginForm
from datetime import datetime

roles_user = db.Table('user_roles',db.Model.metadata,
    db.Column('user_id',db.Integer, db.ForeignKey('user.id')),
    db.Column('role_id',db.Integer, db.ForeignKey('role.id')),
    db.UniqueConstraint('user_id','role_id', name = 'UC_user_id_role_id')
) 

book_user = db.Table('book_users',db.Model.metadata,
    db.Column('user_id',db.Integer, db.ForeignKey('user.id')),
    db.Column('book_id',db.Integer, db.ForeignKey('book.id')),
    db.UniqueConstraint('user_id','book_id',name='UC_user_id_book_id')
)


class User(db.Model, UserMixin):
    id = db.Column(db.Integer,primary_key=True)
    first_name = db.Column(db.String(200),index = True)
    last_name = db.Column(db.String(200),index = True)
    username = db.Column(db.String(200), index = True)
    email = db.Column(db.String(200), index = True)
    password = db.Column(db.String(200),index = True)
    year = db.Column(db.Date)
    active = db.Column(db.Boolean())
    roles = db.relationship('Role',secondary = roles_user, backref = 'users')
    book = db.relationship('Book', secondary = book_user, lazy = 'select')