partitioncloud-server/scripts/hooks/v1.py

44 lines
1.2 KiB
Python
Raw Normal View History

2023-11-19 15:52:48 +01:00
import os
from hooks import utils
def add_source():
utils.run_sqlite_command(
"ALTER TABLE partition ADD source TEXT DEFAULT 'unknown'"
)
def add_groupes():
utils.run_sqlite_command(
"""CREATE TABLE groupe (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
uuid TEXT(36) NOT NULL
);
CREATE TABLE groupe_contient_user (
groupe_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
is_admin INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (groupe_id, user_id)
);
CREATE TABLE groupe_contient_album (
groupe_id INTEGER NOT NULL,
album_id INTEGER NOT NULL,
PRIMARY KEY (groupe_id, album_id)
);"""
)
def add_attachments():
os.makedirs("partitioncloud/attachments", exist_ok=True)
utils.run_sqlite_command(
"""CREATE TABLE attachments (
uuid TEXT(36) PRIMARY KEY,
name TEXT NOT NULL,
filetype TEXT NOT NULL DEFAULT 'mp3',
partition_uuid INTEGER NOT NULL,
user_id INTEGER NOT NULL
);"""
)
def install_colorama():
os.system("pip install colorama -qq")