<commit_before>"""Add `application_close_date` for Framework
Revision ID: 840
Revises: 830
Create Date: 2017-02-06 11:09:26.852142
"""
from alembic import op
from datetime import datetime
from dateutil import tz
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '840'
down_revision = '830'


frameworks_table = sa.table(
    'frameworks',
    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('slug', sa.String, nullable=False, unique=True, index=True),
    sa.Column('allow_declaration_reuse', sa.Boolean),
    sa.Column('application_close_date', sa.DateTime)
)

tz_utc = tz.tzoffset('utc', 0)


def upgrade():
    op.add_column('frameworks', sa.Column('application_close_date', sa.DateTime(), nullable=True))
    op.add_column(
        'frameworks',
        sa.Column('allow_declaration_reuse', sa.Boolean(), nullable=False, server_default='false')
    )

    fields = ('slug', 'application_close_date', 'allow_declaration_reuse')
    new_values = (
        ('digital-outcomes-and-specialists', datetime(2016, 1, 1, 15, tzinfo=tz_utc), False),
        ('digital-outcomes-and-specialists-2', datetime(2017, 1, 16, 17, tzinfo=tz_utc), True),
        ('g-cloud-8', datetime(2016, 6, 1, 17, tzinfo=tz_utc), True),

    )
    new_values = [dict(zip(fields, i)) for i in new_values]
    for i in new_values:
        op.execute(
            frameworks_table.update().where(frameworks_table.c.slug==i.pop('slug')).values(**i)
        )


def downgrade():
    op.drop_column('frameworks', 'allow_declaration_reuse')
    op.drop_column('frameworks', 'application_close_date')<commit_msg>Remove tzinfo, postgres converts to utc anyway :/<commit_after>"""Add `application_close_date` for Framework
Revision ID: 840
Revises: 830
Create Date: 2017-02-06 11:09:26.852142
"""
from alembic import op
from datetime import datetime
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '840'
down_revision = '830'


frameworks_table = sa.table(
    'frameworks',
    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('slug', sa.String, nullable=False, unique=True, index=True),
    sa.Column('allow_declaration_reuse', sa.Boolean),
    sa.Column('application_close_date', sa.DateTime)
)


def upgrade():
    op.add_column('frameworks', sa.Column('application_close_date', sa.DateTime(), nullable=True))
    op.add_column(
        'frameworks',
        sa.Column('allow_declaration_reuse', sa.Boolean(), nullable=False, server_default='false')
    )

    fields = ('slug', 'application_close_date', 'allow_declaration_reuse')
    new_values = (
        ('digital-outcomes-and-specialists', datetime(2016, 1, 1, 15), True),
        ('digital-outcomes-and-specialists-2', datetime(2017, 1, 16, 17), True),
        ('g-cloud-8', datetime(2016, 6, 1, 17), True),

    )
    new_values = [dict(zip(fields, i)) for i in new_values]
    for i in new_values:
        op.execute(
            frameworks_table.update().where(frameworks_table.c.slug==i.pop('slug')).values(**i)
        )


def downgrade():
    op.drop_column('frameworks', 'allow_declaration_reuse')
    op.drop_column('frameworks', 'application_close_date')
{'fraction_non_alphanumeric': 0.1470031545741325, 'fraction_numerical': 0.03753943217665615, 'mean_word_length': 4.267441860465116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5563857', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1057, 'n_words': 222}