fix: update schedule
This commit is contained in:
1 parent
7147086e84
commit
2c3e038161
19 files changed
+623
-27
No files matched your search
+21
-4
@@ -8,15 +8,31 @@ from sqlalchemy.orm import selectinload
|
||||
|
||||
from .bootstrap import ensure_initial_data
|
||||
from .config import settings
|
||||
from .database import Base, SessionLocal, engine
|
||||
from .database import (
|
||||
SessionLocal,
|
||||
current_revision,
|
||||
has_tables,
|
||||
run_migrations,
|
||||
stamp,
|
||||
)
|
||||
from .models import Assignment, NotificationLog, RotationMember, Schedule, User
|
||||
from .notifications import send_email_notification
|
||||
from .scheduling import ensure_month_assignments
|
||||
from .security import hash_password
|
||||
|
||||
BASELINE_REVISION = "0001_initial"
|
||||
|
||||
|
||||
def migrate() -> None:
|
||||
if has_tables() and current_revision() is None:
|
||||
stamp(BASELINE_REVISION)
|
||||
print(f"Existing database stamped at {BASELINE_REVISION}.")
|
||||
run_migrations()
|
||||
print(f"Database at revision {current_revision()}.")
|
||||
|
||||
|
||||
def init_db() -> None:
|
||||
Base.metadata.create_all(bind=engine)
|
||||
migrate()
|
||||
with SessionLocal() as db:
|
||||
ensure_initial_data(db)
|
||||
print("Database initialized.")
|
||||
@@ -69,7 +85,7 @@ def seed_demo() -> None:
|
||||
|
||||
|
||||
def send_reminders() -> None:
|
||||
Base.metadata.create_all(bind=engine)
|
||||
migrate()
|
||||
target = date.today() + timedelta(days=settings.reminder_days_ahead)
|
||||
with SessionLocal() as db:
|
||||
ensure_initial_data(db)
|
||||
@@ -110,11 +126,12 @@ def main() -> None:
|
||||
command = sys.argv[1] if len(sys.argv) > 1 else ""
|
||||
commands = {
|
||||
"init-db": init_db,
|
||||
"migrate": migrate,
|
||||
"seed-demo": seed_demo,
|
||||
"send-reminders": send_reminders,
|
||||
}
|
||||
if command not in commands:
|
||||
print("Usage: python -m app.cli [init-db|seed-demo|send-reminders]")
|
||||
print("Usage: python -m app.cli [init-db|migrate|seed-demo|send-reminders]")
|
||||
raise SystemExit(2)
|
||||
commands[command]()
|
||||
|
||||
|
||||
Reference in new issue
Block a user