odapi/database/models.py

210 lines
7.8 KiB
Python
Raw Normal View History

2020-09-17 17:35:11 +02:00
from secrets import token_hex
2020-09-03 19:34:51 +02:00
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String, Text, text
from sqlalchemy.sql import func
2020-09-03 19:34:51 +02:00
from database import Base
class Users(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "users"
id = Column(Integer, primary_key=True, autoincrement=True)
social_id = Column(Text)
2020-09-10 23:59:06 +02:00
type = Column(Integer, nullable=True)
2020-09-17 17:35:11 +02:00
full_name = Column(String(255), index=True, nullable=False)
2020-09-10 23:59:06 +02:00
email = Column(String(255), index=True, unique=True, nullable=False)
password = Column(String(255))
gender = Column(Integer)
2020-09-17 17:35:11 +02:00
mobile = Column(String(255), unique=True, nullable=False)
user_image = Column(String(255))
2020-09-03 19:34:51 +02:00
city_id = Column(Integer, ForeignKey("cities.id"))
user_type = Column(Integer)
otp = Column(String(255))
otp_valid_time = Column(DateTime)
2020-09-17 17:35:11 +02:00
access_key = Column(Text, unique=True, default=token_hex)
lang_type = Column(Integer)
2020-09-17 17:35:11 +02:00
badge = Column(Integer, server_default=text("0"))
2020-07-03 02:03:02 +02:00
status = Column(Integer, server_default=text("0"))
admin_status = Column(Integer, server_default=text("0"))
device_id = Column(Text)
device_type = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-09-17 17:35:11 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class Cities(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "cities"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-10 23:59:06 +02:00
name = Column(String(255), nullable=False)
image = Column(String(255))
status = Column(Enum("1", "0"))
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class Games(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "games"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-10 23:59:06 +02:00
name = Column(String(255), nullable=False)
image = Column(String(255))
date_time = Column(DateTime)
2020-09-10 23:59:06 +02:00
price = Column(String(100), nullable=False)
description = Column(Text)
2020-09-03 19:34:51 +02:00
user_id = Column(Integer, ForeignKey("users.id"))
gender = Column(Enum("1", "2", "3"))
2020-09-03 19:34:51 +02:00
city_id = Column(Integer, ForeignKey("cities.id"))
venue_id = Column(Integer, ForeignKey("venues.id"))
sports_id = Column(Integer, ForeignKey("sports.id"))
no_of_player = Column(Integer)
min_player = Column(Integer)
already_player = Column(Integer)
no_of_already_player = Column(Integer)
payment_mode = Column(Integer)
card_id = Column(Integer)
2020-07-03 02:03:02 +02:00
status = Column(Integer, server_default=text("1"))
game_status = Column(Integer, server_default=text("0"))
cancel_status = Column(Integer)
cancel_date = Column(DateTime)
2020-07-03 02:03:02 +02:00
noti_status = Column(Integer, server_default=text("0"))
conduct_status = Column(Integer, server_default=text("1"))
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class Payments(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "payments"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
user_id = Column(Integer, ForeignKey("users.id"))
game_id = Column(Integer, ForeignKey("games.id"))
amount = Column(Integer)
token = Column(String(100))
charge_id = Column(String(200))
transfer_id = Column(String(200))
transaction_id = Column(String(200))
account_no = Column(String(200))
description = Column(Text)
pay_mode = Column(Integer)
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class PlayerAvailabilities(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "player_availabilities"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
game_id = Column(Integer, ForeignKey("games.id"))
player_id = Column(Integer, ForeignKey("users.id"))
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class PlayerCancelGames(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "player_cancel_games"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
player_id = Column(Integer, ForeignKey("users.id"))
game_id = Column(Integer, ForeignKey("games.id"))
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class PurchaseGames(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "purchase_games"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
game_id = Column(Integer, ForeignKey("games.id"))
user_id = Column(Integer, ForeignKey("users.id"))
pay_mode = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class Sports(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "sports"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-10 23:59:06 +02:00
name = Column(String(255), nullable=False)
spanish_name = Column(String(100), nullable=False)
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class Teams(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "teams"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
user_id = Column(Integer, ForeignKey("users_id"))
team_id = Column(Enum("1", "2"))
2020-09-03 19:34:51 +02:00
game_id = Column(Integer, ForeignKey("games_id"))
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class UserRatings(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "user_ratings"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
game_id = Column(Integer, ForeignKey("games_id"))
user_id = Column(Integer, ForeignKey("users_id"))
player_id = Column(Integer, ForeignKey("users_id"))
2020-09-10 23:59:06 +02:00
rating = Column(String(100), nullable=False)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
user_type = Column(Integer)
class VenueImages(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "venue_images"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
venue_id = Column(Integer, ForeignKey("venues_id"))
user_id = Column(Integer, ForeignKey("users_id"))
image = Column(String(255))
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-04 20:15:55 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class Venues(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "venues"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-03 19:34:51 +02:00
user_id = Column(Integer, ForeignKey("users_id"))
2020-09-10 23:59:06 +02:00
address = Column(Text, nullable=False)
latitude = Column(String(100))
longitude = Column(String(100))
2020-09-10 23:59:06 +02:00
name = Column(String(100), nullable=False)
2020-09-03 19:34:51 +02:00
sports_id = Column(Integer, ForeignKey("sports_id"))
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-22 23:58:56 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class ViewNews(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "view_news"
id = Column(Integer, primary_key=True, autoincrement=True)
news_id = Column(Integer)
2020-09-03 19:34:51 +02:00
user_id = Column(Integer, ForeignKey("users_id"))
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-04 20:15:55 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())
class WebBookings(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "web_bookings"
id = Column(Integer, primary_key=True, autoincrement=True)
2020-09-10 23:59:06 +02:00
name = Column(String(255), nullable=False)
email = Column(String(255), nullable=False)
contact = Column(String(100), nullable=False)
message = Column(Text, nullable=False)
game = Column(String(255), nullable=False)
city = Column(String(100), nullable=False)
created = Column(DateTime, nullable=False, server_default=func.now())
2020-07-04 20:15:55 +02:00
updated = Column(DateTime, nullable=True, onupdate=func.now())