<commit_before>"""message contact association

Revision ID: 223041bb858b
Revises: <PASSWORD>
Create Date: 2014-04-28 23:52:05.449401

"""

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '2c9f3a06de09'

# Yes, this is a terrible hack. But tools/rerank_contacts.py already contains a
# script to process contacts from messages, so it's very expedient.
import sys
sys.path.append('./tools')
from rerank_contacts import rerank_contacts

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.create_table(
        'messagecontactassociation',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('contact_id', sa.Integer(), nullable=False),
        sa.Column('message_id', sa.Integer(), nullable=False),
        sa.Column('field',
                  sa.Enum('from_addr', 'to_addr', 'cc_addr', 'bcc_addr'),
                  nullable=True),
        sa.ForeignKeyConstraint(['contact_id'], ['contact.id'], ),
        sa.ForeignKeyConstraint(['message_id'], ['message.id'], ),
        sa.PrimaryKeyConstraint('id', 'contact_id', 'message_id')
    )
    rerank_contacts()


def downgrade():
    op.drop_table('messagecontactassociation')<commit_msg>Rearrange imports in previous migration.<commit_after>"""message contact association

Revision ID: 223041bb858b
Revises: <PASSWORD>
Create Date: 2014-04-28 23:52:05.449401

"""

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '2c9f3a06de09'


from alembic import op
import sqlalchemy as sa


def upgrade():
    op.create_table(
        'messagecontactassociation',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('contact_id', sa.Integer(), nullable=False),
        sa.Column('message_id', sa.Integer(), nullable=False),
        sa.Column('field',
                  sa.Enum('from_addr', 'to_addr', 'cc_addr', 'bcc_addr'),
                  nullable=True),
        sa.ForeignKeyConstraint(['contact_id'], ['contact.id'], ),
        sa.ForeignKeyConstraint(['message_id'], ['message.id'], ),
        sa.PrimaryKeyConstraint('id', 'contact_id', 'message_id')
    )

    # Yes, this is a terrible hack. But tools/rerank_contacts.py already
    # contains a script to process contacts from messages, so it's very
    # expedient.
    import sys
    sys.path.append('./tools')
    from rerank_contacts import rerank_contacts
    rerank_contacts()


def downgrade():
    op.drop_table('messagecontactassociation')
{'fraction_non_alphanumeric': 0.13555194805194806, 'fraction_numerical': 0.02922077922077922, 'mean_word_length': 3.6863117870722433, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5277846', 'n_tokens_mistral': 822, 'n_tokens_neox': 753, 'n_words': 177}