Add todosrht-initdb
This commit is contained in:
parent
dd416c6a59
commit
fcc0ae031b
1
setup.py
1
setup.py
|
@ -68,6 +68,7 @@ setup(
|
|||
]
|
||||
},
|
||||
scripts = [
|
||||
'todosrht-initdb',
|
||||
'todosrht-lmtp',
|
||||
'todosrht-migrate',
|
||||
]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Create the initial database schema and stamp the `head` revision.
|
||||
|
||||
The target database needs to exist, as defined in the config file.
|
||||
|
||||
Idempotent. If the tables already exist, they will not be re-created.
|
||||
"""
|
||||
import todosrht.alembic
|
||||
import todosrht.types
|
||||
|
||||
from alembic import command
|
||||
from alembic.config import Config
|
||||
from srht.config import cfg
|
||||
from srht.database import DbSession
|
||||
|
||||
connection_string = cfg("todo.sr.ht", "connection-string")
|
||||
alembic_path = list(todosrht.alembic.__path__)[0]
|
||||
|
||||
db = DbSession(connection_string)
|
||||
db.create()
|
||||
|
||||
config = Config()
|
||||
config.set_main_option("sqlalchemy.url", connection_string)
|
||||
config.set_main_option("script_location", alembic_path)
|
||||
command.stamp(config, "head")
|
Loading…
Reference in New Issue