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, 'sqlalchemy.Column', 'Column', (['Integer'], {'primary_key': '(True)', 'nullable': '(False)', 'index': '(True)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (11, 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (12, 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (13, 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (14, 'sqlalchemy.Column', 'Column', (['Float'], {'default': '(0.0)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (15, 'sqlalchemy.Column', 'Column', (['String'], {}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (18, 'sqlalchemy.orm.relationship', 'relationship', (['"""User"""'], {'back_populates': '"""posts"""'}), False, 'from sqlalchemy.orm import relationship\n'), (24, 'sqlalchemy.Column', 'Column', (['Integer'], {'primary_key': '(True)', 'nullable': '(False)', 'index': '(True)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (25, 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (26, 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)', 'unique': '(True)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (27, 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (28, 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (30, 'sqlalchemy.orm.relationship', 'relationship', (['"""Post"""'], {'back_populates': '"""creator"""'}), False, 'from sqlalchemy.orm import relationship\n'), (36, 'sqlalchemy.Column', 'Column', (['Integer'], {'primary_key': '(True)', 'nullable': '(False)', 'index': '(True)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (37, 'sqlalchemy.Column', 'Column', (['Integer'], {'nullable': '(False)'}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), (16, 'sqlalchemy.ForeignKey', 'ForeignKey', (['"""users.id"""'], {}), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n')]