-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
76 lines (62 loc) · 2.72 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from flask import Flask
from flask_moment import Moment
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from datetime import datetime
app = Flask(__name__)
db = SQLAlchemy(app)
#----------------------------------------------------------------------------#
# Models.
#----------------------------------------------------------------------------#
class Venue(db.Model):
__tablename__ = 'venue'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
city = db.Column(db.String(120))
state = db.Column(db.String(120))
address = db.Column(db.String(120))
phone = db.Column(db.String(120))
genres = db.Column(db.String(120))
image_link = db.Column(db.String(500))
facebook_link = db.Column(db.String(120))
website_link = db.Column(db.String(120))
looking_for_talent = db.Column(db.Boolean,default=False)
seeking_description = db.Column(db.String(120))
shows = db.relationship('Shows', backref='venues', lazy=True)
def __repr__(self):
return f'<Venue "{self.name}">'
# TODO: implement any missing fields, as a database migration using Flask-Migrate DONE
class Artist(db.Model):
__tablename__ = 'artist'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
city = db.Column(db.String(120))
state = db.Column(db.String(120))
phone = db.Column(db.String(120))
genres = db.Column(db.String(120))
image_link = db.Column(db.String(500))
facebook_link = db.Column(db.String(120))
website_link = db.Column(db.String(120))
looking_for_talent = db.Column(db.Boolean,default=False)
seeking_description = db.Column(db.String(120))
shows = db.relationship('Shows', backref='artists', lazy=True)
def __repr__(self):
return f'<Artist "{self.name}">'
# TODO: implement any missing fields, as a database migration using Flask-Migrate DONE
# TODO Implement Show and Artist models, and complete all model relationships and properties, as a database migration. DONE
class Shows(db.Model):
__tablename__ = 'shows'
id = db.Column(db.Integer, primary_key=True)
artist_id = db.Column(db.Integer, db.ForeignKey('artist.id'), nullable = False)
venue_id = db.Column(db.Integer, db.ForeignKey('venue.id'), nullable = False)
created = db.Column(db.DateTime, default=datetime.utcnow)
def __repr__(self):
return f'<Show "{self.id}">'
class Available(db.Model):
__tablename__ = 'availability'
id = db.Column(db.Integer, primary_key=True)
artist_id = db.Column(db.Integer, db.ForeignKey('artist.id'), nullable = False)
created = db.Column(db.DateTime, default=datetime.utcnow)
def __repr__(self):
return f'<Availability "{self.id}">'
db.create_all()