~fnux/meta.sr.ht

ref: 3bad716474023aa367775f87683c3c2debc38e39 meta.sr.ht/metasrht-initdb -rwxr-xr-x 911 bytes
3bad7164Timothée Floure auth: handle LDAP connection failures 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/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 metasrht.alembic
import metasrht.types
import metasrht.webhooks

import srht.alembic

from alembic import command
from alembic.config import Config
from srht.config import cfg
from srht.database import DbSession

connection_string = cfg("meta.sr.ht", "connection-string")
alembic_path = list(metasrht.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")

alembic_path = list(srht.alembic.__path__)[0]

config.set_main_option("script_location", alembic_path)
command.stamp(config, "head")