-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
59 lines (48 loc) · 2.42 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
# ----------------------------------------------------------------------------#
# Imports
# ----------------------------------------------------------------------------#
from app import db
from datetime import datetime
# DONE: connect to a local postgresql database
# ----------------------------------------------------------------------------#
# Models.
# ----------------------------------------------------------------------------#
Shows = db.Table("Shows",
db.Column("id", db.Integer, primary_key=True),
db.Column("artist_id", db.Integer, db.ForeignKey("Artist.id")),
db.Column("venue_id", db.Integer, db.ForeignKey("Venue.id")),
db.Column("start_time", db.DateTime, default=datetime.utcnow()))
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), index=True)
state = db.Column(db.String(120), index=True)
address = db.Column(db.String(120))
phone = db.Column(db.String(120))
image_link = db.Column(db.String(500))
facebook_link = db.Column(db.String(120))
genres = db.Column(db.ARRAY(db.String()))
seeking_talent = db.Column(db.Boolean(), default=False)
seeking_description = db.Column(db.String())
website_link = db.Column(db.String(500))
artists = db.relationship("Artist", secondary=Shows,
backref=db.backref('Venue',
cascade="all,delete"), lazy=True)
# DONE: implement any missing fields, as a database migration using Flask-Migrate
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.ARRAY(db.String))
image_link = db.Column(db.String(500))
facebook_link = db.Column(db.String(120))
seeking_venue = db.Column(db.Boolean(), default=False)
seeking_description = db.Column(db.String(300))
website_link = db.Column(db.String(500))
venues = db.relationship("Venue", secondary=Shows, backref="Artist", lazy=True)
# DONE: implement any missing fields, as a database migration using Flask-Migrate
# DONE Implement Show and Artist models, and complete all model relationships and properties, as a database migration.