Hi Gabriel,

could you try to split your migratiion in 2 steps?

1/ create 'website_infos' and 'website_urls'
2/ create 'visits'

I suspect that, maybe, the sa.ForeignKey() calls need the target tables
to already exist.

Hope this helps,

Laurent.


Le 06/03/2015 15:37, gabr...@admetricks.com a écrit :
> Hi everyone,
> 
> I'm new in the amazing world of Flask & SA and I'm running into a loop. 
> I'm using Flask and SA using:
> 
> /db = SQLAlchemy(app)/
> /db.reflect('__all__', app)/
> 
> I wrote 3 migrations using ForeignKey with Alembic 
> 
> op.create_table(
>         'website_infos',
>         sa.Column('id', sa.Integer, primary_key=True),
>         sa.Column('website_id', sa.Integer, sa.ForeignKey('websites.id')),
>         sa.Column('country_id', sa.Integer, sa.ForeignKey('countries.id')),
> ...
> )
> 
> op.create_table(
>         'website_urls',
>         sa.Column('id', sa.Integer, primary_key=True),
> ...
> )
> 
> op.create_table(
>         'visits',
>         sa.Column('id', sa.Integer, primary_key=True),
>         sa.Column('country_id', sa.Integer, sa.ForeignKey('countries.id')),
>         sa.Column('device_id', sa.Integer, sa.ForeignKey('devices.id')),
>         sa.Column('website_url_id', sa.Integer,
> sa.ForeignKey('website_urls.id')),
>         sa.Column('website_info_id', sa.Integer,
> sa.ForeignKey('website_infos.id')),
> ...
> )
> 
> and when I run /alembic upgrade head/ I get this error:
> 
> /sqlalchemy.exc.NoSuchTableError: website_urls
> /
> 
> Website_urls is part of my 3 migrations I want Alembic to generate.
> 
> If I remove db.reflect('__all__', app) I get an other error from sqlalchemy:
> 
> /could not assemble any primary key columns for mapped table 'website_info'
> /
> 
> I believe sqlalchemy wants me to define my table in my models but I'm
> using the reflexion to not have to do that.
> 
> If anyone can provide me guidance that will be awesome.
> 
> Full stacks:
> https://gist.github.com/GabKlein/43d520cc458e1acb10de
> https://gist.github.com/GabKlein/b29b1ae6fae55460fbbb
> 
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy-alembic+unsubscr...@googlegroups.com
> <mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

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

Reply via email to