I have an existing app that I want to add some features to, so I created
the new models and then ran --autogenerate and it created me a revision
file where in downgrade it was creating all my files and in upgrade it was
dropping the tables. That was backwards from what I expected, since my
database didn't have the tables but the model did.
Am I thinking about this in the wrong way?
Here is the generated file:
"""added presentation table
Revision ID: 29b24a536dc5
Revises: None
Create Date: 2012-03-24 15:03:18.268581
"""
# revision identifiers, used by Alembic.
revision = '29b24a536dc5'
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.drop_table(u'presentation')
op.drop_table(u'file')
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table(u'presentation',
sa.Column(u'pk', sa.INTEGER(),
server_default='nextval('presentation_pk_seq'::regclass)', nullable=False),
sa.Column(u'name', sa.TEXT(), nullable=True),
sa.Column(u'description', sa.TEXT(), nullable=True),
sa.Column(u'presenter', sa.TEXT(), nullable=True),
sa.Column(u'date', postgresql.TIMESTAMP(), nullable=True),
sa.PrimaryKeyConstraint(u'pk', name=u'presentation_pkey')
)
op.create_table(u'file',
sa.Column(u'pk', sa.INTEGER(),
server_default='nextval('file_pk_seq'::regclass)', nullable=False),
sa.Column(u'user_pk', sa.INTEGER(), nullable=False),
sa.Column(u'mimetype', sa.TEXT(), nullable=False),
sa.Column(u'uid', sa.TEXT(), nullable=False),
sa.Column(u'filename', sa.TEXT(), nullable=False),
sa.Column(u'size', sa.INTEGER(), nullable=False),
sa.ForeignKeyConstraint(['user_pk'], [u'user.pk'],
name=u'file_user_pk_fkey'),
sa.PrimaryKeyConstraint(u'pk', name=u'file_pkey')
)
### end Alembic commands ###
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/J0nrs7KxckgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.