1
1
from alembic import context
2
- from sqlalchemy import engine_from_config , pool , text
2
+ from sqlalchemy import create_engine , text
3
3
4
4
from dispatch .logging import logging
5
5
from dispatch .config import SQLALCHEMY_DATABASE_URI
23
23
24
24
def include_object (object , name , type_ , reflected , compare_to ):
25
25
if type_ == "table" :
26
- if object .schema == CORE_SCHEMA_NAME :
27
- return True
28
- else :
29
- return True
26
+ return object .schema == CORE_SCHEMA_NAME
27
+ return True
30
28
31
29
32
30
def run_migrations_online ():
@@ -36,28 +34,23 @@ def run_migrations_online():
36
34
and associate a connection with the context.
37
35
38
36
"""
39
-
40
- # don't create empty revisions
41
37
def process_revision_directives (context , revision , directives ):
42
38
script = directives [0 ]
43
39
if script .upgrade_ops .is_empty ():
44
40
directives [:] = []
45
41
log .info ("No changes found skipping revision creation." )
46
42
47
- connectable = engine_from_config (
48
- config .get_section (config .config_ini_section ), prefix = "sqlalchemy." , poolclass = pool .NullPool
49
- )
43
+ connectable = create_engine (SQLALCHEMY_DATABASE_URI )
50
44
51
45
log .info ("Migrating dispatch core schema..." )
52
46
# migrate common tables
53
47
with connectable .connect () as connection :
54
48
set_search_path = text (f'set search_path to "{ CORE_SCHEMA_NAME } "' )
55
49
connection .execute (set_search_path )
56
- connection .dialect . default_schema_name = CORE_SCHEMA_NAME
50
+ connection .commit ()
57
51
context .configure (
58
52
connection = connection ,
59
53
target_metadata = target_metadata ,
60
- include_schemas = True ,
61
54
include_object = include_object ,
62
55
process_revision_directives = process_revision_directives ,
63
56
)
0 commit comments