[openstack-dev] [Neutron][DB] neutron DB migration scripts

Zang, Rui rui.zang at intel.com
Mon May 25 06:23:54 UTC 2015


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
- 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. So I replaced the upgrade() method with the DB table creation code.
- 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?

* Should I just keep the "ee78798e4af_my_plugin_init_ops.py" file? Seems the metadata files are no longer usable.

* 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?

* Anything what I did wrong or missing?

Thanks,
Rui Zang 




More information about the OpenStack-dev mailing list