Fix minor details of the migration script

This commit is contained in:
augustin64 2023-11-19 16:05:23 +01:00
parent 76cfe9657f
commit 8ef2928ab3
3 changed files with 11 additions and 9 deletions

View File

@ -2,7 +2,7 @@ import sqlite3
def run_sqlite_command(cmd):
"""Run a command against the database"""
con = sqlite3.connect("instance/partitioncloud.db")
con = sqlite3.connect("instance/partitioncloud.sqlite")
cur = con.cursor()
cur.execute(cmd)
con.commit()

View File

@ -12,16 +12,18 @@ def add_groupes():
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
uuid TEXT(36) NOT NULL
);
CREATE TABLE groupe_contient_user (
);"""
)
utils.run_sqlite_command(
"""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 (
);"""
)
utils.run_sqlite_command(
"""CREATE TABLE groupe_contient_album (
groupe_id INTEGER NOT NULL,
album_id INTEGER NOT NULL,
PRIMARY KEY (groupe_id, album_id)

View File

@ -129,7 +129,7 @@ def restore(version):
exit(1)
dest = os.path.join("backups", version)
print(f"Restoring from {dst}")
print(f"Restoring from {dest}")
paths = [
("instance", os.path.join(dest, "instance")),
(os.path.join("partitioncloud", "partitions"), os.path.join(dest, "partitions")),
@ -144,7 +144,7 @@ def restore(version):
print(f"\tRestoring {src}")
copy_tree(dst, src)
else:
print(f"{Fore.RED}No available backup for {src}, deleting current content to avoid any conflict{Style.RESET_ALL}")
print(f"\t{Fore.RED}No available backup for {src}, deleting current content to avoid any conflict{Style.RESET_ALL}")
if __name__ == "__main__":