Create initial SQLAlchemy models for DB
This commit is contained in:
parent
a3b2ecfbbf
commit
ed16323d97
|
@ -1 +1,2 @@
|
|||
src/constants.py
|
||||
assets/db_schema.sql
|
||||
|
|
|
@ -11,6 +11,7 @@ flask = "*"
|
|||
pymysql = "*"
|
||||
flask-praetorian = "*"
|
||||
flask-sqlalchemy = "*"
|
||||
flask-migrate = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "5bee56bdc672b4d2c8c3450c852221d2dbe8b5d15840a0fafa5643c87b03ce3a"
|
||||
"sha256": "4328be3ab2dfc7cdc0c6dfc8ff03702be800ff524133228b149ca368e1d29bfe"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
|
@ -16,6 +16,12 @@
|
|||
]
|
||||
},
|
||||
"default": {
|
||||
"alembic": {
|
||||
"hashes": [
|
||||
"sha256:035ab00497217628bf5d0be82d664d8713ab13d37b630084da8e1f98facf4dbf"
|
||||
],
|
||||
"version": "==1.4.2"
|
||||
},
|
||||
"blinker": {
|
||||
"hashes": [
|
||||
"sha256:471aee25f3992bd325afa3772f1063dbdbbca947a041b8b89466dc00d606f8b6"
|
||||
|
@ -64,6 +70,14 @@
|
|||
],
|
||||
"version": "==0.9.1"
|
||||
},
|
||||
"flask-migrate": {
|
||||
"hashes": [
|
||||
"sha256:4dc4a5cce8cbbb06b8dc963fd86cf8136bd7d875aabe2d840302ea739b243732",
|
||||
"sha256:a69d508c2e09d289f6e55a417b3b8c7bfe70e640f53d2d9deb0d056a384f37ee"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.5.3"
|
||||
},
|
||||
"flask-praetorian": {
|
||||
"hashes": [
|
||||
"sha256:107086455f57935432700dab2611aecdaf3825421196cf6c8e812700e43b37a3",
|
||||
|
@ -101,6 +115,13 @@
|
|||
],
|
||||
"version": "==2.11.1"
|
||||
},
|
||||
"mako": {
|
||||
"hashes": [
|
||||
"sha256:3139c5d64aa5d175dbafb95027057128b5fbd05a40c53999f3905ceb53366d9d",
|
||||
"sha256:8e8b53c71c7e59f3de716b6832c4e401d903af574f6962edbbbf6ecc2a5fe6c9"
|
||||
],
|
||||
"version": "==1.1.2"
|
||||
},
|
||||
"markupsafe": {
|
||||
"hashes": [
|
||||
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
|
||||
|
@ -199,6 +220,14 @@
|
|||
],
|
||||
"version": "==2.8.1"
|
||||
},
|
||||
"python-editor": {
|
||||
"hashes": [
|
||||
"sha256:1bf6e860a8ad52a14c3ee1252d5dc25b2030618ed80c022598f00176adc8367d",
|
||||
"sha256:51fda6bcc5ddbbb7063b2af7509e43bd84bfc32a4ff71349ec7847713882327b",
|
||||
"sha256:5f98b069316ea1c2ed3f67e7f5df6c0d8f10b689964a4a811ff64f0106819ec8"
|
||||
],
|
||||
"version": "==1.0.4"
|
||||
},
|
||||
"pytz": {
|
||||
"hashes": [
|
||||
"sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d",
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from flask import Flask
|
||||
from config import Config
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
db = SQLAlchemy(app)
|
||||
migrate = Migrate(app, db)
|
||||
|
||||
from app import routes
|
||||
from app import routes, models
|
||||
|
|
|
@ -5,7 +5,7 @@ from app import app
|
|||
|
||||
|
||||
@app.route("/users", methods=["POST"])
|
||||
def create_user(self):
|
||||
def create_user():
|
||||
data = request.get_json()
|
||||
register_user(data)
|
||||
send_otp(data["mobile"])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from constants import CONNECTION_URI
|
||||
from constants import connection_uri
|
||||
|
||||
|
||||
class Config(object):
|
||||
SQLALCHEMY_DATABASE_URI = CONNECTION_URI
|
||||
SQLALCHEMY_DATABASE_URI = connection_uri
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SECRET_KEY = "trolaso"
|
||||
|
|
|
@ -0,0 +1,430 @@
|
|||
from app import db
|
||||
|
||||
|
||||
class Users(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
social_id = db.Column(db.Text)
|
||||
type = db.Column(db.Integer)
|
||||
full_name = db.Column(db.String(255), index=True, unique=True)
|
||||
email = db.Column(db.String(255), index=True, unique=True)
|
||||
password = db.Column(db.String(255))
|
||||
gender = db.Column(db.Integer)
|
||||
mobile = db.Column(db.String(255))
|
||||
user_image = db.Column(db.String(255))
|
||||
city_id = db.Column(db.Integer)
|
||||
user_type = db.Column(db.Integer)
|
||||
otp = db.Column(db.String(255))
|
||||
otp_valid_time = db.Column(db.Date)
|
||||
access_key = db.Column(db.Text)
|
||||
lang_type = db.Column(db.Integer)
|
||||
badge = db.Column(db.Integer)
|
||||
status = db.Column(db.Integer)
|
||||
admin_status = db.Column(db.Integer)
|
||||
device_id = db.Column(db.Text)
|
||||
device_type = db.Column(db.Integer)
|
||||
created = db.Column(db.TIMESTAMP, nullable=False, server_default=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id,
|
||||
social_id,
|
||||
type,
|
||||
full_name,
|
||||
email,
|
||||
password,
|
||||
gender,
|
||||
mobile,
|
||||
user_image,
|
||||
city_id,
|
||||
user_type,
|
||||
otp,
|
||||
otp_valid_time,
|
||||
access_key,
|
||||
lang_type,
|
||||
badge,
|
||||
status,
|
||||
admin_status,
|
||||
device_id,
|
||||
device_type,
|
||||
created,
|
||||
):
|
||||
self.id = id
|
||||
self.social_id = social_id
|
||||
self.type = type
|
||||
self.full_name = full_name
|
||||
self.email = email
|
||||
self.password = password
|
||||
self.gender = gender
|
||||
self.mobile = mobile
|
||||
self.user_image = user_image
|
||||
self.city_id = city_id
|
||||
self.user_type = user_type
|
||||
self.otp = otp
|
||||
self.otp_valid_time = otp_valid_time
|
||||
self.access_key = access_key
|
||||
self.lang_type = lang_type
|
||||
self.badge = badge
|
||||
self.status = status
|
||||
self.admin_status = admin_status
|
||||
self.device_id = device_id
|
||||
self.device_type = device_type
|
||||
self.created = created
|
||||
|
||||
|
||||
class Cities(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
name = db.Column(db.String(255))
|
||||
image = db.Column(db.String(255))
|
||||
status = db.Column(db.mysql.ENUM("1", "0"))
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
updated = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(self, name, image, status, created, updated):
|
||||
self.name = name
|
||||
self.image = image
|
||||
self.status = status
|
||||
self.created = created
|
||||
self.updated = updated
|
||||
|
||||
|
||||
class Games(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
name = db.Column(db.String(255))
|
||||
image = db.Column(db.String(255))
|
||||
date_time = db.Column(db.DateTime)
|
||||
price = db.Column(db.String(100))
|
||||
description = db.Column(db.Text)
|
||||
user_id = db.Column(db.Integer)
|
||||
gender = db.Column(db.mysql.ENUM("1", "2", "3"))
|
||||
city_id = db.Column(db.Integer)
|
||||
venue_id = db.Column(db.Integer)
|
||||
sports_id = db.Column(db.Integer)
|
||||
no_of_player = db.Column(db.Integer)
|
||||
min_player = db.Column(db.Integer)
|
||||
already_player = db.Column(db.Integer)
|
||||
no_of_already_player = db.Column(db.Integer)
|
||||
payment_mode = db.Column(db.Integer)
|
||||
card_id = db.Column(db.Integer)
|
||||
status = db.Column(db.Integer, server_default=1)
|
||||
game_status = db.Column(db.Integer, server_default=0)
|
||||
cancel_status = db.Column(db.Integer)
|
||||
cancel_date = db.Column(db.DateTime)
|
||||
noti_status = db.Column(db.Integer, server_default=0)
|
||||
conduct_status = db.Column(db.Integer, server_default=1)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
updated = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id,
|
||||
name,
|
||||
image,
|
||||
date_time,
|
||||
price,
|
||||
description,
|
||||
user_id,
|
||||
gender,
|
||||
city_id,
|
||||
venue_id,
|
||||
sports_id,
|
||||
no_of_player,
|
||||
min_player,
|
||||
already_player,
|
||||
no_of_already_player,
|
||||
payment_mode,
|
||||
card_id,
|
||||
created,
|
||||
updated,
|
||||
):
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.image = image
|
||||
self.date_time = date_time
|
||||
self.price = price
|
||||
self.description = description
|
||||
self.user_id = user_id
|
||||
self.gender = gender
|
||||
self.city_id = city_id
|
||||
self.venue_id = venue_id
|
||||
self.sports_id = sports_id
|
||||
self.no_of_player = no_of_player
|
||||
self.no_of_already_player = no_of_already_player
|
||||
self.payment_mode = payment_mode
|
||||
self.card_id = card_id
|
||||
self.created = created
|
||||
self.updated = updated
|
||||
|
||||
|
||||
class Payments(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
user_id = db.Column(db.Integer)
|
||||
game_id = db.Column(db.Integer)
|
||||
amount = db.Column(db.Integer)
|
||||
token = db.Column(db.String(100))
|
||||
charge_id = db.Column(db.String(200))
|
||||
transfer_id = db.Column(db.String(200))
|
||||
transaction_id = db.Column(db.String(200))
|
||||
account_no = db.Column(db.String(200))
|
||||
description = db.Column(db.Text)
|
||||
pay_mode = db.Column(db.Integer)
|
||||
status = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id,
|
||||
user_id,
|
||||
game_id,
|
||||
amount,
|
||||
token,
|
||||
charge_id,
|
||||
transfer_id,
|
||||
transaction_id,
|
||||
account_no,
|
||||
description,
|
||||
pay_mode,
|
||||
status,
|
||||
created,
|
||||
modified,
|
||||
):
|
||||
self.id = id
|
||||
self.user_id = user_id
|
||||
self.game_id = game_id
|
||||
self.amount = amount
|
||||
self.token = token
|
||||
self.charge_id = charge_id
|
||||
self.transfer_id = transfer_id
|
||||
self.transaction_id = transaction_id
|
||||
self.account_no = account_no
|
||||
self.description = description
|
||||
self.pay_mode = pay_mode
|
||||
self.status = status
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class Player_Availabilities:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
game_id = db.Column(db.Integer)
|
||||
player_id = db.Column(db.Integer)
|
||||
status = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self, id, game_id, player_id, status, created, modified,
|
||||
):
|
||||
self.id = id
|
||||
self.game_id = game_id
|
||||
self.player_id = player_id
|
||||
self.status = status
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class Player_Cancel_Games:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
player_id = db.Column(db.Integer)
|
||||
game_id = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self, id, player_id, game_id, created, modified,
|
||||
):
|
||||
self.id = id
|
||||
self.player_id = player_id
|
||||
self.game_id = game_id
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class Purchase_Games:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
game_id = db.Column(db.Integer)
|
||||
user_id = db.Column(db.Integer)
|
||||
pay_mode = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self, id, game_id, user_id, pay_mode, created, modified,
|
||||
):
|
||||
self.id = id
|
||||
self.game_id = game_id
|
||||
self.user_id = user_id
|
||||
self.pay_mode = pay_mode
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class Sports:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
name = db.Column(db.String(255))
|
||||
spanish_name = db.Column(db.String(100))
|
||||
status = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self, id, name, spanish_name, status, created, modified,
|
||||
):
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.spanish_name = spanish_name
|
||||
self.status = status
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class Teams:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
user_id = db.Column(db.Integer)
|
||||
team_id = db.Column(db.mysql.ENUM("1", "2"))
|
||||
game_id = db.Column(db.Integer)
|
||||
status = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self, id, game_id, user_id, team_id, status, created, modified,
|
||||
):
|
||||
self.id = id
|
||||
self.game_id = game_id
|
||||
self.user_id = user_id
|
||||
self.team_id = team_id
|
||||
self.status = status
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class User_Ratings:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
game_id = db.Column(db.Integer)
|
||||
user_id = db.Column(db.Integer)
|
||||
player_id = db.Column(db.mysql.ENUM("1", "2"))
|
||||
rating = db.Column(db.String(100))
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
user_type = db.Column(db.Integer)
|
||||
|
||||
def __init__(
|
||||
self, id, game_id, user_id, player_id, rating, created, modified, user_type
|
||||
):
|
||||
self.id = id
|
||||
self.game_id = game_id
|
||||
self.user_id = user_id
|
||||
self.player_id = player_id
|
||||
self.rating = rating
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
self.user_type = user_type
|
||||
|
||||
|
||||
class Venue_Images:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
venue_id = db.Column(db.Integer)
|
||||
user_id = db.Column(db.Integer)
|
||||
image = db.Column(db.String(255))
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self, id, venue_id, user_id, image, created, modified,
|
||||
):
|
||||
self.id = id
|
||||
self.venue_id = venue_id
|
||||
self.user_id = user_id
|
||||
self.image = image
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class Venues:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
user_id = db.Column(db.Integer)
|
||||
address = db.Column(db.Text)
|
||||
latitude = db.Column(db.String(100))
|
||||
longitude = db.Column(db.String(100))
|
||||
name = db.Column(db.String(100))
|
||||
sports_id = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id,
|
||||
user_id,
|
||||
address,
|
||||
latitude,
|
||||
longitude,
|
||||
name,
|
||||
sports_id,
|
||||
created,
|
||||
modified,
|
||||
):
|
||||
self.id = id
|
||||
self.user_id = user_id
|
||||
self.address = address
|
||||
self.latitude = latitude
|
||||
self.longitude = longitude
|
||||
self.name = name
|
||||
self.sports_id = sports_id
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class View_News:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
news_id = db.Column(db.Integer)
|
||||
user_id = db.Column(db.Integer)
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self, id, news_id, user_id, created, modified,
|
||||
):
|
||||
self.id = id
|
||||
self.news_id = news_id
|
||||
self.user_id = user_id
|
||||
self.created = created
|
||||
self.modified = modified
|
||||
|
||||
|
||||
class Web_Bookings:
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
name = db.Column(db.String(255))
|
||||
email = db.Column(db.String(255))
|
||||
contact = db.Column(db.String(100))
|
||||
message = db.Column(db.Text)
|
||||
game = db.Column(db.String(255))
|
||||
city = db.Column(db.String(100))
|
||||
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
|
||||
updated = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id,
|
||||
user_id,
|
||||
address,
|
||||
name,
|
||||
email,
|
||||
contact,
|
||||
message,
|
||||
game,
|
||||
city,
|
||||
created,
|
||||
updated,
|
||||
):
|
||||
self.id = id
|
||||
self.user_id = user_id
|
||||
self.address = address
|
||||
self.name = name
|
||||
self.email = email
|
||||
self.contact = contact
|
||||
self.message = message
|
||||
self.game = game
|
||||
self.city = city
|
||||
self.created = created
|
||||
self.updated = updated
|
Loading…
Reference in New Issue