from sqlalchemy import Column, Integer, String, ForeignKey, Float
from sqlalchemy.orm import relationship

from .database import Base


class Post(Base):
    __tablename__ = "posts"

    id = Column(Integer, primary_key=True, nullable=False, index=True)
    full_name = Column(String, nullable=False)
    last_place = Column(String, nullable=False)
    description = Column(String, nullable=False)
    percentage = Column(Float, default=0.0)
    image = Column(String)
    owner_id = Column(Integer, ForeignKey("users.id"))

    creator = relationship("User", back_populates="posts")


class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, nullable=False, index=True)
    name = Column(String, nullable=False)
    email = Column(String, nullable=False, unique=True)
    password = Column(String, nullable=False)
    phone_number = Column(String, nullable=False)

    posts = relationship("Post", back_populates="creator")


class Code(Base):
    __tablename__ = "codes"

    id = Column(Integer, primary_key=True, nullable=False, index=True)
    code = Column(Integer, nullable=False)

[((10, 9, 10, 70), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((11, 16, 11, 46), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((12, 17, 12, 47), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((13, 18, 13, 48), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((14, 17, 14, 43), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((15, 12, 15, 26), 'sqlalchemy.Column', 'Column', ({(15, 19, 15, 25): 'String'}, {}), '(String)', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((18, 14, 18, 58), 'sqlalchemy.orm.relationship', 'relationship', (), '', False, 'from sqlalchemy.orm import relationship\n'), ((24, 9, 24, 70), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((25, 11, 25, 41), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((26, 12, 26, 55), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((27, 15, 27, 45), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((28, 19, 28, 49), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((30, 12, 30, 58), 'sqlalchemy.orm.relationship', 'relationship', (), '', False, 'from sqlalchemy.orm import relationship\n'), ((36, 9, 36, 70), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((37, 11, 37, 42), 'sqlalchemy.Column', 'Column', (), '', False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((16, 31, 16, 53), 'sqlalchemy.ForeignKey', 'ForeignKey', ({(16, 42, 16, 52): '"""users.id"""'}, {}), "('users.id')", False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n')]