Skip to content

Commit

Permalink
creating database at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
elman23 committed Sep 26, 2023
1 parent 9c44188 commit 31f07bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
engine = create_engine(SQLALCHEMY_DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
Base.metadata.create_all(bind=engine)


def get_db():
Expand Down
4 changes: 4 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from . import auth
from .routers import post, user, vote
from fastapi.middleware.cors import CORSMiddleware
from database import Base, engine


# Auto generate database
Expand All @@ -21,6 +22,9 @@
)


Base.metadata.create_all(bind=engine)


app.include_router(auth.router)
app.include_router(post.router)
app.include_router(user.router)
Expand Down

0 comments on commit 31f07bc

Please sign in to comment.