"""Add role seed data for flask-security

Revision ID: 7b2d863b105
Revises: 2a3fee7de8d4
Create Date: 2015-07-02 10:48:35.805882

"""

# revision identifiers, used by Alembic.
revision = '7b2d863b105'
down_revision = '2a3fee7de8d4'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    role_table = sa.table('role',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    )
    op.bulk_insert(role_table, [
        {'id': 2, 'name': 'product_category_view', 'description': 'View product categories'},
        {'id': 3, 'name': 'product_category_create', 'description': 'Create product category'},
        {'id': 4, 'name': 'product_category_edit', 'description': 'Edit product category'},
        {'id': 5, 'name': 'product_category_delete', 'description': 'Delete product category'},
        {'id': 6, 'name': 'sales_order_view', 'description': 'View sales orders'},
        {'id': 7, 'name': 'sales_order_create', 'description': 'Create sales order'},
        {'id': 8, 'name': 'sales_order_edit', 'description': 'Edit sales order'},
        {'id': 9, 'name': 'sales_order_delete', 'description': 'Delete sales order'},
        {'id': 10, 'name': 'purchase_order_view', 'description': 'View purchase orders'},
        {'id': 11, 'name': 'purchase_order_create', 'description': 'Create purchase order'},
        {'id': 12, 'name': 'purchase_order_edit', 'description': 'Edit purchase order'},
        {'id': 13, 'name': 'purchase_order_delete', 'description': 'Delete purchase order'},
        {'id': 14, 'name': 'expense_view', 'description': 'View expenses'},
        {'id': 15, 'name': 'expense_create', 'description': 'Create expense'},
        {'id': 16, 'name': 'expense_edit', 'description': 'Edit expense'},
        {'id': 17, 'name': 'expense_delete', 'description': 'Delete expense'},
        {'id': 18, 'name': 'incoming_view', 'description': 'View incoming'},
        {'id': 19, 'name': 'incoming_create', 'description': 'Create incoming'},
        {'id': 20, 'name': 'incoming_edit', 'description': 'Edit incoming'},
        {'id': 21, 'name': 'incoming_delete', 'description': 'Delete incoming'},
        {'id': 22, 'name': 'supplier_view', 'description': 'View suppliers'},
        {'id': 23, 'name': 'supplier_create', 'description': 'Create supplier'},
        {'id': 24, 'name': 'supplier_edit', 'description': 'Edit supplier'},
        {'id': 25, 'name': 'supplier_delete', 'description': 'Delete supplier'},
        {'id': 26, 'name': 'product_view', 'description': 'View products'},
        {'id': 27, 'name': 'product_create', 'description': 'Create product'},
        {'id': 28, 'name': 'product_edit', 'description': 'Edit product'},
        {'id': 29, 'name': 'product_delete', 'description': 'Delete product'},
        {'id': 30, 'name': 'enum_values_view', 'description': 'View enum values'},
        {'id': 31, 'name': 'enum_values_create', 'description': 'Create enum value'},
        {'id': 32, 'name': 'enum_values_edit', 'description': 'Edit enum value'},
        {'id': 33, 'name': 'enum_values_delete', 'description': 'Delete enum value'},
        {'id': 34, 'name': 'preference_view', 'description': 'View system preference'},
        {'id': 35, 'name': 'preference_edit', 'description': 'Update system preference'},
        {'id': 36, 'name': 'user_view', 'description': 'View user'},
        {'id': 37, 'name': 'user_create', 'description': 'Create user'},
        {'id': 38, 'name': 'user_edit', 'description': 'Edit user'},
        {'id': 39, 'name': 'user_delete', 'description': 'Delete user'},
        {'id': 40, 'name': 'role_view', 'description': 'View roles'},
        {'id': 41, 'name': 'role_create', 'description': 'Create role'},
        {'id': 42, 'name': 'role_edit', 'description': 'Edit role'},
        {'id': 43, 'name': 'role_delete', 'description': 'Delete role'},
    ],multiinsert=False)
    from sqlalchemy.sql import text
    op.get_bind().execute(text("ALTER SEQUENCE role_id_seq RESTART WITH 44;"))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    pass
    ### end Alembic commands ###
