# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""initial

Revision ID: 5c5f07c6f2fa
Revises: 
Create Date: 2019-11-18 15:43:56.955078

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '5c5f07c6f2fa'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('experiment',
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('time_created', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.PrimaryKeyConstraint('name')
    )
    op.create_table('trial',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('fuzzer', sa.String(), nullable=False),
    sa.Column('experiment', sa.String(), nullable=False),
    sa.Column('benchmark', sa.String(), nullable=False),
    sa.Column('time_created', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
    sa.ForeignKeyConstraint(['experiment'], ['experiment.name'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('snapshot',
    sa.Column('time', sa.Integer(), nullable=False),
    sa.Column('trial_id', sa.Integer(), nullable=False),
    sa.Column('edges_covered', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['trial_id'], ['trial.id'], ),
    sa.PrimaryKeyConstraint('time', 'trial_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('snapshot')
    op.drop_table('trial')
    op.drop_table('experiment')
    # ### end Alembic commands ###
