""".

Revision ID: 84f53900d351
Revises: 
Create Date: 2018-08-11 06:33:15.862312

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import ENUM


# revision identifiers, used by Alembic.
revision = '84f53900d351'
down_revision = None
branch_labels = None
depends_on = None
status_pembayaran = ENUM('pending', 'confirmed', 'rejected', name='status_pembayaran', create_type=False)


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('PO',
    sa.Column('id_po', sa.Integer(), nullable=False),
    sa.Column('nama_po', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id_po')
    )
    op.create_table('rute',
    sa.Column('id_rute', sa.Integer(), nullable=False),
    sa.Column('tujuan', sa.String(), nullable=True),
    sa.Column('ongkos', sa.Integer(), nullable=True),
    sa.Column('jadwal_keberangkatan', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id_rute')
    )
    op.create_table('data pesanan',
    sa.Column('kode_pemesanan', sa.String(), nullable=False),
    sa.Column('nama_pemesan', sa.String(), nullable=True),
    sa.Column('nomor_telepon', sa.VARCHAR(), nullable=True),
    sa.Column('alamat', sa.String(), nullable=True),
    sa.Column('tanggal_lahir', sa.DateTime(), nullable=True),
    sa.Column('tanggal_pesanan_tiket', sa.DateTime(), nullable=True),
    sa.Column('jadwal_berangkat', sa.DateTime(), nullable=True),
    sa.Column('jumlah_kursi', sa.Integer(), nullable=True),
    sa.Column('harga_total', sa.Integer(), nullable=True),
                    sa.Column('status_pembayaran', status_pembayaran, nullable=True),
    sa.Column('rute_id', sa.Integer(), nullable=True),
    sa.Column('po_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['po_id'], ['PO.id_po'], ),
    sa.ForeignKeyConstraint(['rute_id'], ['rute.id_rute'], ),
    sa.PrimaryKeyConstraint('kode_pemesanan'),
    sa.UniqueConstraint('kode_pemesanan')
    )
    # op.create_foreign_key(None, 'user', 'PO', ['po_id'], ['id_po'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'user', type_='foreignkey')
    op.drop_table('data pesanan')
    op.drop_table('rute')
    op.drop_table('PO')
    # ### end Alembic commands ###
