"""Added file table

Revision ID: 1403ac1fa61e
Revises: 4d5e42cec5bc
Create Date: 2013-08-14 23:29:09.622395

"""

# revision identifiers, used by Alembic.
revision = '1403ac1fa61e'
down_revision = '4d5e42cec5bc'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('files',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uid', sa.Integer(), nullable=True),
        sa.Column('gid', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['gid'], ['usergroups.id'], ),
        sa.ForeignKeyConstraint(['uid'], ['users.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    op.execute("INSERT into modules (id, name, clazzpath, label, label_plural, display) VALUES (8, 'files', 'ringo.model.file.File', 'File', 'Files', 'header-menu')")
    op.execute("insert into actions (id, mid, name, url, icon, description) values ('27', '8', 'List', 'list', 'icon-list-alt', NULL)")
    op.execute("insert into actions (id, mid, name, url, icon, description) values ('28', '8', 'Create', 'create', ' icon-plus', NULL)")
    op.execute("insert into actions (id, mid, name, url, icon, description) values ('29', '8', 'Read', 'read/{id}', 'icon-eye-open', NULL)")
    op.execute("insert into actions (id, mid, name, url, icon, description) values ('30', '8', 'Update', 'update/{id}', 'icon-edit', NULL)")
    op.execute("insert into actions (id, mid, name, url, icon, description) values ('31', '8', 'Delete', 'delete/{id}', 'icon-trash', NULL)")
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('files')
    op.execute("DELETE from modules where id = 8")
    op.execute("DELETE from actions where id = 27")
    op.execute("DELETE from actions where id = 28")
    op.execute("DELETE from actions where id = 29")
    op.execute("DELETE from actions where id = 30")
    op.execute("DELETE from actions where id = 31")
    ### end Alembic commands ###
