File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change 1- # start-example
2- from sqlspec .adapters .asyncpg import AsyncpgConfig
3-
41__all__ = ("test_async_methods" ,)
52
63
7- config = AsyncpgConfig (
8- pool_config = {"dsn" : "postgresql://user:pass@localhost/mydb" },
9- migration_config = {"enabled" : True , "script_location" : "migrations" },
10- )
11- # end-example
4+ async def test_async_methods () -> None :
5+ # start-example
6+ from sqlspec .adapters .asyncpg import AsyncpgConfig
7+
8+ config = AsyncpgConfig (
9+ pool_config = {"dsn" : "postgresql://user:pass@localhost/mydb" },
10+ migration_config = {"enabled" : True , "script_location" : "migrations" },
11+ )
12+
13+ # Apply migrations
14+ await config .migrate_up ("head" )
15+ # Or use the alias
16+ await config .upgrade ("head" )
1217
18+ # Rollback one revision
19+ await config .migrate_down ("-1" )
20+ # Or use the alias
21+ await config .downgrade ("-1" )
1322
14- def test_async_methods () -> None :
23+ # Check current version
24+ current = await config .get_current_migration (verbose = True )
25+ print (current )
26+ # end-example
1527 # These are just smoke tests for method presence, not actual DB calls
1628 assert hasattr (config , "migrate_up" )
1729 assert hasattr (config , "upgrade" )
You can’t perform that action at this time.
0 commit comments