lenapi 0.1.4.6__tar.gz → 0.1.4.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/PKG-INFO +2 -2
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/README.md +1 -1
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/__init__.py +1 -1
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/cli.py +62 -73
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi.egg-info/PKG-INFO +2 -2
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/pyproject.toml +1 -1
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/LICENSE +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/admin.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/application.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/auth.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/authentication.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/authorization.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/background.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/concurrency.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/database.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/dependencies.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/docs_guard.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/logging.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/middleware.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/migration_render.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/model.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/models.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/mongodb.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/openapi.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/parameters.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/project.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/request.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/response.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/security.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/security_store.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/sentinels.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/service.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/throttling.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi/transaction.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi.egg-info/SOURCES.txt +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi.egg-info/dependency_links.txt +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi.egg-info/entry_points.txt +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi.egg-info/requires.txt +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi.egg-info/top_level.txt +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/lenapi_bootstrap.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/setup.cfg +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_admin_console.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_cli_settings_recovery.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_docs_guard.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_framework_features.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_media_upload.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_migration_render.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_mongodb.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_platform_services.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_project_isolation.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_security_patch.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_sentinels.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_throttle.py +0 -0
- {lenapi-0.1.4.6 → lenapi-0.1.4.7}/tests/test_user_model_extension.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lenapi
|
|
3
|
-
Version: 0.1.4.
|
|
3
|
+
Version: 0.1.4.7
|
|
4
4
|
Summary: A modern ASGI framework with Pydantic validation, sync and async database access, WebSockets, authentication, and integrated API documentation.
|
|
5
5
|
Author: Maekandex Communication Limitation
|
|
6
6
|
Author-email: "Ifeanyi M. Onovo" <ifeanyi@maekandex.com.ng>
|
|
@@ -2051,7 +2051,7 @@ python lenora.py migrate
|
|
|
2051
2051
|
python lenora.py showmigrations
|
|
2052
2052
|
```
|
|
2053
2053
|
|
|
2054
|
-
`repair-migrations`
|
|
2054
|
+
`repair-migrations` rebuilds SQL migration history from the live database schema and the current models. It removes this project's local revision files and Alembic version table, then generates and applies a fresh migration. Application tables and rows are preserved; existing tables or columns no longer represented by models are retained rather than dropped. Back up the database before running it. MongoDB has no Alembic history and does not support this repair command.
|
|
2055
2055
|
|
|
2056
2056
|
```bash
|
|
2057
2057
|
python lenora.py repair-migrations
|
|
@@ -1999,7 +1999,7 @@ python lenora.py migrate
|
|
|
1999
1999
|
python lenora.py showmigrations
|
|
2000
2000
|
```
|
|
2001
2001
|
|
|
2002
|
-
`repair-migrations`
|
|
2002
|
+
`repair-migrations` rebuilds SQL migration history from the live database schema and the current models. It removes this project's local revision files and Alembic version table, then generates and applies a fresh migration. Application tables and rows are preserved; existing tables or columns no longer represented by models are retained rather than dropped. Back up the database before running it. MongoDB has no Alembic history and does not support this repair command.
|
|
2003
2003
|
|
|
2004
2004
|
```bash
|
|
2005
2005
|
python lenora.py repair-migrations
|
|
@@ -473,7 +473,7 @@ def _main() -> None:
|
|
|
473
473
|
showmigrations = commands.add_parser("showmigrations", help="show local and applied database migration history")
|
|
474
474
|
showmigrations.add_argument("--app", default=DEFAULT_APP, help=f"ASGI app import string (default: {DEFAULT_APP})")
|
|
475
475
|
repair_migrations = commands.add_parser(
|
|
476
|
-
"repair-migrations", help="
|
|
476
|
+
"repair-migrations", help="rebuild migration history from the live schema and current models while preserving application data"
|
|
477
477
|
)
|
|
478
478
|
repair_migrations.add_argument("--app", default=DEFAULT_APP, help=f"ASGI app import string (default: {DEFAULT_APP})")
|
|
479
479
|
clear_migrations = commands.add_parser(
|
|
@@ -1028,7 +1028,7 @@ def test_http_endpoint_is_registered_and_documented(method, path):
|
|
|
1028
1028
|
|
|
1029
1029
|
engine = app.database.engine
|
|
1030
1030
|
revisions = Path.cwd() / "migrations" / "versions"
|
|
1031
|
-
if namespace and args.command
|
|
1031
|
+
if namespace and args.command not in {"delete_migrations", "repair-migrations"}:
|
|
1032
1032
|
# Never read or adopt the legacy global alembic_version table: it may
|
|
1033
1033
|
# belong to another project using the same database. Also refuse to
|
|
1034
1034
|
# replay a pre-namespace local chain into the shared database.
|
|
@@ -1096,7 +1096,22 @@ def test_http_endpoint_is_registered_and_documented(method, path):
|
|
|
1096
1096
|
name for name in inspector.get_view_names()
|
|
1097
1097
|
if namespace and name.startswith(f"{namespace}_")
|
|
1098
1098
|
}
|
|
1099
|
-
if args.command
|
|
1099
|
+
if args.command == "repair-migrations":
|
|
1100
|
+
# A repair rebases only migration metadata. Keep every application
|
|
1101
|
+
# table, view, and row; autogenerate a new revision against the live
|
|
1102
|
+
# schema below so the resulting migration contains only forward diffs.
|
|
1103
|
+
revisions.mkdir(parents=True, exist_ok=True)
|
|
1104
|
+
with engine.begin() as connection:
|
|
1105
|
+
if version_table in inspect(connection).get_table_names():
|
|
1106
|
+
quoted_version = connection.dialect.identifier_preparer.quote(version_table)
|
|
1107
|
+
connection.exec_driver_sql(f"DROP TABLE {quoted_version}")
|
|
1108
|
+
for path in revisions.glob("*.py"):
|
|
1109
|
+
if path.name != "__init__.py":
|
|
1110
|
+
path.unlink()
|
|
1111
|
+
logger.info(
|
|
1112
|
+
"Reset local migration revisions and the project Alembic version table; application data was preserved."
|
|
1113
|
+
)
|
|
1114
|
+
if args.command in {"migration", "migrate"}:
|
|
1100
1115
|
confirm_project_orphans(orphaned_tables | owned_views, "database tables/views")
|
|
1101
1116
|
if orphaned_tables or owned_views:
|
|
1102
1117
|
dialect = engine.dialect.name
|
|
@@ -1278,72 +1293,6 @@ def test_http_endpoint_is_registered_and_documented(method, path):
|
|
|
1278
1293
|
print("Database migration state: " + ", ".join(sorted(current_heads)))
|
|
1279
1294
|
return
|
|
1280
1295
|
|
|
1281
|
-
if args.command == "repair-migrations":
|
|
1282
|
-
script = ScriptDirectory.from_config(config)
|
|
1283
|
-
with engine.connect() as connection:
|
|
1284
|
-
table_names = set(inspect(connection).get_table_names())
|
|
1285
|
-
differences = compare_metadata(
|
|
1286
|
-
MigrationContext.configure(
|
|
1287
|
-
connection,
|
|
1288
|
-
opts={"compare_type": True, "include_object": include_migration_object,
|
|
1289
|
-
"version_table": version_table},
|
|
1290
|
-
),
|
|
1291
|
-
Model.metadata,
|
|
1292
|
-
)
|
|
1293
|
-
if differences:
|
|
1294
|
-
parser.error(
|
|
1295
|
-
"database schema does not match current models; refusing to change migration history. "
|
|
1296
|
-
"Restore the missing revision file or reconcile the schema first. "
|
|
1297
|
-
"If the database is empty, run python lenora.py migration instead."
|
|
1298
|
-
)
|
|
1299
|
-
local_revisions = [
|
|
1300
|
-
path for path in revisions.glob("*.py") if path.name != "__init__.py"
|
|
1301
|
-
]
|
|
1302
|
-
if not local_revisions:
|
|
1303
|
-
if not table_names:
|
|
1304
|
-
parser.error("database is empty; run python lenora.py migration to create the initial revision")
|
|
1305
|
-
from alembic.autogenerate import render_python_code
|
|
1306
|
-
from alembic.operations.ops import CreateIndexOp, CreateTableOp, UpgradeOps
|
|
1307
|
-
from alembic.util import rev_id
|
|
1308
|
-
|
|
1309
|
-
revision_id = rev_id()
|
|
1310
|
-
operations = []
|
|
1311
|
-
tables = list(Model.metadata.sorted_tables)
|
|
1312
|
-
for table in tables:
|
|
1313
|
-
operations.append(CreateTableOp.from_table(table))
|
|
1314
|
-
for table in tables:
|
|
1315
|
-
operations.extend(
|
|
1316
|
-
CreateIndexOp.from_index(index)
|
|
1317
|
-
for index in sorted(table.indexes, key=lambda index: index.name or "")
|
|
1318
|
-
)
|
|
1319
|
-
upgrade_code = render_python_code(UpgradeOps(ops=operations))
|
|
1320
|
-
downgrade_code = "\n".join(
|
|
1321
|
-
f" op.drop_table({table.name!r})" for table in reversed(tables)
|
|
1322
|
-
) or " pass"
|
|
1323
|
-
revisions.mkdir(parents=True, exist_ok=True)
|
|
1324
|
-
baseline = revisions / f"{revision_id}_baseline.py"
|
|
1325
|
-
baseline.write_text(
|
|
1326
|
-
'"""Baseline schema captured from the current model metadata.\n\n'
|
|
1327
|
-
f"Revision ID: {revision_id}\nRevises: None\n\n\n"
|
|
1328
|
-
'"""\nfrom alembic import op\nimport sqlalchemy as sa\n\n'
|
|
1329
|
-
f"revision = {revision_id!r}\ndown_revision = None\n"
|
|
1330
|
-
"branch_labels = None\ndepends_on = None\n\n\n"
|
|
1331
|
-
"def upgrade():\n"
|
|
1332
|
-
f"{upgrade_code}\n\n\n"
|
|
1333
|
-
"def downgrade():\n"
|
|
1334
|
-
f"{downgrade_code}\n",
|
|
1335
|
-
encoding="utf-8",
|
|
1336
|
-
)
|
|
1337
|
-
logger.info("Created baseline migration %s from current models.", baseline.name)
|
|
1338
|
-
head = revision_id
|
|
1339
|
-
else:
|
|
1340
|
-
head = script.get_current_head()
|
|
1341
|
-
if head is None:
|
|
1342
|
-
parser.error("no migration head found; inspect showmigrations and restore missing revision files")
|
|
1343
|
-
command.stamp(config, "head")
|
|
1344
|
-
logger.info("Migration history repaired to %s; schema and data were preserved.", head)
|
|
1345
|
-
return
|
|
1346
|
-
|
|
1347
1296
|
if args.command == "clear_migrations":
|
|
1348
1297
|
with engine.connect() as connection:
|
|
1349
1298
|
table_names = set(inspect(connection).get_table_names())
|
|
@@ -1354,7 +1303,7 @@ def test_http_endpoint_is_registered_and_documented(method, path):
|
|
|
1354
1303
|
if application_tables:
|
|
1355
1304
|
parser.error(
|
|
1356
1305
|
"refusing to clear migrations because the database contains application tables; "
|
|
1357
|
-
"use `python lenora.py repair-migrations`
|
|
1306
|
+
"use `python lenora.py repair-migrations` to rebuild migration history while preserving application tables and data"
|
|
1358
1307
|
)
|
|
1359
1308
|
if version_table in table_names:
|
|
1360
1309
|
with engine.begin() as connection:
|
|
@@ -1367,13 +1316,19 @@ def test_http_endpoint_is_registered_and_documented(method, path):
|
|
|
1367
1316
|
logger.info("Cleared migration files and database history; no application tables existed.")
|
|
1368
1317
|
return
|
|
1369
1318
|
|
|
1370
|
-
schema_generation = args.command in {"migration", "background-worker"}
|
|
1319
|
+
schema_generation = args.command in {"migration", "background-worker", "repair-migrations"}
|
|
1371
1320
|
if schema_generation:
|
|
1372
1321
|
existing_revisions = [
|
|
1373
1322
|
path for path in revisions.glob("*.py") if path.name != "__init__.py"
|
|
1374
1323
|
]
|
|
1375
1324
|
revisions_before_autogenerate = {path.resolve() for path in existing_revisions}
|
|
1376
|
-
|
|
1325
|
+
# Repair autogeneration must compare against the real database even
|
|
1326
|
+
# for SQLite. The normal initial-migration path uses an empty temporary
|
|
1327
|
+
# database to generate a create-all baseline, which would overwrite
|
|
1328
|
+
# the meaning of an existing schema during repair.
|
|
1329
|
+
config.attributes["lenapi_initial_revision"] = (
|
|
1330
|
+
not existing_revisions and args.command != "repair-migrations"
|
|
1331
|
+
)
|
|
1377
1332
|
|
|
1378
1333
|
script = ScriptDirectory.from_config(config)
|
|
1379
1334
|
|
|
@@ -1525,6 +1480,36 @@ def test_http_endpoint_is_registered_and_documented(method, path):
|
|
|
1525
1480
|
temporary_engine.dispose()
|
|
1526
1481
|
|
|
1527
1482
|
def skip_empty_revision(migration_context, revision, directives):
|
|
1483
|
+
if args.command == "repair-migrations":
|
|
1484
|
+
# Preserve existing database data: an autogenerate diff must
|
|
1485
|
+
# never remove a table or column simply because its model was
|
|
1486
|
+
# removed or renamed. Keep the remaining forward changes.
|
|
1487
|
+
from alembic.operations import ops
|
|
1488
|
+
|
|
1489
|
+
def keep_data_operations(container):
|
|
1490
|
+
kept = []
|
|
1491
|
+
for operation in container.ops:
|
|
1492
|
+
if isinstance(operation, (ops.DropTableOp, ops.DropColumnOp)):
|
|
1493
|
+
preserved_name = getattr(operation, "table_name", "table")
|
|
1494
|
+
if isinstance(operation, ops.DropColumnOp):
|
|
1495
|
+
preserved_name = f"{preserved_name}.{operation.column_name}"
|
|
1496
|
+
logger.warning(
|
|
1497
|
+
"Keeping existing database data in %s; model removal was not applied.",
|
|
1498
|
+
preserved_name,
|
|
1499
|
+
)
|
|
1500
|
+
continue
|
|
1501
|
+
nested = getattr(operation, "ops", None)
|
|
1502
|
+
if nested is not None:
|
|
1503
|
+
keep_data_operations(operation)
|
|
1504
|
+
kept.append(operation)
|
|
1505
|
+
container.ops = kept
|
|
1506
|
+
|
|
1507
|
+
for directive in directives or ():
|
|
1508
|
+
for upgrade_ops in directive.upgrade_ops_list:
|
|
1509
|
+
keep_data_operations(upgrade_ops)
|
|
1510
|
+
# Unlike an ordinary migration, an empty repair revision is
|
|
1511
|
+
# useful: it records the new baseline after a history reset.
|
|
1512
|
+
return
|
|
1528
1513
|
if directives and directives[0].upgrade_ops.is_empty():
|
|
1529
1514
|
directives.clear()
|
|
1530
1515
|
|
|
@@ -1643,7 +1628,11 @@ def test_http_endpoint_is_registered_and_documented(method, path):
|
|
|
1643
1628
|
name for name in table_names
|
|
1644
1629
|
if namespace and name.startswith(f"{namespace}_") and name != version_table
|
|
1645
1630
|
}
|
|
1646
|
-
if
|
|
1631
|
+
if (
|
|
1632
|
+
existing_tables
|
|
1633
|
+
and version_table not in table_names
|
|
1634
|
+
and args.command != "repair-migrations"
|
|
1635
|
+
):
|
|
1647
1636
|
differences = compare_metadata(
|
|
1648
1637
|
MigrationContext.configure(
|
|
1649
1638
|
connection,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lenapi
|
|
3
|
-
Version: 0.1.4.
|
|
3
|
+
Version: 0.1.4.7
|
|
4
4
|
Summary: A modern ASGI framework with Pydantic validation, sync and async database access, WebSockets, authentication, and integrated API documentation.
|
|
5
5
|
Author: Maekandex Communication Limitation
|
|
6
6
|
Author-email: "Ifeanyi M. Onovo" <ifeanyi@maekandex.com.ng>
|
|
@@ -2051,7 +2051,7 @@ python lenora.py migrate
|
|
|
2051
2051
|
python lenora.py showmigrations
|
|
2052
2052
|
```
|
|
2053
2053
|
|
|
2054
|
-
`repair-migrations`
|
|
2054
|
+
`repair-migrations` rebuilds SQL migration history from the live database schema and the current models. It removes this project's local revision files and Alembic version table, then generates and applies a fresh migration. Application tables and rows are preserved; existing tables or columns no longer represented by models are retained rather than dropped. Back up the database before running it. MongoDB has no Alembic history and does not support this repair command.
|
|
2055
2055
|
|
|
2056
2056
|
```bash
|
|
2057
2057
|
python lenora.py repair-migrations
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lenapi"
|
|
7
|
-
version = "0.1.4.
|
|
7
|
+
version = "0.1.4.7"
|
|
8
8
|
description = "A modern ASGI framework with Pydantic validation, sync and async database access, WebSockets, authentication, and integrated API documentation."
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "Ifeanyi M. Onovo", email = "ifeanyi@maekandex.com.ng"},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|