diff --git a/app/models/file.py b/app/models/file.py new file mode 100644 index 0000000..6687928 --- /dev/null +++ b/app/models/file.py @@ -0,0 +1,19 @@ +# File model +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import relationship + +Base = declarative_base() + +class File(Base): + __tablename__ = 'files' + id = Column(Integer, primary_key=True) + name = Column(String) + content = Column(String) + user_id = Column(Integer, ForeignKey('users.id')) + user = relationship('User', backref='files') + + def __init__(self, name, content, user): + self.name = name + self.content = content + self.user = user