contentdb/setup.py

32 lines
771 B
Python
Raw Normal View History

2018-03-18 18:43:30 +01:00
import os, datetime
delete_db = False
2018-03-19 19:08:41 +01:00
if delete_db and os.path.isfile("db.sqlite"):
os.remove("db.sqlite")
2018-03-18 18:43:30 +01:00
2018-03-19 19:08:41 +01:00
if not os.path.isfile("db.sqlite"):
2018-03-18 19:05:53 +01:00
from app.models import *
2018-03-18 18:43:30 +01:00
print("Creating database tables...")
2018-03-18 19:05:53 +01:00
db.create_all()
2018-03-18 18:43:30 +01:00
print("Filling database...")
2018-03-18 19:05:53 +01:00
ruben = User("rubenwardy")
ruben.github_username = "rubenwardy"
db.session.add(ruben)
2018-03-19 19:08:41 +01:00
mod1 = Mod()
mod1.name = "awards"
mod1.title = "Awards"
mod1.author = ruben
mod1.description = "Adds achievements and an API to register new ones."
mod1.repo = "https://github.com/rubenwardy/awards"
mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
mod1.forums = "https://forum.minetest.net/viewtopic.php?t=4870"
db.session.add(mod1)
2018-03-18 19:05:53 +01:00
db.session.commit()
2018-03-18 18:43:30 +01:00
else:
print("Database already exists")