[openstack-dev] [neutron] how to create initial db migration script to sub-project
Moshe Levi
moshele at mellanox.com
Sun Jul 24 08:38:06 UTC 2016
Hi,
I am trying to create initial db for the networking-mlnx project.
I am following this neutron alembic documentation [1].
I added a entrypoint to networking-mlnx setup.cfg
neutron.db.alembic_migrations =
networking-mlnx = networking_mlnx.db.migration:alembic_migrations
I added model.py file to networking-mlnx/networking_mlnx/db
And I run python setup.py develop to regenerate the entrypoint
I am running the following commands:
1. mysql -e "drop database neutron; create database neutron;"
2. neutron-db-manage --subproject=neutron upgrade heads
3. neutron-db-manage --subproject=networking-mlnx revision -m "test" --autogenerate
I am getting the following errors:
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.autogenerate.compare] Detected removed table u'alembic_version'
INFO [alembic.autogenerate.compare] Detected removed index 'idx_autoinc_vr_id' on 'ha_router_vrid_allocations'
Generating /.autodirect/mtrswgwork/moshele/openstack/networking-mlnx/networking_mlnx/db/migration/alembic_migrations/versions/120e7e350bb1_test.py ... done
OK
Traceback (most recent call last):
File "/usr/bin/neutron-db-manage", line 10, in <module>
sys.exit(main())
File "/.autodirect/mtrswgwork/moshele/openstack/neutron/neutron/db/migration/cli.py", line 689, in main
return_val |= bool(CONF.command.func(config, CONF.command.name))
File "/.autodirect/mtrswgwork/moshele/openstack/neutron/neutron/db/migration/cli.py", line 275, in do_revision
update_head_files(config)
File "/.autodirect/mtrswgwork/moshele/openstack/neutron/neutron/db/migration/cli.py", line 398, in update_head_files
f.write(head_map[CONTRACT_BRANCH] + '\n')
KeyError: 'contract'
And the migration script just dropping unrelated tables
[moshele at r-dcs84 networking-mlnx]$ cat /.autodirect/mtrswgwork/moshele/openstack/networking-mlnx/networking_mlnx/db/migration/alembic_migrations/versions/120e7e350bb1_test.py
# revision identifiers, used by Alembic.
revision = '120e7e350bb1'
down_revision = None
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_table('alembic_version')
op.drop_index('idx_autoinc_vr_id', table_name='ha_router_vrid_allocations')
### end Alembic commands ###
It seem that the neutron alembic migration documentation [1] is out of date ( I don't see the --core_plugin flag in the neutron-db-manage man, but I do see the --subproject flag)
Does anyone know how to make it works?
[1] - http://docs.openstack.org/developer/neutron/devref/alembic_migrations.html
More information about the OpenStack-dev
mailing list