"""user_trial_ends_at

Revision: 0044
Revision ID: 21e56a0093b
Revises: 459ea8446830
Create Date: 2015-12-20 11:06:13.745404

"""

# revision identifiers, used by Alembic.
revision = '21e56a0093b'
down_revision = '459ea8446830'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.add_column('users', sa.Column('trial_ends_at', sa.DateTime(), nullable=True))
    op.execute("UPDATE users SET trial_ends_at = (SELECT trial_ends_at FROM organizations WHERE created_by_id = users.id AND is_user_org)")


def downgrade():
    op.drop_column('users', 'trial_ends_at')
