# Path: aodh/storage/sqlalchemy/models.py
# class JSONEncodedDict(TypeDecorator):
# class TimestampUTC(TypeDecorator):
# class AodhBase(object):
# class Alarm(Base):
# class AlarmChange(Base):
# class Quota(Base):
#     def process_bind_param(value, dialect):
#     def process_result_value(value, dialect):
#     def load_dialect_impl(self, dialect):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def update(self, values):


from alembic import op
from sqlalchemy import func
from aodh.storage.sqlalchemy import models
import sqlalchemy as sa
Revises: f8c31b1ffe11
Create Date: 2016-09-19 16:43:34.379029

"""

# revision identifiers, used by Alembic.
revision = '367aadf5485f'
down_revision = 'f8c31b1ffe11'
branch_labels = None
depends_on = None




def upgrade():
    bind = op.get_bind()
    if bind and bind.engine.name == "mysql":
        # NOTE(jd) So that crappy engine that is MySQL does not have "ALTER
        # TABLE … USING …". We need to copy everything and convert…
        for table_name, column_name in (("alarm", "timestamp"),
                                        ("alarm", "state_timestamp"),
                                        ("alarm_history", "timestamp")):
            existing_type = sa.types.DECIMAL(
                precision=20, scale=6, asdecimal=True)
            existing_col = sa.Column(
                column_name,
                existing_type,
                nullable=True)
            temp_col = sa.Column(
                column_name + "_ts",

# Path: aodh/storage/sqlalchemy/models.py
# class JSONEncodedDict(TypeDecorator):
# class TimestampUTC(TypeDecorator):
# class AodhBase(object):
# class Alarm(Base):
# class AlarmChange(Base):
# class Quota(Base):
#     def process_bind_param(value, dialect):
#     def process_result_value(value, dialect):
#     def load_dialect_impl(self, dialect):
#     def __setitem__(self, key, value):
#     def __getitem__(self, key):
#     def update(self, values):


# Path: aodh/storage/sqlalchemy/alembic/versions/367aadf5485f_precisetimestamp_to_datetime.py
from alembic import op
from sqlalchemy import func
from aodh.storage.sqlalchemy import models
import sqlalchemy as sa

Revises: f8c31b1ffe11
Create Date: 2016-09-19 16:43:34.379029

"""

# revision identifiers, used by Alembic.
revision = '367aadf5485f'
down_revision = 'f8c31b1ffe11'
branch_labels = None
depends_on = None




def upgrade():
    bind = op.get_bind()
    if bind and bind.engine.name == "mysql":
        # NOTE(jd) So that crappy engine that is MySQL does not have "ALTER
        # TABLE … USING …". We need to copy everything and convert…
        for table_name, column_name in (("alarm", "timestamp"),
                                        ("alarm", "state_timestamp"),
                                        ("alarm_history", "timestamp")):
            existing_type = sa.types.DECIMAL(
                precision=20, scale=6, asdecimal=True)
            existing_col = sa.Column(
                column_name,
                existing_type,
                nullable=True)
            temp_col = sa.Column(
                column_name + "_ts",

                models.TimestampUTC(),