class Many2OneModel(db.Model, SerializerMixin): __tablename__ = 'many2one_model' id = db.Column(db.Integer, primary_key=True) string = db.Column(db.String(256), default='Some string') boolean = db.Column(db.Boolean, default=True) null = db.Column(db.String) rel_id = db.Column(db.ForeignKey('many2many_model.id', ondelete='CASCADE')) rel = db.relationship('Many2manyModel', lazy='joined', uselist=False)
class TS(db.Model, SerializerMixin): __tablename__ = 'ts' id = db.Column(db.Integer, primary_key=True) reg_num = db.Column(db.String(25)) decomission_date = db.Column(db.DateTime) is_delete = db.Column(db.Boolean, default=False)
class Many2manyModel(db.Model, SerializerMixin): __tablename__ = 'many2many_model' id = db.Column(db.Integer, primary_key=True) string = db.Column(db.String(256), default='Some string for m2m') boolean = db.Column(db.Boolean, default=True) null = db.Column(db.String) rel = db.relationship(NoRelationshipModel, lazy='joined', secondary=secondary)
class Chart(db.Model, SerializerMixin): __table_name__ = 'charts' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(255), nullable=False, unique=True) legend = db.Column(db.String(255), nullable=True) date_format = db.Column(db.String(255), nullable=True) points = db.relationship('Point', order_by='Point.id', cascade='delete') created_at = db.Column(db.DateTime, default=datetime.utcnow)
class Associate(db.Model, SerializerMixin): __tablename__ = 'associates' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(255)) surname = db.Column(db.String(255)) patronymic = db.Column(db.String(255)) start_date = db.Column(db.DateTime, default=datetime.utcnow) end_date = db.Column(db.DateTime) is_delete = db.Column(db.Boolean, default=False)
class Point(db.Model, SerializerMixin): __table_name__ = 'points' id = db.Column(db.Integer, primary_key=True) chart_id = db.Column(db.Integer, db.ForeignKey('chart.id')) x_coord = db.Column(db.String(64), nullable=False) y_coord = db.Column(db.String(64), nullable=False) created_at = db.Column(db.DateTime, default=datetime.utcnow) updated_at = db.Column(db.DateTime, default=datetime.utcnow)
class NoRelationshipModel(db.Model, SerializerMixin): __tablename__ = 'no_rel_model' id = db.Column(db.Integer, primary_key=True) string = db.Column(db.String(256), default='Some string with') time_at = db.Column(db.DateTime, default=datetime.utcnow()) date_at = db.Column(db.Date, default=datetime.utcnow()) boolean = db.Column(db.Boolean, default=True) null = db.Column(db.String) nosql_field = None def _protected_method(self): return 'User defined method %s' % self.string
class TsResponsible(db.Model, SerializerMixin): __tablename__ = 'ts_resposibles' id = db.Column(db.Integer, primary_key=True) id_ts = db.Column(db.Integer, db.ForeignKey('ts.id', ondelete='CASCADE')) associate_id = db.Column( db.Integer, db.ForeignKey('associates.id', ondelete='CASCADE')) parrent_id = db.Column(db.Integer, db.ForeignKey('ts_resposibles.id', ondelete='CASCADE'), nullable=True) start_date = db.Column(db.DateTime, default=datetime.utcnow) end_date = db.Column(db.DateTime) is_delete = db.Column(db.Boolean, default=False)
from flask_builder import db from datetime import datetime from sqlalchemy_serializer import SerializerMixin class {{cookiecutter.module_name|capitalize}}(db.Model, SerializerMixin): __tablename__ = '{{cookiecutter.module_name|lower}}s' id = db.Column(db.Integer, primary_key=True) created_at = db.Column(db.DateTime, default=datetime.utcnow) updated_at = db.Column(db.DateTime, default=datetime.utcnow)
class Many2OneModel(db.Model, SerializerMixin): __tablename__ = 'many2one_model' id = db.Column(db.Integer, primary_key=True) string = db.Column(db.String(256), default='Some string') boolean = db.Column(db.Boolean, default=True) null = db.Column(db.String) rel_id = db.Column(db.ForeignKey('many2many_model.id', ondelete='CASCADE')) rel = db.relationship('Many2manyModel', lazy='joined', uselist=False) secondary = db.Table( 'secondary_table', db.Column('no_rel_id', db.Integer, db.ForeignKey('no_rel_model.id', ondelete='CASCADE'), primary_key=True), db.Column('m2m_id', db.Integer, db.ForeignKey('many2many_model.id', ondelete='CASCADE'), primary_key=True)) class Many2manyModel(db.Model, SerializerMixin): __tablename__ = 'many2many_model' id = db.Column(db.Integer, primary_key=True) string = db.Column(db.String(256), default='Some string for m2m') boolean = db.Column(db.Boolean, default=True) null = db.Column(db.String) rel = db.relationship(NoRelationshipModel, lazy='joined',