mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
86fabcd5e3
+ merge main.py and manage.py + move start logic to swingmusic/__main__.py + add a run.py on the project root
39 lines
895 B
Python
39 lines
895 B
Python
"""
|
|
Module to setup Sqlite databases and tables.
|
|
Applies migrations.
|
|
"""
|
|
|
|
from sqlalchemy import create_engine
|
|
from swingmusic.db.userdata import UserTable
|
|
from swingmusic.migrations import apply_migrations
|
|
from swingmusic.settings import DbPaths
|
|
|
|
from swingmusic.db.engine import DbEngine
|
|
from swingmusic.db import create_all_tables
|
|
# from swingmusic.db.libdata import create_all as create_user_tables
|
|
|
|
|
|
def run_migrations():
|
|
"""
|
|
Run migrations and updates migration version.
|
|
"""
|
|
apply_migrations()
|
|
|
|
|
|
def setup_sqlite():
|
|
"""
|
|
Create Sqlite databases and tables.
|
|
"""
|
|
DbEngine._engine = create_engine(
|
|
f"sqlite+pysqlite:///{DbPaths.get_app_db_path()}",
|
|
echo=False,
|
|
max_overflow=20,
|
|
pool_size=10,
|
|
)
|
|
|
|
create_all_tables()
|
|
# create_user_tables()
|
|
|
|
if not list(UserTable.get_all()):
|
|
UserTable.insert_default_user()
|