Coverage for watcher/db/sqlalchemy/alembic/env.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-17 12:22 +0000

1# Licensed under the Apache License, Version 2.0 (the "License"); you may 

2# not use this file except in compliance with the License. You may obtain 

3# a copy of the License at 

4# 

5# http://www.apache.org/licenses/LICENSE-2.0 

6# 

7# Unless required by applicable law or agreed to in writing, software 

8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

10# License for the specific language governing permissions and limitations 

11# under the License. 

12 

13from alembic import context 

14from oslo_db.sqlalchemy import enginefacade 

15 

16from watcher.db.sqlalchemy import models 

17 

18# this is the Alembic Config object, which provides 

19# access to the values within the .ini file in use. 

20config = context.config 

21 

22# add your model's MetaData object here 

23# for 'autogenerate' support 

24# from myapp import mymodel 

25target_metadata = models.Base.metadata 

26 

27# other values from the config, defined by the needs of env.py, 

28# can be acquired: 

29# my_important_option = config.get_main_option("my_important_option") 

30# ... etc. 

31 

32 

33def run_migrations_online(): 

34 """Run migrations in 'online' mode. 

35 

36 In this scenario we need to create an Engine 

37 and associate a connection with the context. 

38 

39 """ 

40 engine = enginefacade.writer.get_engine() 

41 with engine.connect() as connection: 

42 context.configure(connection=connection, 

43 target_metadata=target_metadata) 

44 with context.begin_transaction(): 

45 context.run_migrations() 

46 

47 

48run_migrations_online()