from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class VAPIDKey(db.Model): id = db.Column(db.Integer, primary_key=True) public_key = db.Column(db.String(255), nullable=False) private_key = db.Column(db.String(255), nullable=False) subscriptions = db.relationship('Subscription', backref='vapid_key', lazy=True) class Subscription(db.Model): id = db.Column(db.Integer, primary_key=True) endpoint = db.Column(db.String(500), nullable=False) p256dh = db.Column(db.String(255), nullable=False) auth = db.Column(db.String(255), nullable=False) vapid_key_id = db.Column(db.Integer, db.ForeignKey('vapid_key.id'), nullable=False)