<commit_before>"""Fetch the S3 Canonical IDs for all active AWS accounts.

Revision ID: b8ccf5b8089b
Revises: 908b0085d28d
Create Date: 2017-03-23 11:00:43.792538
Author: <NAME> <<EMAIL>>

"""

# revision identifiers, used by Alembic.
import sqlalchemy as sa

from alembic import op
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

from security_monkey.manage import fetch_aws_canonical_ids

Session = sessionmaker()
Base = declarative_base()

revision = 'b8ccf5b8089b'
down_revision = '908b0085d28d'

class Account(Base):
    """
    Meant to model AWS accounts.
    """
    __tablename__ = "account"
    id = sa.Column(sa.Integer, primary_key=True)
    active = sa.Column(sa.Boolean())
    third_party = sa.Column(sa.Boolean())
    name = sa.Column(sa.String(32), index=True, unique=True)
    notes = sa.Column(sa.String(256))
    identifier = sa.Column(sa.String(256))  # Unique id of the account, the number for AWS.
    account_type_id = sa.Column(sa.Integer, sa.ForeignKey("account_type.id"), nullable=False)
    unique_const = sa.UniqueConstraint('account_type_id', 'identifier')


def upgrade():
    print("[-->] Adding canonical IDs to all AWS accounts that are active...")
    bind = op.get_bind()
    session = Session(bind=bind)

    # If there are currently no accounts, then skip... (avoids alembic issues...)
    accounts = session.query(Account).all()
    if len(accounts) > 0:
        fetch_aws_canonical_ids(True)

    print("[@] Completed adding canonical IDs to all active AWS accounts...")


def downgrade():
    # No need to go back...
    pass<commit_msg>No-opping DB migration b8ccf5b8089b<commit_after>"""Please run "monkey fetch_aws_canonical_ids"

Revision ID: b8ccf5b8089b
Revises: 908b0085d28d
Create Date: 2017-03-23 11:00:43.792538
Author: <NAME> <<EMAIL>>, No-op'ed by Patrick

"""

# revision identifiers, used by Alembic.
import sqlalchemy as sa

from alembic import op
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

revision = 'b8ccf5b8089b'
down_revision = '908b0085d28d'


def upgrade():
    # This revision has been replaced with a no-op after numerous reports of db upgrade problems.
    # We recommend you run:
    #   monkey fetch_aws_canonical_ids
    pass


def downgrade():
    # No need to go back...
    pass
{'fraction_non_alphanumeric': 0.10629251700680271, 'fraction_numerical': 0.04931972789115646, 'mean_word_length': 4.10412147505423, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2215680', 'n_tokens_mistral': 864, 'n_tokens_neox': 777, 'n_words': 225}