mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Rebased migrations, all tests working.
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0001_initialise_data
|
||||
Revises: None
|
||||
Create Date: 2016-01-12 09:33:29.249042
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0001_initialise_data'
|
||||
down_revision = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('services',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('active', sa.Boolean(), nullable=False),
|
||||
sa.Column('limit', sa.BigInteger(), nullable=False),
|
||||
sa.Column('restricted', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('email_address', sa.String(length=255), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_users_email_address'), 'users', ['email_address'], unique=True)
|
||||
op.create_table('user_to_service',
|
||||
sa.Column('user_id', sa.Integer(), nullable=True),
|
||||
sa.Column('service_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('user_to_service')
|
||||
op.drop_index(op.f('ix_users_email_address'), table_name='users')
|
||||
op.drop_table('users')
|
||||
op.drop_table('services')
|
||||
### end Alembic commands ###
|
||||
225
migrations/versions/0001_restart_migrations.py
Normal file
225
migrations/versions/0001_restart_migrations.py
Normal file
@@ -0,0 +1,225 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0001_restart_migrations
|
||||
Revises: None
|
||||
Create Date: 2016-04-07 17:22:12.147542
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0001_restart_migrations'
|
||||
down_revision = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('services',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('active', sa.Boolean(), nullable=False),
|
||||
sa.Column('limit', sa.BigInteger(), nullable=False),
|
||||
sa.Column('restricted', sa.Boolean(), nullable=False),
|
||||
sa.Column('email_from', sa.Text(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email_from'),
|
||||
sa.UniqueConstraint('name')
|
||||
)
|
||||
op.create_table('users',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('email_address', sa.String(length=255), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('_password', sa.String(), nullable=False),
|
||||
sa.Column('mobile_number', sa.String(), nullable=False),
|
||||
sa.Column('password_changed_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('logged_in_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('failed_login_count', sa.Integer(), nullable=False),
|
||||
sa.Column('state', sa.String(), nullable=False),
|
||||
sa.Column('platform_admin', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_users_email_address'), 'users', ['email_address'], unique=True)
|
||||
op.create_index(op.f('ix_users_name'), 'users', ['name'], unique=False)
|
||||
op.create_table('api_keys',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('secret', sa.String(length=255), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('expiry_date', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('secret'),
|
||||
sa.UniqueConstraint('service_id', 'name', name='uix_service_to_key_name')
|
||||
)
|
||||
op.create_index(op.f('ix_api_keys_service_id'), 'api_keys', ['service_id'], unique=False)
|
||||
op.create_table('invited_users',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('email_address', sa.String(length=255), nullable=False),
|
||||
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('status', sa.Enum('pending', 'accepted', 'cancelled', name='invited_users_status_types'), nullable=False),
|
||||
sa.Column('permissions', sa.String(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_invited_users_service_id'), 'invited_users', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_invited_users_user_id'), 'invited_users', ['user_id'], unique=False)
|
||||
op.create_table('notification_statistics',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('day', sa.String(length=255), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('emails_requested', sa.BigInteger(), nullable=False),
|
||||
sa.Column('emails_delivered', sa.BigInteger(), nullable=False),
|
||||
sa.Column('emails_error', sa.BigInteger(), nullable=False),
|
||||
sa.Column('sms_requested', sa.BigInteger(), nullable=False),
|
||||
sa.Column('sms_delivered', sa.BigInteger(), nullable=False),
|
||||
sa.Column('sms_error', sa.BigInteger(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('service_id', 'day', name='uix_service_to_day')
|
||||
)
|
||||
op.create_index(op.f('ix_notification_statistics_service_id'), 'notification_statistics', ['service_id'], unique=False)
|
||||
op.create_table('permissions',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('permission', sa.Enum('manage_users', 'manage_templates', 'manage_settings', 'send_texts', 'send_emails', 'send_letters', 'manage_api_keys', 'platform_admin', 'view_activity', name='permission_types'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('service_id', 'user_id', 'permission', name='uix_service_user_permission')
|
||||
)
|
||||
op.create_index(op.f('ix_permissions_service_id'), 'permissions', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_permissions_user_id'), 'permissions', ['user_id'], unique=False)
|
||||
op.create_table('templates',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('template_type', sa.Enum('sms', 'email', 'letter', name='template_type'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('subject', sa.Text(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('subject')
|
||||
)
|
||||
op.create_index(op.f('ix_templates_service_id'), 'templates', ['service_id'], unique=False)
|
||||
op.create_table('user_to_service',
|
||||
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.UniqueConstraint('user_id', 'service_id', name='uix_user_to_service')
|
||||
)
|
||||
op.create_table('verify_codes',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('_code', sa.String(), nullable=False),
|
||||
sa.Column('code_type', sa.Enum('email', 'sms', name='verify_code_types'), nullable=False),
|
||||
sa.Column('expiry_datetime', sa.DateTime(), nullable=False),
|
||||
sa.Column('code_used', sa.Boolean(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_verify_codes_user_id'), 'verify_codes', ['user_id'], unique=False)
|
||||
op.create_table('jobs',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('original_file_name', sa.String(), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('status', sa.Enum('pending', 'in progress', 'finished', 'sending limits exceeded', name='job_status_types'), nullable=False),
|
||||
sa.Column('notification_count', sa.Integer(), nullable=False),
|
||||
sa.Column('notifications_sent', sa.Integer(), nullable=False),
|
||||
sa.Column('processing_started', sa.DateTime(), nullable=True),
|
||||
sa.Column('processing_finished', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_jobs_service_id'), 'jobs', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_jobs_template_id'), 'jobs', ['template_id'], unique=False)
|
||||
op.create_table('template_statistics',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('usage_count', sa.BigInteger(), nullable=False),
|
||||
sa.Column('day', sa.Date(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_template_statistics_day'), 'template_statistics', ['day'], unique=False)
|
||||
op.create_index(op.f('ix_template_statistics_service_id'), 'template_statistics', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_template_statistics_template_id'), 'template_statistics', ['template_id'], unique=False)
|
||||
op.create_table('notifications',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('to', sa.String(), nullable=False),
|
||||
sa.Column('job_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('template_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('sent_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('sent_by', sa.String(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('status', sa.Enum('sent', 'delivered', 'failed', 'complaint', 'bounce', name='notification_status_types'), nullable=False),
|
||||
sa.Column('reference', sa.String(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], ),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_notifications_job_id'), 'notifications', ['job_id'], unique=False)
|
||||
op.create_index(op.f('ix_notifications_reference'), 'notifications', ['reference'], unique=False)
|
||||
op.create_index(op.f('ix_notifications_service_id'), 'notifications', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_notifications_template_id'), 'notifications', ['template_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_notifications_template_id'), table_name='notifications')
|
||||
op.drop_index(op.f('ix_notifications_service_id'), table_name='notifications')
|
||||
op.drop_index(op.f('ix_notifications_reference'), table_name='notifications')
|
||||
op.drop_index(op.f('ix_notifications_job_id'), table_name='notifications')
|
||||
op.drop_table('notifications')
|
||||
op.drop_index(op.f('ix_template_statistics_template_id'), table_name='template_statistics')
|
||||
op.drop_index(op.f('ix_template_statistics_service_id'), table_name='template_statistics')
|
||||
op.drop_index(op.f('ix_template_statistics_day'), table_name='template_statistics')
|
||||
op.drop_table('template_statistics')
|
||||
op.drop_index(op.f('ix_jobs_template_id'), table_name='jobs')
|
||||
op.drop_index(op.f('ix_jobs_service_id'), table_name='jobs')
|
||||
op.drop_table('jobs')
|
||||
op.drop_index(op.f('ix_verify_codes_user_id'), table_name='verify_codes')
|
||||
op.drop_table('verify_codes')
|
||||
op.drop_table('user_to_service')
|
||||
op.drop_index(op.f('ix_templates_service_id'), table_name='templates')
|
||||
op.drop_table('templates')
|
||||
op.drop_index(op.f('ix_permissions_user_id'), table_name='permissions')
|
||||
op.drop_index(op.f('ix_permissions_service_id'), table_name='permissions')
|
||||
op.drop_table('permissions')
|
||||
op.drop_index(op.f('ix_notification_statistics_service_id'), table_name='notification_statistics')
|
||||
op.drop_table('notification_statistics')
|
||||
op.drop_index(op.f('ix_invited_users_user_id'), table_name='invited_users')
|
||||
op.drop_index(op.f('ix_invited_users_service_id'), table_name='invited_users')
|
||||
op.drop_table('invited_users')
|
||||
op.drop_index(op.f('ix_api_keys_service_id'), table_name='api_keys')
|
||||
op.drop_table('api_keys')
|
||||
op.drop_index(op.f('ix_users_name'), table_name='users')
|
||||
op.drop_index(op.f('ix_users_email_address'), table_name='users')
|
||||
op.drop_table('users')
|
||||
op.drop_table('services')
|
||||
### end Alembic commands ###
|
||||
@@ -1,38 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0002_add_templates
|
||||
Revises: 0001_initialise_data
|
||||
Create Date: 2016-01-13 10:10:37.303109
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0002_add_templates'
|
||||
down_revision = '0001_initialise_data'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('templates',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('template_type', sa.Enum('sms', 'email', 'letter', name='template_type'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column('service_id', sa.BigInteger(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_templates_service_id'), 'templates', ['service_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_templates_service_id'), table_name='templates')
|
||||
op.drop_table('templates')
|
||||
### end Alembic commands ###
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0003_create_tokens
|
||||
Revises: 0001_initialise_data
|
||||
Create Date: 2016-01-13 17:07:49.061776
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0003_create_tokens'
|
||||
down_revision = '0002_add_templates'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('tokens',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('token', sa.String(length=255), nullable=False),
|
||||
sa.Column('service_id', sa.Integer(), nullable=False),
|
||||
sa.Column('expiry_date', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('token')
|
||||
)
|
||||
op.create_index(op.f('ix_tokens_service_id'), 'tokens', ['service_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_tokens_service_id'), table_name='tokens')
|
||||
op.drop_table('tokens')
|
||||
### end Alembic commands ###
|
||||
@@ -1,40 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0004_create_jobs
|
||||
Revises: 0003_create_tokens
|
||||
Create Date: 2016-01-15 10:12:02.381160
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0004_create_jobs'
|
||||
down_revision = '0003_create_tokens'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('jobs',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('original_file_name', sa.String(), nullable=False),
|
||||
sa.Column('service_id', sa.BigInteger(), nullable=True),
|
||||
sa.Column('template_id', sa.BigInteger(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_jobs_service_id'), 'jobs', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_jobs_template_id'), 'jobs', ['template_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_jobs_template_id'), table_name='jobs')
|
||||
op.drop_index(op.f('ix_jobs_service_id'), table_name='jobs')
|
||||
op.drop_table('jobs')
|
||||
### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0005_add_job_details
|
||||
Revises: 0004_create_jobs
|
||||
Create Date: 2016-01-15 15:57:38.022562
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0005_add_job_details'
|
||||
down_revision = '0004_create_jobs'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('jobs', sa.Column('bucket_name', sa.String(), nullable=False))
|
||||
op.add_column('jobs', sa.Column('file_name', sa.String(), nullable=False))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('jobs', 'file_name')
|
||||
op.drop_column('jobs', 'bucket_name')
|
||||
### end Alembic commands ###
|
||||
@@ -1,40 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0006_add_user_details
|
||||
Revises: 0005_add_job_details
|
||||
Create Date: 2016-01-19 11:16:06.518285
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0006_add_user_details'
|
||||
down_revision = '0005_add_job_details'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('users', sa.Column('_password', sa.String(), nullable=False))
|
||||
op.add_column('users', sa.Column('failed_login_count', sa.Integer(), nullable=False))
|
||||
op.add_column('users', sa.Column('logged_in_at', sa.DateTime(), nullable=True))
|
||||
op.add_column('users', sa.Column('mobile_number', sa.String(), nullable=False))
|
||||
op.add_column('users', sa.Column('name', sa.String(), nullable=False))
|
||||
op.add_column('users', sa.Column('password_changed_at', sa.DateTime(), nullable=True))
|
||||
op.add_column('users', sa.Column('state', sa.String(), nullable=False))
|
||||
op.create_index(op.f('ix_users_name'), 'users', ['name'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_users_name'), table_name='users')
|
||||
op.drop_column('users', 'state')
|
||||
op.drop_column('users', 'password_changed_at')
|
||||
op.drop_column('users', 'name')
|
||||
op.drop_column('users', 'mobile_number')
|
||||
op.drop_column('users', 'logged_in_at')
|
||||
op.drop_column('users', 'failed_login_count')
|
||||
op.drop_column('users', '_password')
|
||||
### end Alembic commands ###
|
||||
@@ -1,47 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0007_change_to_api_keys
|
||||
Revises: 0005_add_job_details
|
||||
Create Date: 2016-01-19 10:50:46.269618
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0007_change_to_api_keys'
|
||||
down_revision = '0006_add_user_details'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('api_key',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
sa.Column('secret', sa.String(length=255), nullable=False),
|
||||
sa.Column('service_id', sa.Integer(), nullable=False),
|
||||
sa.Column('expiry_date', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('secret')
|
||||
)
|
||||
op.create_index(op.f('ix_api_key_service_id'), 'api_key', ['service_id'], unique=False)
|
||||
op.drop_table('tokens')
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('tokens',
|
||||
sa.Column('id', sa.INTEGER(), nullable=False),
|
||||
sa.Column('token', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
|
||||
sa.Column('service_id', sa.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('expiry_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], name='tokens_service_id_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='tokens_pkey'),
|
||||
sa.UniqueConstraint('token', name='tokens_token_key')
|
||||
)
|
||||
op.drop_index(op.f('ix_api_key_service_id'), table_name='api_key')
|
||||
op.drop_table('api_key')
|
||||
### end Alembic commands ###
|
||||
@@ -1,38 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0008_add_verify_codes
|
||||
Revises: 0007_change_to_api_keys
|
||||
Create Date: 2016-01-21 16:59:05.818017
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0008_add_verify_codes'
|
||||
down_revision = '0007_change_to_api_keys'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('verify_codes',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('_code', sa.String(), nullable=False),
|
||||
sa.Column('code_type', sa.Enum('email', 'sms', name='verify_code_types'), nullable=False),
|
||||
sa.Column('expiry_datetime', sa.DateTime(), nullable=False),
|
||||
sa.Column('code_used', sa.Boolean(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_verify_codes_user_id'), 'verify_codes', ['user_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_verify_codes_user_id'), table_name='verify_codes')
|
||||
op.drop_table('verify_codes')
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0009_unique_service_to_key_name
|
||||
Revises: 0007_change_to_api_keys
|
||||
Create Date: 2016-01-21 16:14:51.773001
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0009_unique_service_to_key_name'
|
||||
down_revision = '0008_add_verify_codes'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_unique_constraint('uix_service_to_key_name', 'api_key', ['service_id', 'name'])
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('uix_service_to_key_name', 'api_key', type_='unique')
|
||||
### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0010_add_queue_name_to_service
|
||||
Revises: 0009_unique_service_to_key_name
|
||||
Create Date: 2016-01-27 13:53:34.717916
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
|
||||
revision = '0010_add_queue_name_to_service'
|
||||
down_revision = '0009_unique_service_to_key_name'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('services', sa.Column('queue_name', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
op.get_bind()
|
||||
op.execute('update services set queue_name = (SELECT uuid_in(md5(random()::text || now()::text)::cstring))')
|
||||
### end Alembic commands ###
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('services', 'queue_name')
|
||||
### end Alembic commands ###
|
||||
@@ -1,121 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0011_uuid_service_id
|
||||
Revises: 0010_add_queue_name_to_service
|
||||
Create Date: 2016-02-01 15:47:30.553052
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = '0011_uuid_service_id'
|
||||
down_revision = '0010_add_queue_name_to_service'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
# op.execute('update jobs set new_service_id = (SELECT queue_name from services where service_id = services.id)')
|
||||
|
||||
op.add_column('user_to_service', sa.Column('new_service_id', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
op.get_bind()
|
||||
op.execute('update user_to_service '\
|
||||
'set new_service_id = (SELECT queue_name from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('user_to_service', 'service_id')
|
||||
op.alter_column('user_to_service', 'new_service_id', new_column_name='service_id')
|
||||
|
||||
op.add_column('jobs', sa.Column('new_service_id', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
op.execute('update jobs '\
|
||||
'set new_service_id = (SELECT queue_name from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('jobs', 'service_id')
|
||||
op.alter_column('jobs', 'new_service_id', new_column_name='service_id', nullable=False)
|
||||
|
||||
op.add_column('api_key', sa.Column('new_service_id', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
op.execute('update api_key '\
|
||||
'set new_service_id = (SELECT queue_name from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('api_key', 'service_id')
|
||||
op.alter_column('api_key', 'new_service_id', new_column_name='service_id', nullable=False)
|
||||
|
||||
op.add_column('templates', sa.Column('new_service_id', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
op.execute('update templates '\
|
||||
'set new_service_id = (SELECT queue_name from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('templates', 'service_id')
|
||||
op.alter_column('templates', 'new_service_id', new_column_name='service_id', nullable=False)
|
||||
|
||||
op.drop_constraint('services_pkey', 'services')
|
||||
op.alter_column('services', 'id', new_column_name='old_id')
|
||||
op.alter_column('services', 'queue_name', new_column_name='id', nullable=False)
|
||||
|
||||
op.create_primary_key('services_pkey', 'services', ['id'])
|
||||
|
||||
op.create_foreign_key('user_to_service_service_id_fkey', 'user_to_service', 'services', ['service_id'], ['id'])
|
||||
op.create_foreign_key('api_key_service_id_fkey', 'api_key', 'services', ['service_id'], ['id'])
|
||||
op.create_foreign_key('jobs_service_id_fkey', 'jobs', 'services', ['service_id'], ['id'])
|
||||
op.create_foreign_key('templates_service_id_fkey', 'templates', 'services', ['service_id'], ['id'])
|
||||
|
||||
op.create_index(op.f('ix_templates_service_id'), 'templates', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_jobs_service_id'), 'jobs', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_api_key_service_id'), 'api_key', ['service_id'], unique=False)
|
||||
op.create_unique_constraint('uix_service_to_key_name', 'api_key', ['service_id', 'name'])
|
||||
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
op.add_column('user_to_service', sa.Column('new_service_id', sa.Integer, nullable=True))
|
||||
op.get_bind()
|
||||
op.execute('update user_to_service '\
|
||||
'set new_service_id = (SELECT old_id from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('user_to_service', 'service_id')
|
||||
op.alter_column('user_to_service', 'new_service_id', new_column_name='service_id', nullable=False)
|
||||
|
||||
op.add_column('jobs', sa.Column('new_service_id', sa.Integer, nullable=True))
|
||||
op.execute('update jobs '\
|
||||
'set new_service_id = (SELECT old_id from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('jobs', 'service_id')
|
||||
op.alter_column('jobs', 'new_service_id', new_column_name='service_id', nullable=False)
|
||||
|
||||
op.add_column('api_key', sa.Column('new_service_id', sa.Integer, nullable=True))
|
||||
op.execute('update api_key '\
|
||||
'set new_service_id = (SELECT old_id from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('api_key', 'service_id')
|
||||
op.alter_column('api_key', 'new_service_id', new_column_name='service_id', nullable=False)
|
||||
|
||||
op.add_column('templates', sa.Column('new_service_id', sa.Integer, nullable=True))
|
||||
op.execute('update templates '\
|
||||
'set new_service_id = (SELECT old_id from services where service_id = services.id)')
|
||||
|
||||
op.drop_column('templates', 'service_id')
|
||||
op.alter_column('templates', 'new_service_id', new_column_name='service_id', nullable=False)
|
||||
|
||||
op.drop_constraint('services_pkey', 'services')
|
||||
|
||||
op.alter_column('services', 'id', new_column_name='queue_name', nullable=False)
|
||||
op.alter_column('services', 'old_id', new_column_name='id', nullable=True)
|
||||
|
||||
op.create_primary_key('services_pkey', 'services', ['id'])
|
||||
|
||||
op.create_foreign_key('user_to_service_service_id_fkey', 'user_to_service', 'services', ['service_id'], ['id'])
|
||||
op.create_foreign_key('api_key_service_id_fkey', 'api_key', 'services', ['service_id'], ['id'])
|
||||
op.create_foreign_key('jobs_service_id_fkey', 'jobs', 'services', ['service_id'], ['id'])
|
||||
op.create_foreign_key('templates_service_id_fkey', 'templates', 'services', ['service_id'], ['id'])
|
||||
|
||||
op.create_index(op.f('ix_api_key_service_id'), 'api_key', ['service_id'], unique=False)
|
||||
op.create_unique_constraint('uix_service_to_key_name', 'api_key', ['service_id', 'name'])
|
||||
op.create_index(op.f('ix_jobs_service_id'), 'jobs', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_templates_service_id'), 'templates', ['service_id'], unique=False)
|
||||
|
||||
### end Alembic commands ###
|
||||
@@ -1,34 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0012_add_status_to_job
|
||||
Revises: 0011_uuid_service_id
|
||||
Create Date: 2016-02-02 11:25:34.402864
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0012_add_status_to_job'
|
||||
down_revision = '0011_uuid_service_id'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
job_status_types = sa.Enum('pending', 'in progress', 'finished', name='job_status_types')
|
||||
job_status_types.create(op.get_bind())
|
||||
op.add_column('jobs', sa.Column('status', job_status_types, nullable=True))
|
||||
op.get_bind()
|
||||
op.execute("update jobs set status='pending'")
|
||||
op.alter_column('jobs', 'status', nullable=False)
|
||||
|
||||
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('jobs', 'status')
|
||||
op.execute('DROP TYPE job_status_types')
|
||||
### end Alembic commands ###
|
||||
@@ -1,47 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0013_add_notifications
|
||||
Revises: 0012_add_status_to_job
|
||||
Create Date: 2016-02-09 11:14:46.708551
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0013_add_notifications'
|
||||
down_revision = '0012_add_status_to_job'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('notifications',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('to', sa.String(), nullable=False),
|
||||
sa.Column('job_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('template_id', sa.BigInteger(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('status', sa.Enum('sent', 'failed', name='notification_status_types'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], ),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_notifications_job_id'), 'notifications', ['job_id'], unique=False)
|
||||
op.create_index(op.f('ix_notifications_service_id'), 'notifications', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_notifications_template_id'), 'notifications', ['template_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_notifications_template_id'), table_name='notifications')
|
||||
op.drop_index(op.f('ix_notifications_service_id'), table_name='notifications')
|
||||
op.drop_index(op.f('ix_notifications_job_id'), table_name='notifications')
|
||||
op.drop_table('notifications')
|
||||
op.get_bind()
|
||||
op.execute("drop type notification_status_types")
|
||||
### end Alembic commands ###
|
||||
@@ -1,30 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0014_job_id_nullable
|
||||
Revises: 0013_add_notifications
|
||||
Create Date: 2016-02-10 10:57:39.414061
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0014_job_id_nullable'
|
||||
down_revision = '0013_add_notifications'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('notifications', 'job_id',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=True)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('notifications', 'job_id',
|
||||
existing_type=postgresql.UUID(),
|
||||
nullable=False)
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0015_add_permissions
|
||||
Revises: 0014_job_id_nullable
|
||||
Create Date: 2016-02-19 14:16:59.359493
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0015_add_permissions'
|
||||
down_revision = '0014_job_id_nullable'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('users', sa.Column('permissions', postgresql.ARRAY(sa.String()), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('users', 'permissions')
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0015_add_subject_line
|
||||
Revises: 0015_add_permissions
|
||||
Create Date: 2016-02-18 09:43:29.282804
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0015_add_subject_line'
|
||||
down_revision = '0015_add_permissions'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
op.add_column('templates', sa.Column('subject', sa.Text(), nullable=True))
|
||||
op.create_unique_constraint(None, 'templates', ['subject'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
op.drop_constraint(None, 'templates', type_='unique')
|
||||
op.drop_column('templates', 'subject')
|
||||
@@ -1,23 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0016_add_email_from
|
||||
Revises: 0015_add_subject_line
|
||||
Create Date: 2016-02-18 11:25:37.915137
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0016_add_email_from'
|
||||
down_revision = '0015_add_subject_line'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('services', sa.Column('email_from', sa.Text(), nullable=True))
|
||||
op.execute("UPDATE services SET email_from=name")
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('services', 'email_from')
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0017_emailfrom_notnull
|
||||
Revises: 0016_add_email_from
|
||||
Create Date: 2016-02-18 11:41:25.753694
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0017_emailfrom_notnull'
|
||||
down_revision = '0016_add_email_from'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('services', 'email_from',
|
||||
existing_type=sa.TEXT(),
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('services', 'email_from',
|
||||
existing_type=sa.TEXT(),
|
||||
nullable=True)
|
||||
@@ -1,22 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0018_unique_emailfrom
|
||||
Revises: 0017_emailfrom_notnull
|
||||
Create Date: 2016-02-18 11:42:18.246280
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0018_unique_emailfrom'
|
||||
down_revision = '0017_emailfrom_notnull'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_unique_constraint(None, 'services', ['email_from'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint(None, 'services', type_='unique')
|
||||
@@ -1,22 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0019_unique_servicename
|
||||
Revises: 0018_unique_emailfrom
|
||||
Create Date: 2016-02-18 11:45:29.102891
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0019_unique_servicename'
|
||||
down_revision = '0018_unique_emailfrom'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_unique_constraint(None, 'services', ['name'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint(None, 'services', type_='unique')
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0020_email_has_subject
|
||||
Revises: 0019_unique_servicename
|
||||
Create Date: 2016-02-18 11:45:29.102891
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0020_email_has_subject'
|
||||
down_revision = '0019_unique_servicename'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_check_constraint(
|
||||
"ch_email_template_has_subject",
|
||||
"templates",
|
||||
"((template_type='email' and subject is not null) or (template_type!='email' and subject is null))"
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint('ch_email_template_has_subject', 'templates', type_='check')
|
||||
@@ -1,29 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0021_add_job_metadata
|
||||
Revises: 0020_email_has_subject
|
||||
Create Date: 2016-02-22 12:33:02.360780
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0021_add_job_metadata'
|
||||
down_revision = '0020_email_has_subject'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('jobs', sa.Column('notification_count', sa.Integer(), nullable=True))
|
||||
op.get_bind()
|
||||
op.execute('update jobs set notification_count = 0')
|
||||
op.alter_column('jobs', 'notification_count', nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('jobs', 'notification_count')
|
||||
### end Alembic commands ###
|
||||
@@ -1,42 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0022_add_invite_users
|
||||
Revises: 0021_add_job_metadata
|
||||
Create Date: 2016-02-23 16:41:40.481468
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0022_add_invite_users'
|
||||
down_revision = '0021_add_job_metadata'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('invited_users',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('email_address', sa.String(length=255), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('_token', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('status', sa.Enum('pending', 'accepted', 'cancelled', name='invited_users_status_types'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_invited_users_service_id'), 'invited_users', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_invited_users_user_id'), 'invited_users', ['user_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_invited_users_user_id'), table_name='invited_users')
|
||||
op.drop_index(op.f('ix_invited_users_service_id'), table_name='invited_users')
|
||||
op.drop_table('invited_users')
|
||||
op.execute('DROP TYPE invited_users_status_types')
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0023_drop_token
|
||||
Revises: 0022_add_invite_users
|
||||
Create Date: 2016-02-24 13:58:04.440296
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0023_drop_token'
|
||||
down_revision = '0022_add_invite_users'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('invited_users', '_token')
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('invited_users', sa.Column('_token', sa.VARCHAR(), autoincrement=False, nullable=False))
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0024_uix_user_to_service
|
||||
Revises: 0023_drop_token
|
||||
Create Date: 2016-02-25 11:15:06.088508
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0024_uix_user_to_service'
|
||||
down_revision = '0023_drop_token'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_unique_constraint('uix_user_to_service', 'user_to_service', ['user_id', 'service_id'])
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('uix_user_to_service', 'user_to_service', type_='unique')
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0025_add_processing_dates
|
||||
Revises: 0024_uix_user_to_service
|
||||
Create Date: 2016-02-24 17:15:47.457200
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0025_add_processing_dates'
|
||||
down_revision = '0024_uix_user_to_service'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('jobs', sa.Column('processing_finished', sa.DateTime(), nullable=True))
|
||||
op.add_column('jobs', sa.Column('processing_started', sa.DateTime(), nullable=True))
|
||||
op.add_column('notifications', sa.Column('sent_at', sa.DateTime(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('notifications', 'sent_at')
|
||||
op.drop_column('jobs', 'processing_started')
|
||||
op.drop_column('jobs', 'processing_finished')
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0026_add_sender
|
||||
Revises: 0025_add_processing_dates
|
||||
Create Date: 2016-02-24 17:18:21.942772
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0026_add_sender'
|
||||
down_revision = '0025_add_processing_dates'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('notifications', sa.Column('sent_by', sa.String(), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('notifications', 'sent_by')
|
||||
### end Alembic commands ###
|
||||
@@ -1,42 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0027_add_service_permission
|
||||
Revises: 0026_add_sender
|
||||
Create Date: 2016-02-26 10:33:20.536362
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0027_add_service_permission'
|
||||
down_revision = '0026_add_sender'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('permissions',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('permission', sa.String(length=255), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('service_id', 'user_id', 'permission', name='uix_service_user_permission')
|
||||
)
|
||||
op.create_index(op.f('ix_permissions_service_id'), 'permissions', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_permissions_user_id'), 'permissions', ['user_id'], unique=False)
|
||||
op.drop_column('users', 'permissions')
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('users', sa.Column('permissions', postgresql.ARRAY(VARCHAR()), autoincrement=False, nullable=True))
|
||||
op.drop_index(op.f('ix_permissions_user_id'), table_name='permissions')
|
||||
op.drop_index(op.f('ix_permissions_service_id'), table_name='permissions')
|
||||
op.drop_table('permissions')
|
||||
### end Alembic commands ###
|
||||
@@ -1,44 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0028_add_default_permissions
|
||||
Revises: 0027_add_service_permission
|
||||
Create Date: 2016-02-26 10:33:20.536362
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0028_add_default_permissions'
|
||||
down_revision = '0027_add_service_permission'
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
user_services = conn.execute("SELECT * FROM user_to_service").fetchall()
|
||||
for entry in user_services:
|
||||
id_ = uuid.uuid4()
|
||||
created_at = datetime.now().isoformat().replace('T', ' ')
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', 'manage_service', '{}')").format(id_, entry[0], entry[1], created_at))
|
||||
id_ = uuid.uuid4()
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', 'send_messages', '{}')").format(id_, entry[0], entry[1], created_at))
|
||||
id_ = uuid.uuid4()
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', 'manage_api_keys', '{}')").format(id_, entry[0], entry[1], created_at))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("DELETE FROM permissions")
|
||||
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0029_add_permissions_to_invite
|
||||
Revises: 0028_add_default_permissions
|
||||
Create Date: 2016-02-26 16:17:30.612924
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0029_add_permissions_to_invite'
|
||||
down_revision = '0028_add_default_permissions'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('invited_users', sa.Column('permissions', sa.String(), nullable=False))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('invited_users', 'permissions')
|
||||
### end Alembic commands ###
|
||||
@@ -1,36 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0030_add_template_permission
|
||||
Revises: 0029_add_permissions_to_invite
|
||||
Create Date: 2016-02-26 10:33:20.536362
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0030_add_template_permission'
|
||||
down_revision = '0029_add_permissions_to_invite'
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
user_services = conn.execute("SELECT * FROM user_to_service").fetchall()
|
||||
for entry in user_services:
|
||||
id_ = uuid.uuid4()
|
||||
created_at = datetime.now().isoformat().replace('T', ' ')
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', 'manage_templates', '{}')").format(id_, entry[0], entry[1], created_at))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("DELETE FROM permissions where permission='manage_templates'")
|
||||
|
||||
### end Alembic commands ###
|
||||
@@ -1,41 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0031_add_manage_team_permission
|
||||
Revises: 0030_add_template_permission
|
||||
Create Date: 2016-02-26 10:33:20.536362
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0031_add_manage_team_permission'
|
||||
down_revision = '0030_add_template_permission'
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
user_services = conn.execute("SELECT * FROM user_to_service").fetchall()
|
||||
for entry in user_services:
|
||||
id_ = uuid.uuid4()
|
||||
created_at = datetime.now().isoformat().replace('T', ' ')
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', 'manage_team', '{}')").format(id_, entry[0], entry[1], created_at))
|
||||
id_ = uuid.uuid4()
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', 'view_activity', '{}')").format(id_, entry[0], entry[1], created_at))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("DELETE FROM permissions where permission='manage_team'")
|
||||
conn.execute("DELETE FROM permissions where permission='view_activity'")
|
||||
|
||||
### end Alembic commands ###
|
||||
@@ -1,48 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0032_update_permission_to_enum
|
||||
Revises: 0031_add_manage_team_permission
|
||||
Create Date: 2016-03-01 17:08:12.184393
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0032_update_permission_to_enum'
|
||||
down_revision = '0031_add_manage_team_permission'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
permissions = conn.execute("SELECT id, permission FROM permissions").fetchall()
|
||||
op.drop_constraint('uix_service_user_permission', 'permissions', type_='unique')
|
||||
op.drop_column('permissions', 'permission')
|
||||
permission_types = sa.Enum('manage_service', 'send_messages', 'manage_api_keys', 'manage_templates', 'manage_team', 'view_activity', name='permission_types')
|
||||
permission_types.create(op.get_bind())
|
||||
op.add_column('permissions', sa.Column('permission', permission_types, nullable=True))
|
||||
for p in permissions:
|
||||
conn.execute("UPDATE permissions SET permission='{}' WHERE id='{}'".format(str(p[1]), str(p[0])))
|
||||
op.create_unique_constraint('uix_service_user_permission', 'permissions', ['service_id', 'user_id', 'permission'])
|
||||
op.alter_column('permissions', 'permission', nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
permissions = conn.execute("SELECT id, permission FROM permissions").fetchall()
|
||||
op.drop_constraint('uix_service_user_permission', 'permissions', type_='unique')
|
||||
op.drop_column('permissions', 'permission')
|
||||
try:
|
||||
sa.Enum(name='permission_types').drop(conn, checkfirst=False)
|
||||
except:
|
||||
pass
|
||||
op.add_column('permissions', sa.Column('permission', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
|
||||
for p in permissions:
|
||||
conn.execute("UPDATE permissions SET permission='{}' WHERE ID='{}'".format(str(p[1]), str(p[0])))
|
||||
op.create_unique_constraint('uix_service_user_permission', 'permissions', ['service_id', 'user_id', 'permission'])
|
||||
op.alter_column('permissions', 'permission', nullable=False)
|
||||
### end Alembic commands ###
|
||||
@@ -1,81 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0033_correct_permission_enums
|
||||
Revises: 0032_update_permission_to_enum
|
||||
Create Date: 2016-03-02 15:00:25.358153
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0033_correct_permission_enums'
|
||||
down_revision = '0032_update_permission_to_enum'
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def add_default_permissions(conn, permissions):
|
||||
user_services = conn.execute("SELECT * FROM user_to_service").fetchall()
|
||||
for entry in user_services:
|
||||
for p in permissions:
|
||||
id_ = uuid.uuid4()
|
||||
created_at = datetime.now().isoformat().replace('T', ' ')
|
||||
conn.execute((
|
||||
"INSERT INTO permissions (id, user_id, service_id, permission, created_at)"
|
||||
" VALUES ('{}', '{}', '{}', '{}', '{}')").format(id_, entry[0], entry[1], p, created_at))
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Since there are no specific permissions set for services yet
|
||||
# we can just remove all and re-add all.
|
||||
### commands auto generated by Nick - please adjust! ###
|
||||
new_permissions = ['manage_users',
|
||||
'manage_templates',
|
||||
'manage_settings',
|
||||
'send_texts',
|
||||
'send_emails',
|
||||
'send_letters',
|
||||
'manage_api_keys',
|
||||
'access_developer_docs']
|
||||
conn = op.get_bind()
|
||||
conn.execute("DELETE FROM permissions")
|
||||
op.drop_constraint('uix_service_user_permission', 'permissions', type_='unique')
|
||||
op.drop_column('permissions', 'permission')
|
||||
try:
|
||||
sa.Enum(name='permission_types').drop(conn, checkfirst=False)
|
||||
except:
|
||||
pass
|
||||
permission_types = sa.Enum(*new_permissions, name='permission_types')
|
||||
permission_types.create(op.get_bind())
|
||||
op.add_column('permissions', sa.Column('permission', permission_types, nullable=False))
|
||||
add_default_permissions(conn, new_permissions)
|
||||
op.alter_column('permissions', 'permission', nullable=False)
|
||||
op.create_unique_constraint('uix_service_user_permission', 'permissions', ['service_id', 'user_id', 'permission'])
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Nick - please adjust! ###
|
||||
old_permissions = ['manage_service',
|
||||
'send_messages',
|
||||
'manage_api_keys',
|
||||
'manage_templates',
|
||||
'manage_team',
|
||||
'view_activity']
|
||||
conn = op.get_bind()
|
||||
conn.execute("DELETE FROM permissions")
|
||||
op.drop_constraint('uix_service_user_permission', 'permissions', type_='unique')
|
||||
op.drop_column('permissions', 'permission')
|
||||
try:
|
||||
sa.Enum(name='permission_types').drop(conn, checkfirst=False)
|
||||
except:
|
||||
pass
|
||||
permission_types = sa.Enum(*old_permissions, name='permission_types')
|
||||
permission_types.create(op.get_bind())
|
||||
op.add_column('permissions', sa.Column('permission', permission_types, nullable=False))
|
||||
add_default_permissions(conn, old_permissions)
|
||||
op.alter_column('permissions', 'permission', nullable=False)
|
||||
op.create_unique_constraint('uix_service_user_permission', 'permissions', ['service_id', 'user_id', 'permission'])
|
||||
### end Alembic commands ###
|
||||
@@ -1,26 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0034_job_sent_count
|
||||
Revises: 0033_correct_permission_enums
|
||||
Create Date: 2016-03-04 13:44:32.217058
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0034_job_sent_count'
|
||||
down_revision = '0033_correct_permission_enums'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('jobs', sa.Column('notifications_sent', sa.Integer(), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('jobs', 'notifications_sent')
|
||||
### end Alembic commands ###
|
||||
@@ -1,27 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0035_default_sent_count
|
||||
Revises: 0034_job_sent_count
|
||||
Create Date: 2016-03-08 09:08:55.721654
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0035_default_sent_count'
|
||||
down_revision = '0034_job_sent_count'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute('update jobs set notifications_sent = notification_count')
|
||||
op.alter_column('jobs', 'notifications_sent',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('jobs', 'notifications_sent',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
@@ -1,37 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0036_notification_stats
|
||||
Revises: 0035_default_sent_count
|
||||
Create Date: 2016-03-08 11:16:25.659463
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0036_notification_stats'
|
||||
down_revision = '0035_default_sent_count'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
op.create_table('notification_statistics',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('day', sa.String(length=255), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('emails_requested', sa.BigInteger(), nullable=False),
|
||||
sa.Column('emails_delivered', sa.BigInteger(), nullable=True),
|
||||
sa.Column('emails_error', sa.BigInteger(), nullable=True),
|
||||
sa.Column('sms_requested', sa.BigInteger(), nullable=False),
|
||||
sa.Column('sms_delivered', sa.BigInteger(), nullable=True),
|
||||
sa.Column('sms_error', sa.BigInteger(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('service_id', 'day', name='uix_service_to_day')
|
||||
)
|
||||
op.create_index(op.f('ix_service_notification_stats_service_id'), 'notification_statistics', ['service_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_service_notification_stats_service_id'), table_name='notification_statistics')
|
||||
op.drop_table('notification_statistics')
|
||||
@@ -1,30 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0037_more_job_states
|
||||
Revises: 0036_notification_stats
|
||||
Create Date: 2016-03-08 11:16:25.659463
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0037_more_job_states'
|
||||
down_revision = '0036_notification_stats'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
op.drop_column('jobs', 'status')
|
||||
op.execute('DROP TYPE job_status_types')
|
||||
job_status_types = sa.Enum('pending', 'in progress', 'finished', 'sending limits exceeded', name='job_status_types')
|
||||
job_status_types.create(op.get_bind())
|
||||
op.add_column('jobs', sa.Column('status', job_status_types, nullable=True))
|
||||
op.get_bind()
|
||||
op.execute("update jobs set status='finished'")
|
||||
op.alter_column('jobs', 'status', nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('jobs', 'status')
|
||||
op.execute('DROP TYPE job_status_types')
|
||||
@@ -1,21 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0038_reduce_limits
|
||||
Revises: 0037_more_job_states
|
||||
Create Date: 2016-03-08 11:16:25.659463
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0038_reduce_limits'
|
||||
down_revision = '0037_more_job_states'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute('update services set "limit" = 50')
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -1,31 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0039_more_notification_states
|
||||
Revises: 0038_reduce_limits
|
||||
Create Date: 2016-03-08 11:16:25.659463
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0039_more_notification_states'
|
||||
down_revision = '0038_reduce_limits'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_column('notifications', 'status')
|
||||
op.execute('DROP TYPE notification_status_types')
|
||||
notification_status_types = sa.Enum('sent', 'delivered', 'failed', 'complaint', 'bounce', name='notification_status_types')
|
||||
notification_status_types.create(op.get_bind())
|
||||
op.add_column('notifications', sa.Column('status', notification_status_types, nullable=True))
|
||||
op.get_bind()
|
||||
op.execute("update notifications set status='delivered'")
|
||||
op.alter_column('notifications', 'status', nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('notifications', 'status')
|
||||
op.execute('DROP TYPE notification_status_types')
|
||||
@@ -1,24 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0040_add_reference
|
||||
Revises: 0039_more_notification_states
|
||||
Create Date: 2016-03-11 09:15:57.900192
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0040_add_reference'
|
||||
down_revision = '0039_more_notification_states'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('notifications', sa.Column('reference', sa.String(), nullable=True))
|
||||
op.create_index(op.f('ix_notifications_reference'), 'notifications', ['reference'], unique=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_notifications_reference'), table_name='notifications')
|
||||
op.drop_column('notifications', 'reference')
|
||||
@@ -1,33 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0041_platform_admin
|
||||
Revises: 0040_add_reference
|
||||
Create Date: 2016-03-16 16:33:15.279429
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0041_platform_admin'
|
||||
down_revision = '0040_add_reference'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_index(op.f('ix_notification_statistics_service_id'), 'notification_statistics', ['service_id'], unique=False)
|
||||
op.drop_index('ix_service_notification_stats_service_id', table_name='notification_statistics')
|
||||
op.add_column('users', sa.Column('platform_admin', sa.Boolean(), nullable=True, default=False))
|
||||
op.get_bind()
|
||||
op.execute('update users set platform_admin = False')
|
||||
op.alter_column('users', 'platform_admin', nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('users', 'platform_admin')
|
||||
op.create_index('ix_service_notification_stats_service_id', 'notification_statistics', ['service_id'], unique=False)
|
||||
op.drop_index(op.f('ix_notification_statistics_service_id'), table_name='notification_statistics')
|
||||
### end Alembic commands ###
|
||||
@@ -1,45 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0042_default_stats_to_zero
|
||||
Revises: 0041_platform_admin
|
||||
Create Date: 2016-03-17 11:09:17.906910
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0042_default_stats_to_zero'
|
||||
down_revision = '0041_platform_admin'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.get_bind()
|
||||
op.execute('update notification_statistics set emails_delivered = 0 where emails_delivered is Null')
|
||||
op.execute('update notification_statistics set emails_error = 0 where emails_error is Null')
|
||||
op.execute('update notification_statistics set sms_delivered = 0 where sms_delivered is Null')
|
||||
op.execute('update notification_statistics set sms_error = 0 where sms_error is Null')
|
||||
op.alter_column('notification_statistics', 'emails_requested', server_default='0')
|
||||
op.alter_column('notification_statistics', 'emails_delivered', server_default='0', nullable=False)
|
||||
op.alter_column('notification_statistics', 'emails_error', server_default='0', nullable=False)
|
||||
op.alter_column('notification_statistics', 'sms_requested', server_default='0')
|
||||
op.alter_column('notification_statistics', 'sms_delivered', server_default='0', nullable=False)
|
||||
op.alter_column('notification_statistics', 'sms_error', server_default='0', nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('notification_statistics', 'emails_requested', server_default=None)
|
||||
op.alter_column('notification_statistics', 'emails_delivered', server_default=None, nullable=True)
|
||||
op.alter_column('notification_statistics', 'emails_error', server_default=None, nullable=True)
|
||||
op.alter_column('notification_statistics', 'sms_requested', server_default=None)
|
||||
op.alter_column('notification_statistics', 'sms_delivered', server_default=None, nullable=True)
|
||||
op.alter_column('notification_statistics', 'sms_error', server_default=None, nullable=True)
|
||||
op.execute('update notification_statistics set emails_delivered = Null where emails_delivered = 0')
|
||||
op.execute('update notification_statistics set emails_error = Null where emails_error = 0')
|
||||
op.execute('update notification_statistics set sms_delivered = Null where sms_delivered = 0')
|
||||
op.execute('update notification_statistics set sms_error = Null where sms_error = 0')
|
||||
### end Alembic commands ###
|
||||
@@ -1,47 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0043_add_view_activity
|
||||
Revises: 0042_default_stats_to_zero
|
||||
Create Date: 2016-03-29 13:46:36.219549
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
import uuid
|
||||
|
||||
revision = '0043_add_view_activity'
|
||||
down_revision = '0042_default_stats_to_zero'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute('COMMIT')
|
||||
conn.execute("alter type permission_types add value IF NOT EXISTS 'view_activity'")
|
||||
user_services = conn.execute("SELECT * FROM user_to_service where user_id "
|
||||
"not in (select user_id from permissions "
|
||||
"where permission='view_activity')").fetchall()
|
||||
for user_service in user_services:
|
||||
conn.execute(
|
||||
"insert into permissions (id, service_id, user_id, created_at, permission) "
|
||||
"values('{0}', '{1}', {2}, now(), 'view_activity')".format(
|
||||
uuid.uuid4(), user_service.service_id, user_service.user_id))
|
||||
conn.execute("delete from permissions where permission = 'access_developer_docs'")
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("delete from permissions where permission = 'view_activity'")
|
||||
conn.execute('COMMIT')
|
||||
conn.execute("alter type permission_types add value IF NOT EXISTS 'access_developer_docs'")
|
||||
manage_api_key_users = conn.execute("SELECT * FROM permissions where permission='manage_api_keys'").fetchall()
|
||||
for user_service in manage_api_key_users:
|
||||
conn.execute(
|
||||
"insert into permissions (id, service_id, user_id, created_at, permission) "
|
||||
"values('{0}', '{1}', {2}, now(), 'access_developer_docs')".format(
|
||||
uuid.uuid4(), user_service.service_id, user_service.user_id))
|
||||
### end Alembic commands ###
|
||||
@@ -1,42 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0044_add_template_stats
|
||||
Revises: 0043_add_view_activity
|
||||
Create Date: 2016-03-31 12:05:19.630792
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0044_add_template_stats'
|
||||
down_revision = '0043_add_view_activity'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('template_statistics',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('template_id', sa.BigInteger(), nullable=False),
|
||||
sa.Column('usage_count', sa.BigInteger(), nullable=False),
|
||||
sa.Column('day', sa.Date(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_template_statistics_day'), 'template_statistics', ['day'], unique=False)
|
||||
op.create_index(op.f('ix_template_statistics_service_id'), 'template_statistics', ['service_id'], unique=False)
|
||||
op.create_index(op.f('ix_template_statistics_template_id'), 'template_statistics', ['template_id'], unique=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_template_statistics_template_id'), table_name='template_statistics')
|
||||
op.drop_index(op.f('ix_template_statistics_service_id'), table_name='template_statistics')
|
||||
op.drop_index(op.f('ix_template_statistics_day'), table_name='template_statistics')
|
||||
op.drop_table('template_statistics')
|
||||
### end Alembic commands ###
|
||||
@@ -1,32 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0045_template_stats_update_time
|
||||
Revises: 0044_add_template_stats
|
||||
Create Date: 2016-04-05 14:32:45.165755
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0045_template_stats_update_time'
|
||||
down_revision = '0044_add_template_stats'
|
||||
|
||||
import datetime
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import table, column
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('template_statistics', sa.Column('updated_at', sa.DateTime(), nullable=True))
|
||||
updated_at = table('template_statistics', column('updated_at'))
|
||||
op.execute(updated_at.update().values(updated_at=datetime.datetime.utcnow()))
|
||||
op.alter_column('template_statistics', 'updated_at', nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('template_statistics', 'updated_at')
|
||||
### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0046_remove_bucketname
|
||||
Revises: 0045_template_stats_update_time
|
||||
Create Date: 2016-04-07 12:23:55.050714
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0046_remove_bucketname'
|
||||
down_revision = '0045_template_stats_update_time'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('jobs', 'file_name')
|
||||
op.drop_column('jobs', 'bucket_name')
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('jobs', sa.Column('bucket_name', sa.VARCHAR(), autoincrement=False, nullable=False))
|
||||
op.add_column('jobs', sa.Column('file_name', sa.VARCHAR(), autoincrement=False, nullable=False))
|
||||
### end Alembic commands ###
|
||||
Reference in New Issue
Block a user