Skip to content

Commit

Permalink
reset migrations, added unique constraint to gid
Browse files Browse the repository at this point in the history
  • Loading branch information
n0thingness committed Mar 27, 2018
1 parent ca4e23c commit cbb6cb3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def user_checkin(gid):
if location is None:
abort(404)
g.user.last_checkin = datetime.datetime.utcnow
g.user.checkin_location = location
location.checkedInUsers.append(g.user)
DB.session.commit()
return jsonify(
result=True
Expand Down
2 changes: 1 addition & 1 deletion location_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Location_DB(DB.Model):
__tablename__ = 'locations'

id = DB.Column(DB.Integer, primary_key=True)
gid = DB.Column(DB.String(255)) # google id, api returns location with id
gid = DB.Column(DB.String(255), unique=True) # google id, api returns location with id
name = DB.Column(DB.String(127))
address = DB.Column(DB.String(127))
phoneNumber = DB.Column(DB.String(50))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""empty message
Revision ID: 69ed2d1c50d5
Revision ID: 9c5d06b1cc7c
Revises:
Create Date: 2018-03-26 16:53:27.142562
Create Date: 2018-03-26 23:31:47.287481
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '69ed2d1c50d5'
revision = '9c5d06b1cc7c'
down_revision = None
branch_labels = None
depends_on = None
Expand All @@ -27,7 +27,8 @@ def upgrade():
sa.Column('priceLevel', sa.Integer(), nullable=True),
sa.Column('rating', sa.Float(), nullable=True),
sa.Column('currentUserCount', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id')
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('gid')
)
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
Expand All @@ -36,6 +37,9 @@ def upgrade():
sa.Column('name', sa.String(length=32), nullable=True),
sa.Column('surname', sa.String(length=32), nullable=True),
sa.Column('date_created', sa.DateTime(), nullable=True),
sa.Column('lastCheckIn', sa.DateTime(), nullable=True),
sa.Column('checkInLocation', sa.String(length=255), nullable=True),
sa.ForeignKeyConstraint(['checkInLocation'], ['locations.gid'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
Expand Down
4 changes: 2 additions & 2 deletions user_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class User_DB(DB.Model):
surname = DB.Column(DB.String(32))
date_created = DB.Column(DB.DateTime, default=datetime.datetime.utcnow)
# defaults to creation time but should be changed each time user checks in
last_checkin = DB.Column(DB.DateTime)
lastCheckIn = DB.Column(DB.DateTime)
# Foreign Key creates a pointer to the locations table - google location id column
checkInlocation = DB.Column(DB.String(255), ForeignKey('locations.gid'))
checkInLocation = DB.Column(DB.String(255), ForeignKey('locations.gid'))
# Foreign Key creates a pointer to the matched user
#current_match_id = DB.Column(DB.Integer, ForeignKey('users.id'))

Expand Down

0 comments on commit cbb6cb3

Please sign in to comment.