If I use create_foreign_key then I end up with sequence tables in my 
database...

def upgrade():
    op.drop_constraint('session_server_fkey', 'session', 'foreignkey')
    op.drop_constraint('session_app_fkey', 'session', 'foreignkey')


def downgrade():
    op.create_foreign_key(
        'session_server_fkey', 'session', 'server', ['server'], ['id'])
    op.create_foreign_key(
        'session_app_fkey', 'session', 'app', ['server'], ['id'])


On Thursday, November 14, 2013 11:40:43 AM UTC+1, Simon King wrote:
>
> On Thu, Nov 14, 2013 at 8:47 AM, jonas geiregat 
> <geireg...@gmail.com<javascript:>> 
> wrote: 
> > I have a table called "session" which has foreign key constraints. I 
> removed 
> > them and auto generated a migration script. The upgrade function is 
> > populated as expected but the downgrade function isn't. I searched 
> through 
> > the available operations but can't find what i need. 
> > 
> > The create_foreign_key creates a new table which I don't want. The 
> > create_unique_constraint and create_check_constraint are also not what 
> I'm 
> > looking for. I guess alter_table is left but I don't know how to use it. 
> > Should I fall back to sql alchemy operations? 
> > 
> > 
> > def upgrade(): 
> >     op.drop_constraint('session_server_fkey', 'session', 'foreignkey') 
> >     op.drop_constraint('session_app_fkey', 'session', 'foreignkey') 
> > 
> > 
> > def downgrade(): 
> >     pass 
> > 
>
> Are you sure create_foreign_key actually creates a new table in the 
> database? The docstring says that it creates a sqlalchemy.schema.Table 
> object, but I read that as just an implementation detail - I don't 
> think a new table should end up in the database. 
>
> Simon 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to