Skip to content

Commit 6353016

Browse files
euri10cofin
authored andcommitted
test 1
1 parent 8843fe6 commit 6353016

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

docs/examples/usage/usage_migrations_1.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
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")

0 commit comments

Comments
 (0)