Bug 1041001 - [RFE][nova]: Models should be the same as the state in DB after migration
Summary: [RFE][nova]: Models should be the same as the state in DB after migration
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-nova
Version: unspecified
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 5.0 (RHEL 7)
Assignee: RHOS Maint
QA Contact: Ami Jeain
URL: https://blueprints.launchpad.net/nova...
Whiteboard: upstream_milestone_next upstream_stat...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-12 13:23 UTC by RHOS Integration
Modified: 2019-09-09 14:34 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-01-06 17:55:55 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description RHOS Integration 2013-12-12 13:23:24 UTC
Cloned from launchpad blueprint https://blueprints.launchpad.net/nova/+spec/db-sync-models-with-migrations.

Description:

We are using declarative_base in nova.db.models just for reflection, not for db creation.
For creation we are using migrations.
We don't have any tests that checks, that our models are up-to-date. Also we are testing it only on sqlite, which couldn't test such things as nullable constraints.

So We should:

1) Use always explicit nullable parameter for columns. There is a lot of mistakes in current nova models implementation. (sometimes in schema is nullable=True and in model nullable=False and vise versa). Also at this moment when you see Column description without nullable, you couldn't be sure that is author forget to set nullable='False' or it is really nullable='True'. So the easiest way to track all this and to fix and to avoid such things is to have one rule "always use explicit nullable".
2) Add in __table_args__ indexes and unique constraints
3) Fix all mistakes in models
4) Fix all mistekes in migrations
5) Sync effects of migrations in different backends. 
6) Add tests that ensures that models are up-to-date.

This will allow us to find probably some mistake, or missing inexes and make work with db more clean.

Specification URL (additional information):

None


Note You need to log in before you can comment on or make changes to this bug.