Initial migration

This commit is contained in:
Cara Salter 2022-12-05 16:34:28 -05:00
parent 818b2884b2
commit 8cf72b1065
No known key found for this signature in database
GPG key ID: 90C66610C82B29CA
3 changed files with 55 additions and 1 deletions

View file

@ -17,4 +17,6 @@ def create_app():
migrate.init_app(app, db)
login.init_app(app)
from .models import User
return app

13
goathacks/models.py Normal file
View file

@ -0,0 +1,13 @@
from flask_login import UserMixin
from sqlalchemy import Boolean, Column, DateTime, Integer, String
from . import db
class User(db.Model, UserMixin):
id = Column(Integer, primary_key=True)
email = Column(String, unique=True, nullable=False)
password = Column(String, nullable=False)
first_name = Column(String, nullable=False)
last_name = Column(String, nullable=False)
last_login = Column(DateTime, nullable=False)
active = Column(Boolean, nullable=False, default=True)
is_admin = Column(Boolean, nullable=False, default=False)

View file

@ -0,0 +1,39 @@
"""create user
Revision ID: afb7433de2f3
Revises:
Create Date: 2022-12-05 16:33:45.070436
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'afb7433de2f3'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(), nullable=False),
sa.Column('password', sa.String(), nullable=False),
sa.Column('first_name', sa.String(), nullable=False),
sa.Column('last_name', sa.String(), nullable=False),
sa.Column('last_login', sa.DateTime(), nullable=False),
sa.Column('active', sa.Boolean(), nullable=False),
sa.Column('is_admin', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user')
# ### end Alembic commands ###