Thx Michael, Sorry about being not clear, You care right, I am using autogenerate. I read the doc, I think that's what I am looking for. Thanks.
for the missing auto inrement, I found whenever there are multiple primary key (foreign or not), the created tables are different. case 1: 1 primary key, autoincrement + PK (same as my metadata) case 2: 1 primary key + 1 or 2 foreign key (primary_key = true), autoincrement is not checked case 3: 1 primary key + 1 foreign key (not primary key column), PK is not checked I am new to metadata and alembic, so there maybe some mistakes in my metadata. anyway, manually edit the scripts give me the result I want. On Friday, June 9, 2017 at 6:52:31 PM UTC-4, Michael Bayer wrote: > > > > On Friday, June 9, 2017 at 9:00:00 AM UTC-4, ktang wrote: >> >> Hi, >> >> I have an application migrating existing mysql dbs which may have tables >> only in some system. >> I am trying to use alembic to handle the migration. >> >> When I migrate the db to a newer version, if I don't want to drop any >> existing tables or columns, how can I do this (just adding stuff)? >> > > I'm assuming you're talking about autogenerate. If you are just writing > migration scripts by hand, you just put whatever commands you want in them > and that does not impact anything else that's already in the database. If > you are using autogenerate, and you are comparing a model that's only a > subset of the real database, you can have autogenerate exclude other tables > by writing an "include_object" function. Documentation for this is here: > http://alembic.zzzcomputing.com/en/latest/api/runtime.html?highlight=include_object#alembic.runtime.environment.EnvironmentContext.configure.params.include_object > > . You probably want to look at objects of type "table" and include based > on a list of names you care about. > > > > >> >> And a minor issue, when I first setup alembic in my application, I >> generated an initial migration script which autoincrement is not set in >> only one of the tables while all other tables are created correctly. >> Is this a known issue? >> > > not really, it depends on the specifics of how your Table metadata is set > up. If it's just one table then there is likely something different about > it in your code. > > -- 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.