mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
Rename database to advlabdb.sqlite
This commit is contained in:
parent
cb33b8e12b
commit
bc2050772a
7 changed files with 15 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,7 +3,7 @@ secrets.ini
|
||||||
# Own settings
|
# Own settings
|
||||||
settings.ini
|
settings.ini
|
||||||
# Database
|
# Database
|
||||||
*.db
|
*.sqlite
|
||||||
|
|
||||||
# Flask-Migrate
|
# Flask-Migrate
|
||||||
/migrations/
|
/migrations/
|
||||||
|
|
|
@ -10,4 +10,4 @@ RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
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"]
|
|
@ -53,7 +53,7 @@ def set_config(app, data_dir: Path):
|
||||||
app.config["SECRET_KEY"] = secrets["SECRET_KEY"]
|
app.config["SECRET_KEY"] = secrets["SECRET_KEY"]
|
||||||
|
|
||||||
# SQLALCHEMY
|
# SQLALCHEMY
|
||||||
db_file = data_dir / "db/advlab.db"
|
db_file = data_dir / "db/advlabdb.sqlite"
|
||||||
db_file.parent.mkdir(parents=True, exist_ok=True)
|
db_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_file}"
|
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_file}"
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ def not_nullable(entry):
|
||||||
|
|
||||||
|
|
||||||
def importFromFile(filePath: Path):
|
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 = db_path.parent / "backups"
|
||||||
db_bk_dir.mkdir(exist_ok=True)
|
db_bk_dir.mkdir(exist_ok=True)
|
||||||
|
@ -331,7 +331,7 @@ def importFromFile(filePath: Path):
|
||||||
db.session.add(dbAppointment)
|
db.session.add(dbAppointment)
|
||||||
|
|
||||||
# Backup
|
# 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)
|
copy2(db_path, dest)
|
||||||
|
|
||||||
flash(f"Made a backup of the database before committing the import at {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
|
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)
|
copy2(db_path, dest)
|
||||||
|
|
||||||
flash(f"Made a backup of the database after the import at {dest}")
|
flash(f"Made a backup of the database after the import at {dest}")
|
||||||
|
|
|
@ -17,7 +17,7 @@ class EmailParamType(click.ParamType):
|
||||||
|
|
||||||
|
|
||||||
def _init_db(manage):
|
def _init_db(manage):
|
||||||
db_file = data_dir / "db/advlab.db"
|
db_file = data_dir / "db/advlabdb.sqlite"
|
||||||
if db_file.is_file():
|
if db_file.is_file():
|
||||||
click.echo(f"Skipping database initialization because the database does already exist at {db_file}.")
|
click.echo(f"Skipping database initialization because the database does already exist at {db_file}.")
|
||||||
return
|
return
|
||||||
|
|
|
@ -33,7 +33,7 @@ def db_add(obj):
|
||||||
|
|
||||||
|
|
||||||
def _generate_test_db():
|
def _generate_test_db():
|
||||||
db_file = data_dir / "db/advlab.db"
|
db_file = data_dir / "db/advlabdb.sqlite"
|
||||||
if db_file.is_file():
|
if db_file.is_file():
|
||||||
click.echo(
|
click.echo(
|
||||||
click.style(
|
click.style(
|
||||||
|
|
7
init.sh
Normal file
7
init.sh
Normal 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()"
|
Loading…
Reference in a new issue