relationship
class OrderTicket(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True, nullable=False) ticket_id = db.Column(db.Integer, db.ForeignKey('ticket.id', ondelete='CASCADE'), primary_key=True, nullable=False) ticket = db.relationship('Ticket', back_populates='order_ticket') user_id = db.Column(db.String(36), db.ForeignKey('user.id', ondelete='CASCADE'), nullable=False) user = db..
2023. 8. 28.
[sql, sqlalchemy] 연결된 두 테이블 cascade 설정하기 - 2 (uselist 설정)
지난 글에서 문제점이 있었다. class Announcement(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(50), nullable=False) content = db.Column(db.Text, nullable=True) class AnnouncementUrl(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) announcement_id = db.Column(db.Integer, db.ForeignKey('announcement.id', ondelete='CASCADE'), n..
2023. 8. 10.