add alembic
This commit is contained in:
16
teufa/cli.py
16
teufa/cli.py
@@ -1,5 +1,8 @@
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
||||
import alembic.config
|
||||
import teufa.server
|
||||
|
||||
|
||||
@@ -18,6 +21,13 @@ def server(dev):
|
||||
teufa.server.Application(cfg).run()
|
||||
|
||||
|
||||
@cli.command()
|
||||
def initdb():
|
||||
click.echo("Initialized the database")
|
||||
@cli.command(
|
||||
"alembic",
|
||||
context_settings={
|
||||
"ignore_unknown_options": True,
|
||||
"allow_extra_args": True,
|
||||
},
|
||||
add_help_option=False,
|
||||
)
|
||||
def run_alembic(*args, **kwargs):
|
||||
alembic.config.main(prog="teufa alembic", argv=sys.argv[2:])
|
||||
|
13
teufa/db.py
Normal file
13
teufa/db.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str]
|
||||
email: Mapped[str]
|
Reference in New Issue
Block a user