Re: Rename an existing constraint

2017-08-30 Thread Mike Bayer
On Wed, Aug 30, 2017 at 7:18 AM, wrote: > Given an Alembic migration, would you recommend the following code to rename > constraints? > > from alembic import op > import sqlalchemy as sa > from srv.orm.meta import NAMING_CONVENTION # as per Pylons cookiecutter > template

Re: Rename an existing constraint

2017-08-30 Thread jens . troeger
Given an Alembic migration, would you recommend the following code to rename constraints? from alembic import op import sqlalchemy as sa

Re: Rename an existing constraint

2017-08-29 Thread jens . troeger
Thank you, Mike! I’ll take a closer look at your proposed code this week. I am curious though: not even MySQL has a rename feature , is that because of consistency? PostgreSQL adds ALTER TABLE …

Re: Rename an existing constraint

2017-08-29 Thread Mike Bayer
Unfortunately there's no RENAME CONSTRAINT directive, so dropping and recreating is how it has to go. Alembic and SQLAlchemy together do have the ability to return lists of constraints and produce CREATE instructions for them. Recently I did some of this related to foreign keys, and the same

Rename an existing constraint

2017-08-29 Thread jens . troeger
Hello, I started out migrating my db schema forward using Alembic, and without any constraint naming convention. That caused constraints to be named using MySQL’s default naming. Alas, now I added a naming convention (see doc here