On Mon, May 25, 2015, Zang, Rui <rui.z...@intel.com> wrote: > Greetings, > > Forgive my alembic ignorance. I am writing some vender specific code that > wants to create new DB tables for neutron. I have read the > neutron/db/migration/README file, but still have something unclear. > My current understanding is that for DB tables creation, I have to do > "something" with neutron/db/migration/ . > > What I have done were: > - Copied neutron/db/migration/alembic.ini to $my_plugin_directory
Are you sure you needed to do this step? I have never needed to. > - Ran `neutron-db-manage --config-file /etc/neutron/neutron.conf > --config-file $my_plugin_directory/alembic.ini revision -m "my plugin init > ops" --autogenerate`. This autogenerate command generated a > neutron/db/migrations/alembic_migrations/versions/ > ee78798e4af_my_plugin_init_ops.py file. But this file is completely > irrelevant with my targeted changes. Yes, unfortunately the autogenerate currently generates commands to drop all the FWaaS, LBaaS and VPNaaS tables since their models are not in the neutron tree. You can and should delete all these commands that are not related to your new models. We have been meaning to fix the autogeneration so that it handles the *aaS tables correctly, but it is a little tricky. > So I replaced the upgrade() method with the DB table creation code. If you import your models file in neutron/db/migration/models/head.py then autogenerate should generate the commands for your schemas (in addition to the drops for *aaS). > - Then ran `neutron-db-manager upgrade` to upgrade to revision ee78798e4af > manually, I saw the tables were created. > > So the questions are: > * there are scripts in neutron/db/migration/alembic_migrations/ that without > a revision prefix, like l3_init_ops.py, they are not in the "versions" > directory. What are they for? They are used by the start migration (havana_initial) and some corner cases. You shouldn't need them. > * Should I just keep the "ee78798e4af_my_plugin_init_ops.py" file? Yes, after modifying it so that it contains only commands for your tables. > Seems the metadata files are no longer usable. What metadata files? > * I assume if the revision file ("ee78798e4af_my_plugin_init_ops.py" in my > case) is already there before devstack is started, the new tables will be > created by devstack as other tables, right? Yes. > * Anything what I did wrong or missing? You were not too far off. I hope my answers helped. > Thanks, > Rui Zang __________________________________________________________________________ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev