1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-19 18:31:16 +00:00

Rename database to advlabdb.sqlite

This commit is contained in:
Mo 2023-02-02 13:39:58 +01:00
parent cb33b8e12b
commit bc2050772a
7 changed files with 15 additions and 8 deletions

2
.gitignore vendored
View file

@ -3,7 +3,7 @@ secrets.ini
# Own settings
settings.ini
# Database
*.db
*.sqlite
# Flask-Migrate
/migrations/

View file

@ -10,4 +10,4 @@ RUN pip3 install -r requirements.txt
COPY . .
CMD ["gunicorn", "--bind", "0.0.0.0:80", "--workers", "5", "--log-file", "/volumes/logs/gunicorn.log", "run:create_app()"]
CMD ["/bin/bash", "init.sh"]

View file

@ -53,7 +53,7 @@ def set_config(app, data_dir: Path):
app.config["SECRET_KEY"] = secrets["SECRET_KEY"]
# SQLALCHEMY
db_file = data_dir / "db/advlab.db"
db_file = data_dir / "db/advlabdb.sqlite"
db_file.parent.mkdir(parents=True, exist_ok=True)
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_file}"

View file

@ -48,7 +48,7 @@ def not_nullable(entry):
def importFromFile(filePath: Path):
db_path = data_dir / "db/advlab.db"
db_path = data_dir / "db/advlabdb.sqlite"
db_bk_dir = db_path.parent / "backups"
db_bk_dir.mkdir(exist_ok=True)
@ -331,7 +331,7 @@ def importFromFile(filePath: Path):
db.session.add(dbAppointment)
# Backup
dest = db_bk_dir / f"before_{dbSemester}_import_{now()}.db"
dest = db_bk_dir / f"before_{dbSemester}_import_{now()}.sqlite"
copy2(db_path, dest)
flash(f"Made a backup of the database before committing the import at {dest}")
@ -342,7 +342,7 @@ def importFromFile(filePath: Path):
raise ex
dest = db_bk_dir / f"after_{dbSemester}_import_{now()}.db"
dest = db_bk_dir / f"after_{dbSemester}_import_{now()}.sqlite"
copy2(db_path, dest)
flash(f"Made a backup of the database after the import at {dest}")

View file

@ -17,7 +17,7 @@ class EmailParamType(click.ParamType):
def _init_db(manage):
db_file = data_dir / "db/advlab.db"
db_file = data_dir / "db/advlabdb.sqlite"
if db_file.is_file():
click.echo(f"Skipping database initialization because the database does already exist at {db_file}.")
return

View file

@ -33,7 +33,7 @@ def db_add(obj):
def _generate_test_db():
db_file = data_dir / "db/advlab.db"
db_file = data_dir / "db/advlabdb.sqlite"
if db_file.is_file():
click.echo(
click.style(

7
init.sh Normal file
View file

@ -0,0 +1,7 @@
#!/bin/bash
# Generate secrets if the secrets file does not already exist
./manage.py setup generate-secrets
# Start the server
gunicorn --bind "0.0.0.0:80" --workers "5" --log-file "/volumes/logs/gunicorn.log" "run:create_app()"