Commit Graph

6 Commits

Author SHA1 Message Date
Mike Bayer 0ce2857d0f db: update migrations to use SQLA 2.0 patterns
All tests in test_migration.py pass with either SQLAlchemy 1.4
or SQLAlchemy 2.0 installed.

Change-Id: Ie8831c04b7b4515deea27b1ceb472d07cda91ca0
2024-04-03 19:26:23 -04:00
zhongjun b422699924 Use parenthesis instead of backslashes in db folder
Use parenthesis instead of backslashes in db folder

TrivialFix
Change-Id: I6c2ea07b0bfc5852b28e44989406cc10eb972e13
2017-06-15 19:42:07 +08:00
Valeriy Ponomaryov 503203e243 Close DB migration sessions explicitly for compatibility with PyMySQL
oslo.db lib starting with version 1.12.0 uses PyMySQL as mysql client.
We get problem with it as it does not close opened sessions by default.
And if we do some actions with migration sessions and do not close sessions,
then alembic, as db migration tool does not write to DB updated migration
version, that is final step of each migration.
It breaks further attempts to perform some migration actions in case some
migration can not be applied twice. Because of improper versions in DB,
alembic tries to execute same migrations again and again.

So, close migration sessions explicitly since PyMySQL does not do it itself.
Also, print version in devstack for getting more details in future debug of
devstack installation output.

Change-Id: I5c729f10bac23b1853e18127b50b1d9f053ab629
Closes-Bug: #1473400
2015-07-14 12:39:00 +03:00
Valeriy Ponomaryov 96e049783b Fix fields 'deleted' in various DB models for PostgreSQL compatibility
Our migrations set field 'deleted' as Boolean for table
'share_type_extra_specs', but model 'ShareTypeExtraSpecs' treats it as Integer.
Same for several other models.
It works using MySQL as far it uses 'tinyint' storing `1` or `0` there. So, in
case of MySQL it is always Integer.
But PostgreSQL fails to write any records there because it distinguishes
Boolean from Integer. So, fix DB migrations, DB methods and models to make
mentioned field compatible for PostreSQL backend too.

Also, reuse func 'model_query' from oslo_db to remove errors with queries that
contain aggregate functions.

Change-Id: I0ca00ce86adad893ac786b10324a934d372e2a04
Closes-Bug: #1440089
2015-04-05 17:56:48 +03:00
Valeriy Ponomaryov bf7fc87067 Replace SQL code for ORM analog in DB migration scripts
Replace explicit usage of SQL code with appropriate analog of ORM.
It allows to keep abstraction between DB and python clear without
potential incompatibilities due to differencies in SQL dialects.

Change-Id: Ied97264cafcec0bcebd4c3ddc7b29185825c56a6
Closes-Bug: #1437278
2015-04-01 12:29:54 +03:00
Igor Malinovskiy 31a1be5c2a Make extra spec driver_handles_share_servers required
Currently the driver_handles_share_servers is an optional extra_spec
on each share_type that allows the scheduler to filter. We want to
make this a required extra spec, so that every share type has this
value set to true or false. It's not be possible to remove that extra
spec. Modifying the extra spec is allowed as long as the value
remains either true or false.

- Add validation checks to types_manage and types_extra_specs API
controllers
- Add required_extra_specs to data returned by API methods
types_show() and types_index()
- Add db migration, which adds required extra_spec to all existing
 share_types
- Add get_required_extra_specs(), validate_required_extra_spec(),
 get_valid_required_extra_specs()
methods to share_types module
- Add appropriate unit tests

Partially implements bp share-type-require-driver-mode

Change-Id: I60a877b05a642ea2945b15248e885cf6f7f89aa0
2015-03-06 13:19:14 +02:00