
Initial commit of the event schema for the database. This includes models and alembic migration.
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""Initial Event schema.
|
|
|
|
Revision ID: 3ab6d7bf80cd
|
|
Revises: None
|
|
Create Date: 2014-06-26 01:36:42.792353
|
|
|
|
"""
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '3ab6d7bf80cd'
|
|
down_revision = None
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from winchester import models
|
|
|
|
def upgrade():
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('event_type',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('desc', sa.String(length=255), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('desc')
|
|
)
|
|
op.create_table('event',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('message_id', sa.String(length=50), nullable=True),
|
|
sa.Column('generated', models.PreciseTimestamp(), nullable=True),
|
|
sa.Column('event_type_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['event_type_id'], ['event_type.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('message_id')
|
|
)
|
|
op.create_table('trait',
|
|
sa.Column('event_id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=100), nullable=False),
|
|
sa.Column('type', sa.Integer(), nullable=True),
|
|
sa.Column('t_string', sa.String(length=255), nullable=True),
|
|
sa.Column('t_float', sa.Float(), nullable=True),
|
|
sa.Column('t_int', sa.Integer(), nullable=True),
|
|
sa.Column('t_datetime', models.PreciseTimestamp(), nullable=True),
|
|
sa.ForeignKeyConstraint(['event_id'], ['event.id'], ),
|
|
sa.PrimaryKeyConstraint('event_id', 'name')
|
|
)
|
|
### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('trait')
|
|
op.drop_table('event')
|
|
op.drop_table('event_type')
|
|
### end Alembic commands ###
|