Migrations API Reference¶
This page provides detailed API documentation for the pydapter.migrations
module.
Installation¶
The migrations module is available as optional dependencies:
# Core migrations functionality
pip install "pydapter[migrations-core]"
# SQL migrations with Alembic support
pip install "pydapter[migrations-sql]"
# All migrations components
pip install "pydapter[migrations]"
Module Overview¶
The migrations module provides a framework for managing database schema changes, following the adapter pattern:
MigrationProtocol
│
▼
BaseMigrationAdapter
│
├─────────────────────┐
│ │
▼ ▼
SyncMigrationAdapter AsyncMigrationAdapter
│ │
▼ ▼
AlembicAdapter AsyncAlembicAdapter
Protocols¶
MigrationProtocol¶
pydapter.migrations.protocols.MigrationProtocol
¶
Bases: Protocol[T]
Protocol defining synchronous migration operations.
Source code in src/pydapter/migrations/protocols.py
Functions¶
create_migration(message, autogenerate=True, **kwargs)
classmethod
¶
Create a new migration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Description of the migration |
required |
autogenerate
|
bool
|
Whether to auto-generate the migration based on model changes |
True
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str
|
The revision identifier of the created migration |
Source code in src/pydapter/migrations/protocols.py
downgrade(revision, **kwargs)
classmethod
¶
Downgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to downgrade to |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Source code in src/pydapter/migrations/protocols.py
get_current_revision(**kwargs)
classmethod
¶
Get the current migration revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str | None
|
The current revision identifier, or None if no migrations have been applied |
Source code in src/pydapter/migrations/protocols.py
get_migration_history(**kwargs)
classmethod
¶
Get the migration history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
list[dict]
|
A list of dictionaries containing migration information |
Source code in src/pydapter/migrations/protocols.py
init_migrations(directory, **kwargs)
classmethod
¶
Initialize migration environment in the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory
|
str
|
Path to the directory where migrations will be stored |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Source code in src/pydapter/migrations/protocols.py
upgrade(revision='head', **kwargs)
classmethod
¶
Upgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to upgrade to (default: "head") |
'head'
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Source code in src/pydapter/migrations/protocols.py
AsyncMigrationProtocol¶
pydapter.migrations.protocols.AsyncMigrationProtocol
¶
Bases: Protocol[T]
Protocol defining asynchronous migration operations.
Source code in src/pydapter/migrations/protocols.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
Functions¶
create_migration(message, autogenerate=True, **kwargs)
async
classmethod
¶
Create a new migration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Description of the migration |
required |
autogenerate
|
bool
|
Whether to auto-generate the migration based on model changes |
True
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str
|
The revision identifier of the created migration |
Source code in src/pydapter/migrations/protocols.py
downgrade(revision, **kwargs)
async
classmethod
¶
Downgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to downgrade to |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Source code in src/pydapter/migrations/protocols.py
get_current_revision(**kwargs)
async
classmethod
¶
Get the current migration revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str | None
|
The current revision identifier, or None if no migrations have been applied |
Source code in src/pydapter/migrations/protocols.py
get_migration_history(**kwargs)
async
classmethod
¶
Get the migration history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
list[dict]
|
A list of dictionaries containing migration information |
Source code in src/pydapter/migrations/protocols.py
init_migrations(directory, **kwargs)
async
classmethod
¶
Initialize migration environment in the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory
|
str
|
Path to the directory where migrations will be stored |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Source code in src/pydapter/migrations/protocols.py
upgrade(revision='head', **kwargs)
async
classmethod
¶
Upgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to upgrade to (default: "head") |
'head'
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Source code in src/pydapter/migrations/protocols.py
Base Classes¶
BaseMigrationAdapter¶
pydapter.migrations.base.BaseMigrationAdapter
¶
Bases: ABC
Base class for migration adapters.
Source code in src/pydapter/migrations/base.py
Functions¶
__init__(connection_string, models_module=None)
¶
Initialize the migration adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_string
|
str
|
Database connection string |
required |
models_module
|
Any
|
Optional module containing model definitions |
None
|
Source code in src/pydapter/migrations/base.py
SyncMigrationAdapter¶
pydapter.migrations.base.SyncMigrationAdapter
¶
Bases: BaseMigrationAdapter
, MigrationProtocol
Base class for synchronous migration adapters.
Source code in src/pydapter/migrations/base.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
Functions¶
create_migration(message, autogenerate=True, **kwargs)
classmethod
¶
Create a new migration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Description of the migration |
required |
autogenerate
|
bool
|
Whether to auto-generate the migration based on model changes |
True
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str
|
The revision identifier of the created migration |
Raises:
Type | Description |
---|---|
MigrationCreationError
|
If creation fails |
Source code in src/pydapter/migrations/base.py
downgrade(revision, **kwargs)
classmethod
¶
Downgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to downgrade to |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationDowngradeError
|
If downgrade fails |
Source code in src/pydapter/migrations/base.py
get_current_revision(**kwargs)
classmethod
¶
Get the current migration revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The current revision identifier, or None if no migrations have been applied |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the current revision fails |
Source code in src/pydapter/migrations/base.py
get_migration_history(**kwargs)
classmethod
¶
Get the migration history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
A list of dictionaries containing migration information |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the migration history fails |
Source code in src/pydapter/migrations/base.py
init_migrations(directory, **kwargs)
classmethod
¶
Initialize migration environment in the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory
|
str
|
Path to the directory where migrations will be stored |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationInitError
|
If initialization fails |
Source code in src/pydapter/migrations/base.py
upgrade(revision='head', **kwargs)
classmethod
¶
Upgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to upgrade to (default: "head") |
'head'
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationUpgradeError
|
If upgrade fails |
Source code in src/pydapter/migrations/base.py
AsyncMigrationAdapter¶
pydapter.migrations.base.AsyncMigrationAdapter
¶
Bases: BaseMigrationAdapter
, AsyncMigrationProtocol
Base class for asynchronous migration adapters.
Source code in src/pydapter/migrations/base.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
Functions¶
create_migration(message, autogenerate=True, **kwargs)
async
classmethod
¶
Create a new migration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Description of the migration |
required |
autogenerate
|
bool
|
Whether to auto-generate the migration based on model changes |
True
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str
|
The revision identifier of the created migration |
Raises:
Type | Description |
---|---|
MigrationCreationError
|
If creation fails |
Source code in src/pydapter/migrations/base.py
downgrade(revision, **kwargs)
async
classmethod
¶
Downgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to downgrade to |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationDowngradeError
|
If downgrade fails |
Source code in src/pydapter/migrations/base.py
get_current_revision(**kwargs)
async
classmethod
¶
Get the current migration revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The current revision identifier, or None if no migrations have been applied |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the current revision fails |
Source code in src/pydapter/migrations/base.py
get_migration_history(**kwargs)
async
classmethod
¶
Get the migration history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
A list of dictionaries containing migration information |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the migration history fails |
Source code in src/pydapter/migrations/base.py
init_migrations(directory, **kwargs)
async
classmethod
¶
Initialize migration environment in the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory
|
str
|
Path to the directory where migrations will be stored |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationInitError
|
If initialization fails |
Source code in src/pydapter/migrations/base.py
upgrade(revision='head', **kwargs)
async
classmethod
¶
Upgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
The target revision to upgrade to (default: "head") |
'head'
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationUpgradeError
|
If upgrade fails |
Source code in src/pydapter/migrations/base.py
SQL Adapters¶
AlembicAdapter¶
pydapter.migrations.sql.alembic_adapter.AlembicAdapter
¶
Bases: SyncMigrationAdapter
Alembic implementation of the MigrationAdapter interface.
Source code in src/pydapter/migrations/sql/alembic_adapter.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
Functions¶
__init__(connection_string, models_module=None)
¶
Initialize the Alembic migration adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_string
|
str
|
Database connection string |
required |
models_module
|
Any
|
Optional module containing SQLAlchemy models |
None
|
Source code in src/pydapter/migrations/sql/alembic_adapter.py
create_migration(message, autogenerate=True, **kwargs)
¶
Create a new migration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Description of the migration |
required |
autogenerate
|
bool
|
Whether to auto-generate the migration based on model changes |
True
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str
|
The revision identifier of the created migration |
Raises:
Type | Description |
---|---|
MigrationCreationError
|
If creation fails |
Source code in src/pydapter/migrations/sql/alembic_adapter.py
downgrade(revision, **kwargs)
¶
Downgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
Revision to downgrade to |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationDowngradeError
|
If downgrade fails |
Source code in src/pydapter/migrations/sql/alembic_adapter.py
get_current_revision(**kwargs)
¶
Get the current revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The current revision, or None if no migrations have been applied |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the current revision fails |
Source code in src/pydapter/migrations/sql/alembic_adapter.py
get_migration_history(**kwargs)
¶
Get the migration history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
list[dict]
|
A list of dictionaries containing migration information |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the migration history fails |
Source code in src/pydapter/migrations/sql/alembic_adapter.py
init_migrations(directory, **kwargs)
classmethod
¶
Initialize migration environment in the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory
|
str
|
Path to the directory where migrations will be stored |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments connection_string: Database connection string models_module: Optional module containing SQLAlchemy models template: Optional template to use for migration environment |
{}
|
Source code in src/pydapter/migrations/sql/alembic_adapter.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
upgrade(revision='head', **kwargs)
¶
Upgrade to the specified revision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision
|
str
|
Revision to upgrade to (default: "head" for latest) |
'head'
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationUpgradeError
|
If upgrade fails |
Source code in src/pydapter/migrations/sql/alembic_adapter.py
AsyncAlembicAdapter¶
pydapter.migrations.sql.alembic_adapter.AsyncAlembicAdapter
¶
Bases: AsyncMigrationAdapter
Async implementation of the Alembic migration adapter.
Source code in src/pydapter/migrations/sql/alembic_adapter.py
Functions¶
__init__(connection_string, models_module=None)
¶
Initialize the async Alembic migration adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connection_string
|
str
|
Database connection string |
required |
models_module
|
Any
|
Optional module containing SQLAlchemy models |
None
|
Source code in src/pydapter/migrations/sql/alembic_adapter.py
Registry¶
pydapter.migrations.registry.MigrationRegistry
¶
Registry for migration adapters.
Source code in src/pydapter/migrations/registry.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
Functions¶
create_migration(migration_key, message, autogenerate=True, **kwargs)
¶
Create a migration for the specified adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migration_key
|
str
|
The key of the adapter to use |
required |
message
|
str
|
The migration message |
required |
autogenerate
|
bool
|
Whether to auto-generate the migration |
True
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
str
|
The revision identifier of the created migration |
Raises:
Type | Description |
---|---|
MigrationCreationError
|
If creation fails |
Source code in src/pydapter/migrations/registry.py
downgrade(migration_key, revision, **kwargs)
¶
Downgrade migrations for the specified adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migration_key
|
str
|
The key of the adapter to use |
required |
revision
|
str
|
The target revision to downgrade to |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationDowngradeError
|
If downgrade fails |
Source code in src/pydapter/migrations/registry.py
get(migration_key)
¶
Get a migration adapter by key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migration_key
|
str
|
The key of the adapter to retrieve |
required |
Returns:
Type | Description |
---|---|
type[MigrationProtocol]
|
The adapter class |
Raises:
Type | Description |
---|---|
AdapterNotFoundError
|
If no adapter is registered for the given key |
Source code in src/pydapter/migrations/registry.py
get_current_revision(migration_key, **kwargs)
¶
Get the current revision for the specified adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migration_key
|
str
|
The key of the adapter to use |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
Optional[str]
|
The current revision identifier, or None if no migrations have been applied |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the current revision fails |
Source code in src/pydapter/migrations/registry.py
get_migration_history(migration_key, **kwargs)
¶
Get the migration history for the specified adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migration_key
|
str
|
The key of the adapter to use |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Returns:
Type | Description |
---|---|
list[dict]
|
A list of dictionaries containing migration information |
Raises:
Type | Description |
---|---|
MigrationError
|
If getting the migration history fails |
Source code in src/pydapter/migrations/registry.py
init_migrations(migration_key, directory, **kwargs)
¶
Initialize migrations for the specified adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migration_key
|
str
|
The key of the adapter to use |
required |
directory
|
str
|
The directory to initialize migrations in |
required |
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationInitError
|
If initialization fails |
Source code in src/pydapter/migrations/registry.py
register(adapter_cls)
¶
Register a migration adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adapter_cls
|
type[MigrationProtocol]
|
The adapter class to register |
required |
Raises:
Type | Description |
---|---|
ConfigurationError
|
If the adapter does not define a migration_key |
Source code in src/pydapter/migrations/registry.py
upgrade(migration_key, revision='head', **kwargs)
¶
Upgrade migrations for the specified adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
migration_key
|
str
|
The key of the adapter to use |
required |
revision
|
str
|
The target revision to upgrade to |
'head'
|
**kwargs
|
Any
|
Additional adapter-specific arguments |
{}
|
Raises:
Type | Description |
---|---|
MigrationUpgradeError
|
If upgrade fails |
Source code in src/pydapter/migrations/registry.py
Exceptions¶
MigrationError¶
pydapter.migrations.exceptions.MigrationError
¶
Bases: AdapterError
Base exception for all migration-related errors.
Source code in src/pydapter/migrations/exceptions.py
MigrationInitError¶
pydapter.migrations.exceptions.MigrationInitError
¶
Bases: MigrationError
Exception raised when migration initialization fails.
Source code in src/pydapter/migrations/exceptions.py
MigrationCreationError¶
pydapter.migrations.exceptions.MigrationCreationError
¶
Bases: MigrationError
Exception raised when migration creation fails.
Source code in src/pydapter/migrations/exceptions.py
MigrationUpgradeError¶
pydapter.migrations.exceptions.MigrationUpgradeError
¶
Bases: MigrationError
Exception raised when migration upgrade fails.
Source code in src/pydapter/migrations/exceptions.py
MigrationDowngradeError¶
pydapter.migrations.exceptions.MigrationDowngradeError
¶
Bases: MigrationError
Exception raised when migration downgrade fails.
Source code in src/pydapter/migrations/exceptions.py
MigrationNotFoundError¶
pydapter.migrations.exceptions.MigrationNotFoundError
¶
Bases: MigrationError
Exception raised when a migration is not found.