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)

[((192, 253), 'sqlalchemy.Column', 'Column', (['Integer'], {'primary_key': '(True)', 'nullable': '(False)', 'index': '(True)'}), '(Integer, primary_key=True, nullable=False, index=True)\n', (198, 253), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((270, 300), 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), '(String, nullable=False)\n', (276, 300), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((318, 348), 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), '(String, nullable=False)\n', (324, 348), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((367, 397), 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), '(String, nullable=False)\n', (373, 397), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((415, 441), 'sqlalchemy.Column', 'Column', (['Float'], {'default': '(0.0)'}), '(Float, default=0.0)\n', (421, 441), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((454, 468), 'sqlalchemy.Column', 'Column', (['String'], {}), '(String)\n', (460, 468), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((539, 583), 'sqlalchemy.orm.relationship', 'relationship', (['"""User"""'], {'back_populates': '"""posts"""'}), "('User', back_populates='posts')\n", (551, 583), False, 'from sqlalchemy.orm import relationship\n'), ((642, 703), 'sqlalchemy.Column', 'Column', (['Integer'], {'primary_key': '(True)', 'nullable': '(False)', 'index': '(True)'}), '(Integer, primary_key=True, nullable=False, index=True)\n', (648, 703), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((715, 745), 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), '(String, nullable=False)\n', (721, 745), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((758, 801), 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)', 'unique': '(True)'}), '(String, nullable=False, unique=True)\n', (764, 801), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((817, 847), 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), '(String, nullable=False)\n', (823, 847), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((867, 897), 'sqlalchemy.Column', 'Column', (['String'], {'nullable': '(False)'}), '(String, nullable=False)\n', (873, 897), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((911, 957), 'sqlalchemy.orm.relationship', 'relationship', (['"""Post"""'], {'back_populates': '"""creator"""'}), "('Post', back_populates='creator')\n", (923, 957), False, 'from sqlalchemy.orm import relationship\n'), ((1016, 1077), 'sqlalchemy.Column', 'Column', (['Integer'], {'primary_key': '(True)', 'nullable': '(False)', 'index': '(True)'}), '(Integer, primary_key=True, nullable=False, index=True)\n', (1022, 1077), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((1089, 1120), 'sqlalchemy.Column', 'Column', (['Integer'], {'nullable': '(False)'}), '(Integer, nullable=False)\n', (1095, 1120), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n'), ((500, 522), 'sqlalchemy.ForeignKey', 'ForeignKey', (['"""users.id"""'], {}), "('users.id')\n", (510, 522), False, 'from sqlalchemy import Column, Integer, String, ForeignKey, Float\n')]