Prepare ERP source for Gitea deployment
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
@echo off
|
||||
setlocal
|
||||
alembic upgrade head
|
||||
if %errorlevel% neq 0 (
|
||||
echo Migration failed.
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
echo Migration complete.
|
||||
endlocal
|
||||
@@ -0,0 +1,8 @@
|
||||
@echo off
|
||||
setlocal
|
||||
if "%~1"=="" (
|
||||
echo Usage: new_migration.bat "message"
|
||||
exit /b 1
|
||||
)
|
||||
alembic revision --autogenerate -m "%~1"
|
||||
endlocal
|
||||
@@ -0,0 +1,26 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import select, func
|
||||
|
||||
from app.core.db.common import CommonSessionLocal
|
||||
from app.modules.clients.association_models import ClientAssociation
|
||||
from app.modules.clients.models import Client
|
||||
|
||||
|
||||
def main():
|
||||
db = CommonSessionLocal()
|
||||
try:
|
||||
total_clients = db.execute(select(func.count()).select_from(Client)).scalar_one()
|
||||
total_assoc = db.execute(select(func.count()).select_from(ClientAssociation)).scalar_one()
|
||||
missing = db.execute(select(Client.id, Client.client_code, Client.client_name).outerjoin(ClientAssociation, ClientAssociation.client_id == Client.id).where(ClientAssociation.id.is_(None))).all()
|
||||
print(f"Total clients : {total_clients}")
|
||||
print(f"Total associations : {total_assoc}")
|
||||
print(f"Missing associations: {len(missing)}")
|
||||
for row in missing[:50]:
|
||||
print(f"- {row.id} | {row.client_code} | {row.client_name}")
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user