Spaces:
Runtime error
Runtime error
Document additive ORM schema initialization
Browse files- app/security/database.py +7 -0
app/security/database.py
CHANGED
|
@@ -122,6 +122,13 @@ class SecurityDatabase:
|
|
| 122 |
cursor.close()
|
| 123 |
|
| 124 |
async def initialize(self) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
if not self.auto_migrate:
|
| 126 |
return
|
| 127 |
async with self.engine.begin() as connection:
|
|
|
|
| 122 |
cursor.close()
|
| 123 |
|
| 124 |
async def initialize(self) -> None:
|
| 125 |
+
"""Create ORM-mapped tables and indexes that do not exist yet.
|
| 126 |
+
|
| 127 |
+
SQLAlchemy create_all is intentionally additive: it does not alter
|
| 128 |
+
existing columns or repair incompatible foreign keys. PostgreSQL RLS
|
| 129 |
+
policies and migration-only constraints must still be applied by SQL
|
| 130 |
+
migrations and are verified separately at startup.
|
| 131 |
+
"""
|
| 132 |
if not self.auto_migrate:
|
| 133 |
return
|
| 134 |
async with self.engine.begin() as connection:
|