deb-murano/murano/db/api.py
Ruslan Kamaldinov 2174fc8a84 Fix DB migration script
Problems we had:
1. If the collation of the DB and table is utf8 and the columns we want to
   index are 512 chars, it is too big for the index since the max key length
   is 767 bytes. Following error message observed:
   (OperationalError) (1071, 'Specified key was too long; max key length is 767 bytes')

2. During migration to Alembic we missed the unique field for the
   'fully_qualified_name' column of the table 'package'. This change
   fixes that issue.

Fixes:
1. Reduce length of indexed columns to fix problem. 128 chars should be probably enough
2. Add uniqe paramater for column fully_qualified_name of table package

Additional changes:
* Test that column is unique in DB migration tests (on real databases)
* Introduced base for DB-related unit-tests. These tests use in-memory
  instance of SQLite
* Test that column is unique in DB-related unit-tests

Closes-Bug: #1339201
Closes-Bug: #1339728
Change-Id: I4816790e11f225c5dbb130747535094fdf06733e
2014-07-12 13:16:04 +00:00

26 lines
780 B
Python

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from murano.db import models
from murano.db import session
def setup_db():
engine = session.get_engine()
models.register_models(engine)
def drop_db():
engine = session.get_engine()
models.unregister_models(engine)