forked from KSP-SpaceDock/SpaceDock
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_initialize.py
42 lines (36 loc) · 1.16 KB
/
db_initialize.py
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
35
36
37
38
39
40
41
42
from alembic.config import Config
from alembic import command
from SpaceDock.objects import *
from SpaceDock.database import db
# Make sure tables are created
alembic_cfg = Config("alembic.ini")
command.stamp(alembic_cfg, "head")
command.upgrade(alembic_cfg, "head")
# Create admin user if doesn't exist
if not User.query.filter(User.username.ilike("admin")).first():
admin = User("admin", "[email protected]", "development")
admin.admin = True
user.public = True
admin.confirmation = None
db.add(admin)
db.commit()
# Create normal user if doesn't exist
if not User.query.filter(User.username.ilike("user")).first():
user = User("user", "[email protected]", "development")
user.public = True
user.confirmation = None
db.add(user)
db.commit()
if not Publisher.query.first():
pub = Publisher("Squad")
db.add(pub)
db.commit()
if not Game.query.first():
game = Game("Kerbal Space Program", 1, "kerbal-space-program")
game.active = True
db.add(game)
db.commit()
if not GameVersion.query.first():
gameversion = GameVersion('1.0', 1)
db.add(gameversion)
db.commit()