|
1 | 1 | from fastapi import FastAPI, Request |
2 | 2 | from fastapi.staticfiles import StaticFiles |
3 | 3 |
|
| 4 | +from app.config import PSQL_ENVIRONMENT |
4 | 5 | from app.database import models |
5 | 6 | from app.database.database import engine |
6 | 7 | from app.dependencies import ( |
7 | 8 | MEDIA_PATH, STATIC_PATH, templates) |
8 | | -from app.routers import agenda, dayview, event, profile, email, invitation |
| 9 | +from app.routers import (agenda, dayview, email, event, invitation, profile, |
| 10 | + search) |
9 | 11 |
|
10 | 12 |
|
11 | | -models.Base.metadata.create_all(bind=engine) |
| 13 | +def create_tables(engine, psql_environment): |
| 14 | + if 'sqlite' in str(engine.url) and psql_environment: |
| 15 | + raise models.PSQLEnvironmentError( |
| 16 | + "You're trying to use PSQL features on SQLite env.\n" |
| 17 | + "Please set app.config.PSQL_ENVIRONMENT to False " |
| 18 | + "and run the app again." |
| 19 | + ) |
| 20 | + else: |
| 21 | + models.Base.metadata.create_all(bind=engine) |
12 | 22 |
|
| 23 | + |
| 24 | +create_tables(engine, PSQL_ENVIRONMENT) |
13 | 25 | app = FastAPI() |
14 | 26 | app.mount("/static", StaticFiles(directory=STATIC_PATH), name="static") |
15 | 27 | app.mount("/media", StaticFiles(directory=MEDIA_PATH), name="media") |
|
20 | 32 | app.include_router(dayview.router) |
21 | 33 | app.include_router(email.router) |
22 | 34 | app.include_router(invitation.router) |
| 35 | +app.include_router(search.router) |
23 | 36 |
|
24 | 37 |
|
25 | 38 | @app.get("/") |
|
0 commit comments