From 6a6afdbe72c626b01245c9372c9d10be79789bb0 Mon Sep 17 00:00:00 2001 From: Rasmus Luha Date: Sun, 6 Feb 2022 13:41:11 +0200 Subject: restrucurring the stucture of the folderstruture --> structure --- Projekt/app/models.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 Projekt/app/models.py (limited to 'Projekt/app/models.py') diff --git a/Projekt/app/models.py b/Projekt/app/models.py deleted file mode 100644 index 97d1e35..0000000 --- a/Projekt/app/models.py +++ /dev/null @@ -1,31 +0,0 @@ -from sqlalchemy import Column, Integer, String, Boolean, ForeignKey -from sqlalchemy.orm import relationship -from sqlalchemy.sql.expression import text -from sqlalchemy.sql.sqltypes import TIMESTAMP -from .database import Base - -class Post(Base): - __tablename__= "posts" - - id = Column(Integer, primary_key=True, nullable=False) - title = Column(String, nullable=False) - content = Column(String, nullable=False) - published = Column(Boolean, server_default="true", nullable=False) - created_at = Column(TIMESTAMP(timezone=True), nullable=False, server_default=text('now()') ) - - owner_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False) - owner = relationship("User") #Fetcib owner_id põhjal( see foreign key) vastava Posti teinud User callsi useri - -class User(Base): - __tablename__ = "users" - - id = Column(Integer, primary_key=True, nullable=False) - email = Column(String, nullable=False, unique = True) - password = Column(String, nullable=False) - created_at = Column(TIMESTAMP(timezone=True), nullable=False, server_default=text('now()') ) - - -class Vote(Base): - __tablename__ = "votes" - user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), primary_key=True) - post_id = Column(Integer, ForeignKey("posts.id", ondelete="CASCADE"), primary_key=True) -- cgit v1.2.3