"""The one migration to rule them all

Revision ID: 3a0669bb5312
Revises: 
Create Date: 2021-04-28 11:45:16.436405

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '3a0669bb5312'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('teams',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('teamName', sa.String(length=50), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('firstname', sa.String(length=50), nullable=False),
    sa.Column('lastname', sa.String(length=50), nullable=False),
    sa.Column('username', sa.String(length=40), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=False),
    sa.Column('user_avatar', sa.String(length=255), nullable=True),
    sa.Column('hashed_password', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('projects',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('projectTitle', sa.String(length=50), nullable=False),
    sa.Column('projectDescription', sa.String(length=255), nullable=False),
    sa.Column('dueDate', sa.Date(), nullable=False),
    sa.Column('teamId', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['teamId'], ['teams.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('usersOnTeams',
    sa.Column('userId', sa.Integer(), nullable=False),
    sa.Column('teamId', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['teamId'], ['teams.id'], ),
    sa.ForeignKeyConstraint(['userId'], ['users.id'], ),
    sa.PrimaryKeyConstraint('userId', 'teamId')
    )
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('commentBody', sa.String(length=255), nullable=False),
    sa.Column('createdAt', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
    sa.Column('projectId', sa.Integer(), nullable=False),
    sa.Column('userId', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['projectId'], ['projects.id'], ),
    sa.ForeignKeyConstraint(['userId'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tasks',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('taskName', sa.String(length=50), nullable=False),
    sa.Column('taskBody', sa.String(length=255), nullable=True),
    sa.Column('dueDate', sa.Date(), nullable=False),
    sa.Column('completed', sa.Boolean(), nullable=False),
    sa.Column('assignedUserId', sa.Integer(), nullable=True),
    sa.Column('projectId', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['assignedUserId'], ['users.id'], ),
    sa.ForeignKeyConstraint(['projectId'], ['projects.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('tasks')
    op.drop_table('comments')
    op.drop_table('usersOnTeams')
    op.drop_table('projects')
    op.drop_table('users')
    op.drop_table('teams')
    # ### end Alembic commands ###
