General Settings
Basic settings related to this client
diff --git a/apps/desktop/src/screens/settings/LocationSettings.tsx b/apps/desktop/src/screens/settings/LocationSettings.tsx
index 7b7a98521..dc701a7b5 100644
--- a/apps/desktop/src/screens/settings/LocationSettings.tsx
+++ b/apps/desktop/src/screens/settings/LocationSettings.tsx
@@ -1,5 +1,7 @@
import React from 'react';
import { Button } from '../../components/primitive';
+import { Dropdown } from '../../components/primitive/Dropdown';
+import DropdownMenu from '../../components/primitive/DropdownMenu';
import { InputContainer } from '../../components/primitive/InputContainer';
const exampleLocations = [
@@ -12,7 +14,7 @@ export default function LocationSettings() {
// const locations = useBridgeQuery("SysGetLocation")
return (
-
+
{/**/}
Add Location
+
diff --git a/core/prisma/migrations/20220303102833_/migration.sql b/core/prisma/migrations/20220303102833_/migration.sql
deleted file mode 100644
index ffa7a9dd5..000000000
--- a/core/prisma/migrations/20220303102833_/migration.sql
+++ /dev/null
@@ -1,117 +0,0 @@
--- CreateTable
-CREATE TABLE "libraries" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "remote_id" TEXT,
- "is_primary" BOOLEAN NOT NULL DEFAULT true,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "total_file_count" INTEGER NOT NULL DEFAULT 0,
- "total_bytes_used" TEXT NOT NULL DEFAULT '0',
- "total_byte_capacity" TEXT NOT NULL DEFAULT '0',
- "total_unique_bytes" TEXT NOT NULL DEFAULT '0',
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "timezone" TEXT
-);
-
--- CreateTable
-CREATE TABLE "clients" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "platform" INTEGER NOT NULL DEFAULT 0,
- "version" TEXT,
- "online" BOOLEAN DEFAULT true,
- "last_seen" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "timezone" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
--- CreateTable
-CREATE TABLE "locations" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "name" TEXT,
- "path" TEXT,
- "total_capacity" INTEGER,
- "available_capacity" INTEGER,
- "is_removable" BOOLEAN NOT NULL DEFAULT true,
- "is_ejectable" BOOLEAN NOT NULL DEFAULT true,
- "is_root_filesystem" BOOLEAN NOT NULL DEFAULT true,
- "is_online" BOOLEAN NOT NULL DEFAULT true,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
--- CreateTable
-CREATE TABLE "files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "location_id" INTEGER NOT NULL,
- "materialized_path" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "path_integrity_hash" TEXT NOT NULL,
- "quick_integrity_hash" TEXT,
- "full_integrity_hash" TEXT,
- "size_in_bytes" TEXT NOT NULL,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "ipfs_id" TEXT,
- "parent_id" INTEGER,
- CONSTRAINT "files_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "files_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "tags" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "name" TEXT,
- "encryption" INTEGER DEFAULT 0,
- "total_files" INTEGER DEFAULT 0,
- "redundancy_goal" INTEGER DEFAULT 1,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
--- CreateTable
-CREATE TABLE "tags_on_files" (
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "tag_id" INTEGER NOT NULL,
- "file_id" INTEGER NOT NULL,
-
- PRIMARY KEY ("tag_id", "file_id"),
- CONSTRAINT "tags_on_files_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "tags_on_files_tag_id_fkey" FOREIGN KEY ("tag_id") REFERENCES "tags" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-
--- CreateTable
-CREATE TABLE "jobs" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "client_id" INTEGER NOT NULL,
- "action" INTEGER NOT NULL,
- "status" INTEGER NOT NULL DEFAULT 0,
- "percentage_complete" INTEGER NOT NULL DEFAULT 0,
- "task_count" INTEGER NOT NULL DEFAULT 1,
- "completed_task_count" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "jobs_client_id_fkey" FOREIGN KEY ("client_id") REFERENCES "clients" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-
--- CreateTable
-CREATE TABLE "spaces" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "name" TEXT NOT NULL,
- "encryption" INTEGER DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "libraryId" INTEGER,
- CONSTRAINT "spaces_libraryId_fkey" FOREIGN KEY ("libraryId") REFERENCES "libraries" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-
--- CreateIndex
-CREATE UNIQUE INDEX "clients_uuid_key" ON "clients"("uuid");
-
--- CreateIndex
-CREATE UNIQUE INDEX "files_path_integrity_hash_key" ON "files"("path_integrity_hash");
diff --git a/core/prisma/migrations/20220303120220_/migration.sql b/core/prisma/migrations/20220303120220_/migration.sql
deleted file mode 100644
index d65287933..000000000
--- a/core/prisma/migrations/20220303120220_/migration.sql
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `full_integrity_hash` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `path_integrity_hash` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `quick_integrity_hash` on the `files` table. All the data in the column will be lost.
- - Added the required column `path_checksum` to the `files` table without a default value. This is not possible if the table is not empty.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "location_id" INTEGER NOT NULL,
- "materialized_path" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "path_checksum" TEXT NOT NULL,
- "quick_checksum" TEXT,
- "full_checksum" TEXT,
- "size_in_bytes" TEXT NOT NULL,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "ipfs_id" TEXT,
- "parent_id" INTEGER,
- CONSTRAINT "files_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "files_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_files" ("date_created", "date_indexed", "date_modified", "encryption", "extension", "id", "ipfs_id", "is_dir", "location_id", "materialized_path", "name", "parent_id", "size_in_bytes") SELECT "date_created", "date_indexed", "date_modified", "encryption", "extension", "id", "ipfs_id", "is_dir", "location_id", "materialized_path", "name", "parent_id", "size_in_bytes" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_path_checksum_key" ON "files"("path_checksum");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220303131457_/migration.sql b/core/prisma/migrations/20220303131457_/migration.sql
deleted file mode 100644
index e554da274..000000000
--- a/core/prisma/migrations/20220303131457_/migration.sql
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `materialized_path` on the `files` table. All the data in the column will be lost.
- - A unique constraint covering the columns `[uuid]` on the table `libraries` will be added. If there are existing duplicate values, this will fail.
- - Added the required column `stem` to the `files` table without a default value. This is not possible if the table is not empty.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "location_id" INTEGER NOT NULL,
- "stem" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "path_checksum" TEXT NOT NULL,
- "quick_checksum" TEXT,
- "full_checksum" TEXT,
- "size_in_bytes" TEXT NOT NULL,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "ipfs_id" TEXT,
- "parent_id" INTEGER,
- CONSTRAINT "files_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "files_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_files" ("date_created", "date_indexed", "date_modified", "encryption", "extension", "full_checksum", "id", "ipfs_id", "is_dir", "location_id", "name", "parent_id", "path_checksum", "quick_checksum", "size_in_bytes") SELECT "date_created", "date_indexed", "date_modified", "encryption", "extension", "full_checksum", "id", "ipfs_id", "is_dir", "location_id", "name", "parent_id", "path_checksum", "quick_checksum", "size_in_bytes" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_path_checksum_key" ON "files"("path_checksum");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
-
--- CreateIndex
-CREATE UNIQUE INDEX "libraries_uuid_key" ON "libraries"("uuid");
diff --git a/core/prisma/migrations/20220304090731_/migration.sql b/core/prisma/migrations/20220304090731_/migration.sql
deleted file mode 100644
index 1aad1ccaa..000000000
--- a/core/prisma/migrations/20220304090731_/migration.sql
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `total_byte_capacity` on the `libraries` table. All the data in the column will be lost.
- - You are about to drop the column `total_bytes_used` on the `libraries` table. All the data in the column will be lost.
- - You are about to drop the column `total_file_count` on the `libraries` table. All the data in the column will be lost.
- - You are about to drop the column `total_unique_bytes` on the `libraries` table. All the data in the column will be lost.
-
-*/
--- CreateTable
-CREATE TABLE "library_statistics" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "date_captured" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "library_id" INTEGER NOT NULL,
- "total_file_count" INTEGER NOT NULL DEFAULT 0,
- "total_bytes_used" TEXT NOT NULL DEFAULT '0',
- "total_byte_capacity" TEXT NOT NULL DEFAULT '0',
- "total_unique_bytes" TEXT NOT NULL DEFAULT '0'
-);
-
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_libraries" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "remote_id" TEXT,
- "is_primary" BOOLEAN NOT NULL DEFAULT true,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "timezone" TEXT
-);
-INSERT INTO "new_libraries" ("date_created", "encryption", "id", "is_primary", "name", "remote_id", "timezone", "uuid") SELECT "date_created", "encryption", "id", "is_primary", "name", "remote_id", "timezone", "uuid" FROM "libraries";
-DROP TABLE "libraries";
-ALTER TABLE "new_libraries" RENAME TO "libraries";
-CREATE UNIQUE INDEX "libraries_uuid_key" ON "libraries"("uuid");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
-
--- CreateIndex
-CREATE UNIQUE INDEX "library_statistics_library_id_key" ON "library_statistics"("library_id");
diff --git a/core/prisma/migrations/20220304104946_/migration.sql b/core/prisma/migrations/20220304104946_/migration.sql
deleted file mode 100644
index ab18a3f33..000000000
--- a/core/prisma/migrations/20220304104946_/migration.sql
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `total_byte_capacity` on the `library_statistics` table. All the data in the column will be lost.
- - You are about to drop the column `total_bytes_used` on the `library_statistics` table. All the data in the column will be lost.
- - You are about to drop the column `total_file_count` on the `library_statistics` table. All the data in the column will be lost.
- - You are about to drop the column `total_unique_bytes` on the `library_statistics` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_libraries" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "remote_id" TEXT,
- "is_primary" BOOLEAN NOT NULL DEFAULT true,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "timezone" TEXT,
- "total_file_count" INTEGER NOT NULL DEFAULT 0,
- "total_bytes_used" TEXT NOT NULL DEFAULT '0',
- "total_byte_capacity" TEXT NOT NULL DEFAULT '0',
- "total_unique_bytes" TEXT NOT NULL DEFAULT '0'
-);
-INSERT INTO "new_libraries" ("date_created", "encryption", "id", "is_primary", "name", "remote_id", "timezone", "uuid") SELECT "date_created", "encryption", "id", "is_primary", "name", "remote_id", "timezone", "uuid" FROM "libraries";
-DROP TABLE "libraries";
-ALTER TABLE "new_libraries" RENAME TO "libraries";
-CREATE UNIQUE INDEX "libraries_uuid_key" ON "libraries"("uuid");
-CREATE TABLE "new_library_statistics" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "date_captured" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "library_id" INTEGER NOT NULL
-);
-INSERT INTO "new_library_statistics" ("date_captured", "id", "library_id") SELECT "date_captured", "id", "library_id" FROM "library_statistics";
-DROP TABLE "library_statistics";
-ALTER TABLE "new_library_statistics" RENAME TO "library_statistics";
-CREATE UNIQUE INDEX "library_statistics_library_id_key" ON "library_statistics"("library_id");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220304120710_/migration.sql b/core/prisma/migrations/20220304120710_/migration.sql
deleted file mode 100644
index b9c92f15b..000000000
--- a/core/prisma/migrations/20220304120710_/migration.sql
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `total_byte_capacity` on the `libraries` table. All the data in the column will be lost.
- - You are about to drop the column `total_bytes_used` on the `libraries` table. All the data in the column will be lost.
- - You are about to drop the column `total_file_count` on the `libraries` table. All the data in the column will be lost.
- - You are about to drop the column `total_unique_bytes` on the `libraries` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_library_statistics" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "date_captured" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "library_id" INTEGER NOT NULL,
- "total_file_count" INTEGER NOT NULL DEFAULT 0,
- "total_bytes_used" TEXT NOT NULL DEFAULT '0',
- "total_byte_capacity" TEXT NOT NULL DEFAULT '0',
- "total_unique_bytes" TEXT NOT NULL DEFAULT '0'
-);
-INSERT INTO "new_library_statistics" ("date_captured", "id", "library_id") SELECT "date_captured", "id", "library_id" FROM "library_statistics";
-DROP TABLE "library_statistics";
-ALTER TABLE "new_library_statistics" RENAME TO "library_statistics";
-CREATE UNIQUE INDEX "library_statistics_library_id_key" ON "library_statistics"("library_id");
-CREATE TABLE "new_libraries" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "remote_id" TEXT,
- "is_primary" BOOLEAN NOT NULL DEFAULT true,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "timezone" TEXT
-);
-INSERT INTO "new_libraries" ("date_created", "encryption", "id", "is_primary", "name", "remote_id", "timezone", "uuid") SELECT "date_created", "encryption", "id", "is_primary", "name", "remote_id", "timezone", "uuid" FROM "libraries";
-DROP TABLE "libraries";
-ALTER TABLE "new_libraries" RENAME TO "libraries";
-CREATE UNIQUE INDEX "libraries_uuid_key" ON "libraries"("uuid");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220304124103_/migration.sql b/core/prisma/migrations/20220304124103_/migration.sql
deleted file mode 100644
index 084dfbb46..000000000
--- a/core/prisma/migrations/20220304124103_/migration.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `path_checksum` on the `files` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "location_id" INTEGER NOT NULL,
- "stem" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "quick_checksum" TEXT,
- "full_checksum" TEXT,
- "size_in_bytes" TEXT NOT NULL,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "ipfs_id" TEXT,
- "parent_id" INTEGER,
- CONSTRAINT "files_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "files_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_files" ("date_created", "date_indexed", "date_modified", "encryption", "extension", "full_checksum", "id", "ipfs_id", "is_dir", "location_id", "name", "parent_id", "quick_checksum", "size_in_bytes", "stem") SELECT "date_created", "date_indexed", "date_modified", "encryption", "extension", "full_checksum", "id", "ipfs_id", "is_dir", "location_id", "name", "parent_id", "quick_checksum", "size_in_bytes", "stem" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_location_id_stem_name_extension_key" ON "files"("location_id", "stem", "name", "extension");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220315120620_/migration.sql b/core/prisma/migrations/20220315120620_/migration.sql
deleted file mode 100644
index 294071e26..000000000
--- a/core/prisma/migrations/20220315120620_/migration.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `percentage_complete` on the `jobs` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_jobs" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "client_id" INTEGER NOT NULL,
- "action" INTEGER NOT NULL,
- "status" INTEGER NOT NULL DEFAULT 0,
- "task_count" INTEGER NOT NULL DEFAULT 1,
- "completed_task_count" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "jobs_client_id_fkey" FOREIGN KEY ("client_id") REFERENCES "clients" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-INSERT INTO "new_jobs" ("action", "client_id", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count") SELECT "action", "client_id", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count" FROM "jobs";
-DROP TABLE "jobs";
-ALTER TABLE "new_jobs" RENAME TO "jobs";
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220321193637_refactored_files/migration.sql b/core/prisma/migrations/20220321193637_refactored_files/migration.sql
deleted file mode 100644
index 1a4251506..000000000
--- a/core/prisma/migrations/20220321193637_refactored_files/migration.sql
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `full_checksum` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `is_dir` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `location_id` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `parent_id` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `quick_checksum` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `stem` on the `files` table. All the data in the column will be lost.
- - Added the required column `file_hash` to the `files` table without a default value. This is not possible if the table is not empty.
-
-*/
--- CreateTable
-CREATE TABLE "file_paths" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "materialized_path" TEXT NOT NULL,
- "file_id" INTEGER,
- "logical_file_parent_id" INTEGER,
- "location_id" INTEGER NOT NULL,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "permissions" TEXT,
- CONSTRAINT "file_paths_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "file_paths_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "file_paths_logical_file_parent_id_fkey" FOREIGN KEY ("logical_file_parent_id") REFERENCES "file_paths" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "labels" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "name" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
--- CreateTable
-CREATE TABLE "label_on_files" (
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "label_id" INTEGER NOT NULL,
- "file_id" INTEGER NOT NULL,
-
- PRIMARY KEY ("label_id", "file_id"),
- CONSTRAINT "label_on_files_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "label_on_files_label_id_fkey" FOREIGN KEY ("label_id") REFERENCES "labels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-
--- CreateTable
-CREATE TABLE "albums" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "name" TEXT NOT NULL,
- "is_hidden" BOOLEAN NOT NULL DEFAULT false,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
--- CreateTable
-CREATE TABLE "comments" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "content" TEXT NOT NULL,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "file_id" INTEGER,
- CONSTRAINT "comments_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "file_hash" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "checksum" TEXT,
- "size_in_bytes" TEXT NOT NULL,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "ipfs_id" TEXT
-);
-INSERT INTO "new_files" ("date_created", "date_indexed", "date_modified", "encryption", "extension", "id", "ipfs_id", "name", "size_in_bytes") SELECT "date_created", "date_indexed", "date_modified", "encryption", "extension", "id", "ipfs_id", "name", "size_in_bytes" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_file_hash_key" ON "files"("file_hash");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
-
--- CreateIndex
-CREATE UNIQUE INDEX "file_paths_location_id_materialized_path_file_id_key" ON "file_paths"("location_id", "materialized_path", "file_id");
diff --git a/core/prisma/migrations/20220321212645_/migration.sql b/core/prisma/migrations/20220321212645_/migration.sql
deleted file mode 100644
index 15d416713..000000000
--- a/core/prisma/migrations/20220321212645_/migration.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `logical_file_parent_id` on the `file_paths` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_file_paths" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "materialized_path" TEXT NOT NULL,
- "file_id" INTEGER,
- "parent_id" INTEGER,
- "location_id" INTEGER NOT NULL,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "permissions" TEXT,
- CONSTRAINT "file_paths_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "file_paths_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "file_paths_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "file_paths" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_file_paths" ("date_created", "date_indexed", "date_modified", "file_id", "id", "is_dir", "location_id", "materialized_path", "permissions") SELECT "date_created", "date_indexed", "date_modified", "file_id", "id", "is_dir", "location_id", "materialized_path", "permissions" FROM "file_paths";
-DROP TABLE "file_paths";
-ALTER TABLE "new_file_paths" RENAME TO "file_paths";
-CREATE UNIQUE INDEX "file_paths_location_id_materialized_path_file_id_key" ON "file_paths"("location_id", "materialized_path", "file_id");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220321230705_/migration.sql b/core/prisma/migrations/20220321230705_/migration.sql
deleted file mode 100644
index 7ee6fb0af..000000000
--- a/core/prisma/migrations/20220321230705_/migration.sql
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `file_hash` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `date_created` on the `file_paths` table. All the data in the column will be lost.
- - You are about to drop the column `date_modified` on the `file_paths` table. All the data in the column will be lost.
- - Added the required column `id_hash` to the `files` table without a default value. This is not possible if the table is not empty.
-
-*/
--- AlterTable
-ALTER TABLE "locations" ADD COLUMN "disk_type" INTEGER;
-ALTER TABLE "locations" ADD COLUMN "filesystem" TEXT;
-
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "id_hash" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "checksum" TEXT,
- "size_in_bytes" TEXT NOT NULL,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "ipfs_id" TEXT
-);
-INSERT INTO "new_files" ("checksum", "date_created", "date_indexed", "date_modified", "encryption", "extension", "id", "ipfs_id", "name", "size_in_bytes") SELECT "checksum", "date_created", "date_indexed", "date_modified", "encryption", "extension", "id", "ipfs_id", "name", "size_in_bytes" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_id_hash_key" ON "files"("id_hash");
-CREATE TABLE "new_file_paths" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "materialized_path" TEXT NOT NULL,
- "file_id" INTEGER,
- "parent_id" INTEGER,
- "location_id" INTEGER NOT NULL,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "permissions" TEXT,
- CONSTRAINT "file_paths_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "file_paths_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "file_paths_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "file_paths" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_file_paths" ("date_indexed", "file_id", "id", "is_dir", "location_id", "materialized_path", "parent_id", "permissions") SELECT "date_indexed", "file_id", "id", "is_dir", "location_id", "materialized_path", "parent_id", "permissions" FROM "file_paths";
-DROP TABLE "file_paths";
-ALTER TABLE "new_file_paths" RENAME TO "file_paths";
-CREATE UNIQUE INDEX "file_paths_location_id_materialized_path_file_id_key" ON "file_paths"("location_id", "materialized_path", "file_id");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220325225157_/migration.sql b/core/prisma/migrations/20220325225157_/migration.sql
deleted file mode 100644
index 6de227abf..000000000
--- a/core/prisma/migrations/20220325225157_/migration.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `path` on the `locations` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_locations" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "name" TEXT,
- "local_path" TEXT,
- "total_capacity" INTEGER,
- "available_capacity" INTEGER,
- "filesystem" TEXT,
- "disk_type" INTEGER,
- "is_removable" BOOLEAN NOT NULL DEFAULT true,
- "is_ejectable" BOOLEAN NOT NULL DEFAULT true,
- "is_root_filesystem" BOOLEAN NOT NULL DEFAULT true,
- "is_online" BOOLEAN NOT NULL DEFAULT true,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_locations" ("available_capacity", "date_created", "disk_type", "filesystem", "id", "is_ejectable", "is_online", "is_removable", "is_root_filesystem", "name", "total_capacity") SELECT "available_capacity", "date_created", "disk_type", "filesystem", "id", "is_ejectable", "is_online", "is_removable", "is_root_filesystem", "name", "total_capacity" FROM "locations";
-DROP TABLE "locations";
-ALTER TABLE "new_locations" RENAME TO "locations";
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220326080900_/migration.sql b/core/prisma/migrations/20220326080900_/migration.sql
deleted file mode 100644
index 77279800c..000000000
--- a/core/prisma/migrations/20220326080900_/migration.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `client_id` on the `jobs` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_jobs" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "action" INTEGER NOT NULL,
- "status" INTEGER NOT NULL DEFAULT 0,
- "task_count" INTEGER NOT NULL DEFAULT 1,
- "completed_task_count" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_jobs" ("action", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count") SELECT "action", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count" FROM "jobs";
-DROP TABLE "jobs";
-ALTER TABLE "new_jobs" RENAME TO "jobs";
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220327001019_/migration.sql b/core/prisma/migrations/20220327001019_/migration.sql
deleted file mode 100644
index a524b67b3..000000000
--- a/core/prisma/migrations/20220327001019_/migration.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- Warnings:
-
- - The primary key for the `jobs` table will be changed. If it partially fails, the table could be left without primary key constraint.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_jobs" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "action" INTEGER NOT NULL,
- "status" INTEGER NOT NULL DEFAULT 0,
- "task_count" INTEGER NOT NULL DEFAULT 1,
- "completed_task_count" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_jobs" ("action", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count") SELECT "action", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count" FROM "jobs";
-DROP TABLE "jobs";
-ALTER TABLE "new_jobs" RENAME TO "jobs";
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220327005808_/migration.sql b/core/prisma/migrations/20220327005808_/migration.sql
deleted file mode 100644
index ed40fd76a..000000000
--- a/core/prisma/migrations/20220327005808_/migration.sql
+++ /dev/null
@@ -1,17 +0,0 @@
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_jobs" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "action" INTEGER NOT NULL,
- "status" INTEGER NOT NULL DEFAULT 0,
- "task_count" INTEGER NOT NULL DEFAULT 1,
- "completed_task_count" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "seconds_elapsed" INTEGER NOT NULL DEFAULT 0
-);
-INSERT INTO "new_jobs" ("action", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count") SELECT "action", "completed_task_count", "date_created", "date_modified", "id", "status", "task_count" FROM "jobs";
-DROP TABLE "jobs";
-ALTER TABLE "new_jobs" RENAME TO "jobs";
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220329045012_/migration.sql b/core/prisma/migrations/20220329045012_/migration.sql
deleted file mode 100644
index 040625797..000000000
--- a/core/prisma/migrations/20220329045012_/migration.sql
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `extension` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `id_hash` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `name` on the `files` table. All the data in the column will be lost.
- - Added the required column `partial_checksum` to the `files` table without a default value. This is not possible if the table is not empty.
- - Added the required column `name` to the `file_paths` table without a default value. This is not possible if the table is not empty.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "type" INTEGER NOT NULL DEFAULT 0,
- "size_in_bytes" TEXT NOT NULL,
- "partial_checksum" TEXT NOT NULL,
- "checksum" TEXT,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "ipfs_id" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_files" ("checksum", "date_created", "date_indexed", "date_modified", "encryption", "id", "ipfs_id", "size_in_bytes") SELECT "checksum", "date_created", "date_indexed", "date_modified", "encryption", "id", "ipfs_id", "size_in_bytes" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_checksum_key" ON "files"("checksum");
-CREATE TABLE "new_file_paths" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "location_id" INTEGER NOT NULL,
- "materialized_path" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "file_id" INTEGER,
- "parent_id" INTEGER,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "permissions" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "file_paths_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
- CONSTRAINT "file_paths_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "file_paths_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "file_paths" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_file_paths" ("date_indexed", "file_id", "id", "is_dir", "location_id", "materialized_path", "parent_id", "permissions") SELECT "date_indexed", "file_id", "id", "is_dir", "location_id", "materialized_path", "parent_id", "permissions" FROM "file_paths";
-DROP TABLE "file_paths";
-ALTER TABLE "new_file_paths" RENAME TO "file_paths";
-CREATE UNIQUE INDEX "file_paths_location_id_materialized_path_name_extension_key" ON "file_paths"("location_id", "materialized_path", "name", "extension");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220401064231_/migration.sql b/core/prisma/migrations/20220401064231_/migration.sql
deleted file mode 100644
index 011dd4707..000000000
--- a/core/prisma/migrations/20220401064231_/migration.sql
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `type` on the `files` table. All the data in the column will be lost.
-
-*/
--- AlterTable
-ALTER TABLE "file_paths" ADD COLUMN "temp_checksum" TEXT;
-
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "kind" INTEGER NOT NULL DEFAULT 0,
- "size_in_bytes" TEXT NOT NULL,
- "partial_checksum" TEXT NOT NULL,
- "checksum" TEXT,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "ipfs_id" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_files" ("checksum", "date_created", "date_indexed", "date_modified", "encryption", "id", "ipfs_id", "partial_checksum", "size_in_bytes") SELECT "checksum", "date_created", "date_indexed", "date_modified", "encryption", "id", "ipfs_id", "partial_checksum", "size_in_bytes" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_checksum_key" ON "files"("checksum");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220412050513_/migration.sql b/core/prisma/migrations/20220412050513_/migration.sql
deleted file mode 100644
index 116eb425f..000000000
--- a/core/prisma/migrations/20220412050513_/migration.sql
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `checksum` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `partial_checksum` on the `files` table. All the data in the column will be lost.
- - You are about to drop the column `temp_checksum` on the `file_paths` table. All the data in the column will be lost.
- - Added the required column `cas_id` to the `files` table without a default value. This is not possible if the table is not empty.
- - Added the required column `uuid` to the `labels` table without a default value. This is not possible if the table is not empty.
- - Added the required column `uuid` to the `albums` table without a default value. This is not possible if the table is not empty.
- - Added the required column `uuid` to the `locations` table without a default value. This is not possible if the table is not empty.
- - Added the required column `uuid` to the `spaces` table without a default value. This is not possible if the table is not empty.
- - Added the required column `client_id` to the `jobs` table without a default value. This is not possible if the table is not empty.
- - Added the required column `uuid` to the `comments` table without a default value. This is not possible if the table is not empty.
- - Added the required column `uuid` to the `tags` table without a default value. This is not possible if the table is not empty.
-
-*/
--- CreateTable
-CREATE TABLE "sync_events" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "client_id" INTEGER NOT NULL,
- "timestamp" TEXT NOT NULL,
- "data" TEXT NOT NULL,
- CONSTRAINT "sync_events_client_id_fkey" FOREIGN KEY ("client_id") REFERENCES "clients" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "media_data" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "pixel_width" INTEGER,
- "pixel_height" INTEGER,
- "longitude" REAL,
- "latitude" REAL,
- "capture_device" TEXT,
- "duration" INTEGER,
- CONSTRAINT "media_data_id_fkey" FOREIGN KEY ("id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_files" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "cas_id" TEXT NOT NULL,
- "integrity_checksum" TEXT,
- "kind" INTEGER NOT NULL DEFAULT 0,
- "size_in_bytes" TEXT NOT NULL,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "hidden" BOOLEAN NOT NULL DEFAULT false,
- "favorite" BOOLEAN NOT NULL DEFAULT false,
- "important" BOOLEAN NOT NULL DEFAULT false,
- "has_thumbnail" BOOLEAN NOT NULL DEFAULT false,
- "has_thumbstrip" BOOLEAN NOT NULL DEFAULT false,
- "has_video_preview" BOOLEAN NOT NULL DEFAULT false,
- "ipfs_id" TEXT,
- "comment" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_files" ("date_created", "date_indexed", "date_modified", "encryption", "id", "ipfs_id", "kind", "size_in_bytes") SELECT "date_created", "date_indexed", "date_modified", "encryption", "id", "ipfs_id", "kind", "size_in_bytes" FROM "files";
-DROP TABLE "files";
-ALTER TABLE "new_files" RENAME TO "files";
-CREATE UNIQUE INDEX "files_integrity_checksum_key" ON "files"("integrity_checksum");
-CREATE TABLE "new_labels" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_labels" ("date_created", "date_modified", "id", "name") SELECT "date_created", "date_modified", "id", "name" FROM "labels";
-DROP TABLE "labels";
-ALTER TABLE "new_labels" RENAME TO "labels";
-CREATE UNIQUE INDEX "labels_uuid_key" ON "labels"("uuid");
-CREATE TABLE "new_file_paths" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "is_dir" BOOLEAN NOT NULL DEFAULT false,
- "location_id" INTEGER NOT NULL,
- "materialized_path" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "extension" TEXT,
- "file_id" INTEGER,
- "parent_id" INTEGER,
- "encryption" INTEGER NOT NULL DEFAULT 0,
- "permissions" TEXT,
- "temp_cas_id" TEXT,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "file_paths_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "file_paths_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "file_paths_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "file_paths" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_file_paths" ("date_created", "date_indexed", "date_modified", "encryption", "extension", "file_id", "id", "is_dir", "location_id", "materialized_path", "name", "parent_id", "permissions") SELECT "date_created", "date_indexed", "date_modified", "encryption", "extension", "file_id", "id", "is_dir", "location_id", "materialized_path", "name", "parent_id", "permissions" FROM "file_paths";
-DROP TABLE "file_paths";
-ALTER TABLE "new_file_paths" RENAME TO "file_paths";
-CREATE UNIQUE INDEX "file_paths_location_id_materialized_path_name_extension_key" ON "file_paths"("location_id", "materialized_path", "name", "extension");
-CREATE TABLE "new_albums" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "is_hidden" BOOLEAN NOT NULL DEFAULT false,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_albums" ("date_created", "date_modified", "id", "is_hidden", "name") SELECT "date_created", "date_modified", "id", "is_hidden", "name" FROM "albums";
-DROP TABLE "albums";
-ALTER TABLE "new_albums" RENAME TO "albums";
-CREATE UNIQUE INDEX "albums_uuid_key" ON "albums"("uuid");
-CREATE TABLE "new_locations" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "client_id" INTEGER,
- "name" TEXT,
- "local_path" TEXT,
- "total_capacity" INTEGER,
- "available_capacity" INTEGER,
- "filesystem" TEXT,
- "disk_type" INTEGER,
- "is_removable" BOOLEAN NOT NULL DEFAULT true,
- "is_ejectable" BOOLEAN NOT NULL DEFAULT true,
- "is_root_filesystem" BOOLEAN NOT NULL DEFAULT true,
- "is_online" BOOLEAN NOT NULL DEFAULT true,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_locations" ("available_capacity", "date_created", "disk_type", "filesystem", "id", "is_ejectable", "is_online", "is_removable", "is_root_filesystem", "local_path", "name", "total_capacity") SELECT "available_capacity", "date_created", "disk_type", "filesystem", "id", "is_ejectable", "is_online", "is_removable", "is_root_filesystem", "local_path", "name", "total_capacity" FROM "locations";
-DROP TABLE "locations";
-ALTER TABLE "new_locations" RENAME TO "locations";
-CREATE UNIQUE INDEX "locations_uuid_key" ON "locations"("uuid");
-CREATE TABLE "new_spaces" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT NOT NULL,
- "encryption" INTEGER DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "libraryId" INTEGER,
- CONSTRAINT "spaces_libraryId_fkey" FOREIGN KEY ("libraryId") REFERENCES "libraries" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_spaces" ("date_created", "date_modified", "encryption", "id", "libraryId", "name") SELECT "date_created", "date_modified", "encryption", "id", "libraryId", "name" FROM "spaces";
-DROP TABLE "spaces";
-ALTER TABLE "new_spaces" RENAME TO "spaces";
-CREATE UNIQUE INDEX "spaces_uuid_key" ON "spaces"("uuid");
-CREATE TABLE "new_jobs" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "client_id" INTEGER NOT NULL,
- "action" INTEGER NOT NULL,
- "status" INTEGER NOT NULL DEFAULT 0,
- "task_count" INTEGER NOT NULL DEFAULT 1,
- "completed_task_count" INTEGER NOT NULL DEFAULT 0,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "seconds_elapsed" INTEGER NOT NULL DEFAULT 0
-);
-INSERT INTO "new_jobs" ("action", "completed_task_count", "date_created", "date_modified", "id", "seconds_elapsed", "status", "task_count") SELECT "action", "completed_task_count", "date_created", "date_modified", "id", "seconds_elapsed", "status", "task_count" FROM "jobs";
-DROP TABLE "jobs";
-ALTER TABLE "new_jobs" RENAME TO "jobs";
-CREATE TABLE "new_comments" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "content" TEXT NOT NULL,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "file_id" INTEGER,
- CONSTRAINT "comments_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_comments" ("content", "date_created", "date_modified", "file_id", "id") SELECT "content", "date_created", "date_modified", "file_id", "id" FROM "comments";
-DROP TABLE "comments";
-ALTER TABLE "new_comments" RENAME TO "comments";
-CREATE UNIQUE INDEX "comments_uuid_key" ON "comments"("uuid");
-CREATE TABLE "new_tags" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "uuid" TEXT NOT NULL,
- "name" TEXT,
- "encryption" INTEGER DEFAULT 0,
- "total_files" INTEGER DEFAULT 0,
- "redundancy_goal" INTEGER DEFAULT 1,
- "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-INSERT INTO "new_tags" ("date_created", "date_modified", "encryption", "id", "name", "redundancy_goal", "total_files") SELECT "date_created", "date_modified", "encryption", "id", "name", "redundancy_goal", "total_files" FROM "tags";
-DROP TABLE "tags";
-ALTER TABLE "new_tags" RENAME TO "tags";
-CREATE UNIQUE INDEX "tags_uuid_key" ON "tags"("uuid");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/core/prisma/migrations/20220412101826_/migration.sql b/core/prisma/migrations/20220412101826_/migration.sql
new file mode 100644
index 000000000..7fb2b69e0
--- /dev/null
+++ b/core/prisma/migrations/20220412101826_/migration.sql
@@ -0,0 +1,250 @@
+-- CreateTable
+CREATE TABLE "sync_events" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "client_id" INTEGER NOT NULL,
+ "timestamp" TEXT NOT NULL,
+ "data" TEXT NOT NULL,
+ CONSTRAINT "sync_events_client_id_fkey" FOREIGN KEY ("client_id") REFERENCES "clients" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "libraries" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "remote_id" TEXT,
+ "is_primary" BOOLEAN NOT NULL DEFAULT true,
+ "encryption" INTEGER NOT NULL DEFAULT 0,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "timezone" TEXT
+);
+
+-- CreateTable
+CREATE TABLE "library_statistics" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "date_captured" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "library_id" INTEGER NOT NULL,
+ "total_file_count" INTEGER NOT NULL DEFAULT 0,
+ "total_bytes_used" TEXT NOT NULL DEFAULT '0',
+ "total_byte_capacity" TEXT NOT NULL DEFAULT '0',
+ "total_unique_bytes" TEXT NOT NULL DEFAULT '0'
+);
+
+-- CreateTable
+CREATE TABLE "clients" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "platform" INTEGER NOT NULL DEFAULT 0,
+ "version" TEXT,
+ "online" BOOLEAN DEFAULT true,
+ "last_seen" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "timezone" TEXT,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- CreateTable
+CREATE TABLE "locations" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "client_id" INTEGER,
+ "name" TEXT,
+ "local_path" TEXT,
+ "total_capacity" INTEGER,
+ "available_capacity" INTEGER,
+ "filesystem" TEXT,
+ "disk_type" INTEGER,
+ "is_removable" BOOLEAN NOT NULL DEFAULT true,
+ "is_ejectable" BOOLEAN NOT NULL DEFAULT true,
+ "is_root_filesystem" BOOLEAN NOT NULL DEFAULT true,
+ "is_online" BOOLEAN NOT NULL DEFAULT true,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- CreateTable
+CREATE TABLE "files" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "cas_id" TEXT NOT NULL,
+ "integrity_checksum" TEXT,
+ "kind" INTEGER NOT NULL DEFAULT 0,
+ "size_in_bytes" TEXT NOT NULL,
+ "encryption" INTEGER NOT NULL DEFAULT 0,
+ "hidden" BOOLEAN NOT NULL DEFAULT false,
+ "favorite" BOOLEAN NOT NULL DEFAULT false,
+ "important" BOOLEAN NOT NULL DEFAULT false,
+ "has_thumbnail" BOOLEAN NOT NULL DEFAULT false,
+ "has_thumbstrip" BOOLEAN NOT NULL DEFAULT false,
+ "has_video_preview" BOOLEAN NOT NULL DEFAULT false,
+ "ipfs_id" TEXT,
+ "comment" TEXT,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- CreateTable
+CREATE TABLE "file_paths" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "is_dir" BOOLEAN NOT NULL DEFAULT false,
+ "location_id" INTEGER NOT NULL,
+ "materialized_path" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "extension" TEXT,
+ "file_id" INTEGER,
+ "parent_id" INTEGER,
+ "encryption" INTEGER NOT NULL DEFAULT 0,
+ "permissions" TEXT,
+ "temp_cas_id" TEXT,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ CONSTRAINT "file_paths_location_id_fkey" FOREIGN KEY ("location_id") REFERENCES "locations" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "file_paths_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "file_paths_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "file_paths" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "media_data" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pixel_width" INTEGER,
+ "pixel_height" INTEGER,
+ "longitude" REAL,
+ "latitude" REAL,
+ "capture_device" TEXT,
+ "duration" INTEGER,
+ CONSTRAINT "media_data_id_fkey" FOREIGN KEY ("id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "tags" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "name" TEXT,
+ "encryption" INTEGER DEFAULT 0,
+ "total_files" INTEGER DEFAULT 0,
+ "redundancy_goal" INTEGER DEFAULT 1,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- CreateTable
+CREATE TABLE "tags_on_files" (
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "tag_id" INTEGER NOT NULL,
+ "file_id" INTEGER NOT NULL,
+
+ PRIMARY KEY ("tag_id", "file_id"),
+ CONSTRAINT "tags_on_files_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
+ CONSTRAINT "tags_on_files_tag_id_fkey" FOREIGN KEY ("tag_id") REFERENCES "tags" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
+);
+
+-- CreateTable
+CREATE TABLE "labels" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "name" TEXT,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- CreateTable
+CREATE TABLE "label_on_files" (
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "label_id" INTEGER NOT NULL,
+ "file_id" INTEGER NOT NULL,
+
+ PRIMARY KEY ("label_id", "file_id"),
+ CONSTRAINT "label_on_files_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
+ CONSTRAINT "label_on_files_label_id_fkey" FOREIGN KEY ("label_id") REFERENCES "labels" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
+);
+
+-- CreateTable
+CREATE TABLE "jobs" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "client_id" INTEGER NOT NULL,
+ "action" INTEGER NOT NULL,
+ "status" INTEGER NOT NULL DEFAULT 0,
+ "task_count" INTEGER NOT NULL DEFAULT 1,
+ "completed_task_count" INTEGER NOT NULL DEFAULT 0,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "seconds_elapsed" INTEGER NOT NULL DEFAULT 0,
+ CONSTRAINT "jobs_client_id_fkey" FOREIGN KEY ("client_id") REFERENCES "clients" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "spaces" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "encryption" INTEGER DEFAULT 0,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "libraryId" INTEGER,
+ CONSTRAINT "spaces_libraryId_fkey" FOREIGN KEY ("libraryId") REFERENCES "libraries" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "albums" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "is_hidden" BOOLEAN NOT NULL DEFAULT false,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+-- CreateTable
+CREATE TABLE "files_in_albums" (
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "album_id" INTEGER NOT NULL,
+ "file_id" INTEGER NOT NULL,
+
+ PRIMARY KEY ("album_id", "file_id"),
+ CONSTRAINT "files_in_albums_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
+ CONSTRAINT "files_in_albums_album_id_fkey" FOREIGN KEY ("album_id") REFERENCES "albums" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
+);
+
+-- CreateTable
+CREATE TABLE "comments" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "content" TEXT NOT NULL,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "file_id" INTEGER,
+ CONSTRAINT "comments_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "libraries_pub_id_key" ON "libraries"("pub_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "library_statistics_library_id_key" ON "library_statistics"("library_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "clients_pub_id_key" ON "clients"("pub_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "locations_pub_id_key" ON "locations"("pub_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "files_integrity_checksum_key" ON "files"("integrity_checksum");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "file_paths_location_id_materialized_path_name_extension_key" ON "file_paths"("location_id", "materialized_path", "name", "extension");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "tags_pub_id_key" ON "tags"("pub_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "labels_pub_id_key" ON "labels"("pub_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "spaces_pub_id_key" ON "spaces"("pub_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "albums_pub_id_key" ON "albums"("pub_id");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "comments_pub_id_key" ON "comments"("pub_id");
diff --git a/core/prisma/migrations/20220412114616_/migration.sql b/core/prisma/migrations/20220412114616_/migration.sql
new file mode 100644
index 000000000..6d70faebf
--- /dev/null
+++ b/core/prisma/migrations/20220412114616_/migration.sql
@@ -0,0 +1,29 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `is_ejectable` on the `locations` table. All the data in the column will be lost.
+ - You are about to drop the column `is_root_filesystem` on the `locations` table. All the data in the column will be lost.
+
+*/
+-- RedefineTables
+PRAGMA foreign_keys=OFF;
+CREATE TABLE "new_locations" (
+ "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ "pub_id" TEXT NOT NULL,
+ "client_id" INTEGER,
+ "name" TEXT,
+ "local_path" TEXT,
+ "total_capacity" INTEGER,
+ "available_capacity" INTEGER,
+ "filesystem" TEXT,
+ "disk_type" INTEGER,
+ "is_removable" BOOLEAN,
+ "is_online" BOOLEAN NOT NULL DEFAULT true,
+ "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+INSERT INTO "new_locations" ("available_capacity", "client_id", "date_created", "disk_type", "filesystem", "id", "is_online", "is_removable", "local_path", "name", "pub_id", "total_capacity") SELECT "available_capacity", "client_id", "date_created", "disk_type", "filesystem", "id", "is_online", "is_removable", "local_path", "name", "pub_id", "total_capacity" FROM "locations";
+DROP TABLE "locations";
+ALTER TABLE "new_locations" RENAME TO "locations";
+CREATE UNIQUE INDEX "locations_pub_id_key" ON "locations"("pub_id");
+PRAGMA foreign_key_check;
+PRAGMA foreign_keys=ON;
diff --git a/core/prisma/schema.prisma b/core/prisma/schema.prisma
index 06325fe05..aebbd8296 100644
--- a/core/prisma/schema.prisma
+++ b/core/prisma/schema.prisma
@@ -30,7 +30,7 @@ model SyncEvent {
model Library {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
name String
remote_id String?
is_primary Boolean @default(true)
@@ -56,7 +56,7 @@ model LibraryStatistics {
model Client {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
name String
platform Int @default(0)
version String?
@@ -64,16 +64,16 @@ model Client {
last_seen DateTime @default(now())
timezone String?
date_created DateTime @default(now())
- // jobs Job[]
sync_events SyncEvent[]
+ jobs Job[]
@@map("clients")
}
model Location {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
client_id Int?
name String?
local_path String?
@@ -81,9 +81,7 @@ model Location {
available_capacity Int?
filesystem String?
disk_type Int?
- is_removable Boolean @default(true)
- is_ejectable Boolean @default(true)
- is_root_filesystem Boolean @default(true)
+ is_removable Boolean?
is_online Boolean @default(true)
date_created DateTime @default(now())
@@ -122,11 +120,12 @@ model File {
// when this file was first indexed
date_indexed DateTime @default(now())
- file_tags TagOnFile[]
- file_labels LabelOnFile[]
- file_paths FilePath[]
- comments Comment[]
- media_data MediaData?
+ tags TagOnFile[]
+ labels LabelOnFile[]
+ albums FileInAlbum[]
+ paths FilePath[]
+ comments Comment[]
+ media_data MediaData?
@@map("files")
}
@@ -179,7 +178,7 @@ model MediaData {
model Tag {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
name String?
encryption Int? @default(0)
total_files Int? @default(0)
@@ -206,7 +205,7 @@ model TagOnFile {
model Label {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
name String?
date_created DateTime @default(now())
date_modified DateTime @default(now())
@@ -238,15 +237,15 @@ model Job {
completed_task_count Int @default(0)
date_created DateTime @default(now())
date_modified DateTime @default(now())
- // clients Client @relation(fields: [client_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
seconds_elapsed Int @default(0)
+ clients Client @relation(fields: [client_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@map("jobs")
}
model Space {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
name String
encryption Int? @default(0) // remove
date_created DateTime @default(now())
@@ -259,19 +258,34 @@ model Space {
model Album {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
name String
is_hidden Boolean @default(false)
date_created DateTime @default(now())
date_modified DateTime @default(now())
+ files FileInAlbum[]
+
@@map("albums")
}
+model FileInAlbum {
+ date_created DateTime @default(now())
+
+ album_id Int
+ album Album @relation(fields: [album_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
+
+ file_id Int
+ file File @relation(fields: [file_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
+
+ @@id([album_id, file_id])
+ @@map("files_in_albums")
+}
+
model Comment {
id Int @id @default(autoincrement())
- uuid String @unique
+ pub_id String @unique
content String
date_created DateTime @default(now())
date_modified DateTime @default(now())
diff --git a/core/src/client/mod.rs b/core/src/client/mod.rs
index 68ca09721..42e7f6e2a 100644
--- a/core/src/client/mod.rs
+++ b/core/src/client/mod.rs
@@ -51,7 +51,7 @@ pub async fn create(core: &Core) -> Result<(), ClientError> {
let client = match db
.client()
- .find_unique(prisma::Client::uuid().equals(config.client_uuid.clone()))
+ .find_unique(prisma::Client::pub_id().equals(config.client_uuid.clone()))
.exec()
.await?
{
@@ -59,7 +59,7 @@ pub async fn create(core: &Core) -> Result<(), ClientError> {
None => {
db.client()
.create_one(
- prisma::Client::uuid().set(config.client_uuid.clone()),
+ prisma::Client::pub_id().set(config.client_uuid.clone()),
prisma::Client::name().set(hostname.clone()),
vec![
prisma::Client::platform().set(platform as i32),
diff --git a/core/src/file/explorer/mod.rs b/core/src/file/explorer/mod.rs
index e90df7cb1..7423ad158 100644
--- a/core/src/file/explorer/mod.rs
+++ b/core/src/file/explorer/mod.rs
@@ -14,7 +14,7 @@ pub async fn open_dir(
let config = client::get();
// get location
- let location = get_location(ctx, location_id.clone()).await.unwrap();
+ let location = get_location(ctx, location_id.clone()).await?;
let directory = db
.file_path()
@@ -25,7 +25,7 @@ pub async fn open_dir(
])
.exec()
.await?
- .ok_or(FileError::FileNotFound(path.to_string()))?;
+ .ok_or(FileError::DirectoryNotFound(path.to_string()))?;
let files = db
.file_path()
@@ -46,10 +46,6 @@ pub async fn open_dir(
.with_extension("webp");
let exists = path.exists();
- if exists {
- println!("thumb found!! {:?}", path);
- }
-
file.has_local_thumbnail = exists;
}
contents.push(file);
diff --git a/core/src/file/mod.rs b/core/src/file/mod.rs
index 9b1ccfa56..92a5dfe2e 100644
--- a/core/src/file/mod.rs
+++ b/core/src/file/mod.rs
@@ -6,6 +6,7 @@ use ts_rs::TS;
use crate::{
crypto::encryption::EncryptionAlgorithm,
prisma::{self, FileData, FilePathData},
+ sys::SysError,
};
pub mod checksum;
pub mod explorer;
@@ -61,6 +62,10 @@ pub struct FilePath {
pub temp_cas_id: Option
,
pub has_local_thumbnail: bool,
#[ts(type = "string")]
+ pub date_created: chrono::DateTime,
+ #[ts(type = "string")]
+ pub date_modified: chrono::DateTime,
+ #[ts(type = "string")]
pub date_indexed: chrono::DateTime,
pub permissions: Option,
}
@@ -120,6 +125,8 @@ impl Into for FilePathData {
name: self.name,
extension: self.extension,
temp_cas_id: self.temp_cas_id,
+ date_created: self.date_created,
+ date_modified: self.date_modified,
}
}
}
@@ -139,4 +146,6 @@ pub enum FileError {
FileNotFound(String),
#[error("Database error")]
DatabaseError(#[from] prisma::QueryError),
+ #[error("System error")]
+ SysError(#[from] SysError),
}
diff --git a/core/src/file/thumb.rs b/core/src/file/thumb.rs
index 51a948334..0a1717fae 100644
--- a/core/src/file/thumb.rs
+++ b/core/src/file/thumb.rs
@@ -14,9 +14,11 @@ use std::fs;
use std::path::{Path, PathBuf};
use webp::*;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct ThumbnailJob {
pub location_id: i32,
+ pub path: String,
+ pub background: bool,
}
static THUMBNAIL_SIZE_FACTOR: f32 = 0.2;
@@ -39,7 +41,7 @@ impl Job for ThumbnailJob {
let root_path = location.path.unwrap();
- let image_files = get_images(&core_ctx, self.location_id).await?;
+ let image_files = get_images(&core_ctx, self.location_id, &self.path).await?;
let location_id = location.id.clone();
@@ -106,22 +108,25 @@ pub fn generate_thumbnail(file_path: &str, output_path: &PathBuf) -> Result<()>
Ok(())
}
-pub async fn get_images(ctx: &CoreContext, location_id: i32) -> Result> {
- let image_files = ctx
- .database
- .file_path()
- .find_many(vec![
- FilePath::location_id().equals(location_id),
- or!(
- FilePath::extension().equals("png".to_string()),
- FilePath::extension().equals("jpeg".to_string()),
- FilePath::extension().equals("jpg".to_string()),
- FilePath::extension().equals("gif".to_string()),
- FilePath::extension().equals("webp".to_string()),
- ),
- ])
- .exec()
- .await?;
+pub async fn get_images(
+ ctx: &CoreContext,
+ location_id: i32,
+ path: &str,
+) -> Result> {
+ let mut params = vec![
+ FilePath::location_id().equals(location_id),
+ or!(
+ FilePath::extension().equals("png".to_string()),
+ FilePath::extension().equals("jpeg".to_string()),
+ FilePath::extension().equals("jpg".to_string()),
+ FilePath::extension().equals("gif".to_string()),
+ FilePath::extension().equals("webp".to_string()),
+ ),
+ ];
+ if !path.is_empty() {
+ params.push(FilePath::materialized_path().starts_with(path.to_string()))
+ }
+ let image_files = ctx.database.file_path().find_many(params).exec().await?;
Ok(image_files)
}
diff --git a/core/src/job/jobs.rs b/core/src/job/jobs.rs
index f1c44ba2f..d5c729a41 100644
--- a/core/src/job/jobs.rs
+++ b/core/src/job/jobs.rs
@@ -5,6 +5,7 @@ use super::{
use crate::{
prisma::{self, JobData},
state::client,
+ sync::{crdt::Replicate, engine::SyncContext},
CoreContext,
};
use anyhow::Result;
@@ -145,8 +146,8 @@ impl JobReport {
.job()
.create_one(
prisma::Job::id().set(self.id.clone()),
- prisma::Job::client_id().set(config.client_id),
prisma::Job::action().set(1),
+ prisma::Job::clients().link(prisma::Client::id().equals(config.client_id)),
vec![],
)
.exec()
@@ -154,7 +155,6 @@ impl JobReport {
Ok(())
}
pub async fn update(&self, ctx: &CoreContext) -> Result<(), JobError> {
- // let config = client::get();
ctx
.database
.job()
@@ -172,6 +172,17 @@ impl JobReport {
}
}
+#[derive(Clone)]
+pub struct JobReportCreate {}
+
+#[async_trait::async_trait]
+impl Replicate for JobReport {
+ type Create = JobReportCreate;
+
+ async fn create(_data: Self::Create, ctx: SyncContext) {}
+ async fn delete(ctx: SyncContext) {}
+}
+
#[repr(i32)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, TS, Eq, PartialEq, IntEnum)]
#[ts(export)]
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 94786c04b..f1681efc2 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -53,7 +53,7 @@ impl CoreController {
})
.unwrap_or(());
// wait for response and return
- recv.await.unwrap()
+ recv.await.unwrap_or(Err(CoreError::QueryError))
}
pub async fn command(&self, command: ClientCommand) -> Result {
@@ -158,7 +158,9 @@ impl Core {
internal_channel,
};
- // p2p::listener::listen(None).await.unwrap_or(());
+ tokio::spawn(async move {
+ p2p::listener::listen(None).await.unwrap_or(());
+ });
(core, event_recv)
}
@@ -253,8 +255,12 @@ impl Core {
ClientCommand::SysVolumeUnmount { id: _ } => todo!(),
ClientCommand::LibDelete { id: _ } => todo!(),
ClientCommand::TagUpdate { name: _, color: _ } => todo!(),
- ClientCommand::GenerateThumbsForLocation { id } => {
- ctx.spawn_job(Box::new(ThumbnailJob { location_id: id }));
+ ClientCommand::GenerateThumbsForLocation { id, path } => {
+ ctx.spawn_job(Box::new(ThumbnailJob {
+ location_id: id,
+ path,
+ background: false, // fix
+ }));
CoreResponse::Success(())
}
ClientCommand::PurgeDatabase => {
@@ -267,13 +273,16 @@ impl Core {
// query sources of data
async fn exec_query(&self, query: ClientQuery) -> Result {
- info!("Core query: {:?}", query);
+ println!("Core query: {:?}", query);
let ctx = self.get_context();
Ok(match query {
// return the client state from memory
ClientQuery::ClientGetState => CoreResponse::ClientGetState(self.state.clone()),
// get system volumes without saving to library
ClientQuery::SysGetVolumes => CoreResponse::SysGetVolumes(sys::volumes::get_volumes()?),
+ ClientQuery::SysGetLocations => {
+ CoreResponse::SysGetLocations(sys::locations::get_locations(&ctx).await?)
+ }
// get location from library
ClientQuery::SysGetLocation { id } => {
CoreResponse::SysGetLocation(sys::locations::get_location(&ctx, id).await?)
@@ -292,17 +301,6 @@ impl Core {
ClientQuery::JobGetHistory => CoreResponse::JobGetHistory(Jobs::get_history(&ctx).await?),
})
}
-
- // pub fn queue(&mut self, job: JobResource) -> &mut JobResource {
- // self.job_runner.queued_jobs.push(job);
- // self.job_runner.queued_jobs.last_mut().unwrap()
- // }
- // send an event to the client
- // async fn emit_event(&mut self, event: ClientEvent) {}
-
- // pub async fn send(&self, event: CoreEvent) {
- // // self.event_channel.1.send(event).await;
- // }
}
// represents an event this library can emit
@@ -327,7 +325,7 @@ pub enum ClientCommand {
LocDelete { id: i32 },
// System
SysVolumeUnmount { id: i32 },
- GenerateThumbsForLocation { id: i32 },
+ GenerateThumbsForLocation { id: i32, path: String },
PurgeDatabase,
}
@@ -341,6 +339,7 @@ pub enum ClientQuery {
LibGetTags,
JobGetRunning,
JobGetHistory,
+ SysGetLocations,
SysGetLocation {
id: i32,
},
@@ -371,6 +370,7 @@ pub enum CoreResponse {
Success(()),
SysGetVolumes(Vec),
SysGetLocation(sys::locations::LocationResource),
+ SysGetLocations(Vec),
LibGetExplorerDir(file::DirectoryWithContents),
ClientGetState(ClientState),
LocCreate(sys::locations::LocationResource),
diff --git a/core/src/library/loader.rs b/core/src/library/loader.rs
index 9ccf9448a..edacd2fa8 100644
--- a/core/src/library/loader.rs
+++ b/core/src/library/loader.rs
@@ -30,7 +30,7 @@ pub async fn get(core: &Core) -> Result {
// get library from db
let library = match db
.library()
- .find_unique(Library::uuid().equals(library_state.library_uuid.clone()))
+ .find_unique(Library::pub_id().equals(library_state.library_uuid.clone()))
.exec()
.await?
{
@@ -87,7 +87,7 @@ pub async fn create(core: &Core, name: Option) -> Result<()> {
let _library = db
.library()
.create_one(
- Library::uuid().set(config.current_library_uuid),
+ Library::pub_id().set(config.current_library_uuid),
Library::name().set(name.unwrap_or(DEFAULT_NAME.into())),
vec![],
)
diff --git a/core/src/sys/locations.rs b/core/src/sys/locations.rs
index 9b61761dd..a3ee8122a 100644
--- a/core/src/sys/locations.rs
+++ b/core/src/sys/locations.rs
@@ -8,7 +8,7 @@ use crate::{
use anyhow::Result;
use log::info;
use serde::{Deserialize, Serialize};
-use std::{fs, io, io::Write};
+use std::{fs, io, io::Write, path::Path};
use thiserror::Error;
use ts_rs::TS;
@@ -24,9 +24,7 @@ pub struct LocationResource {
pub path: Option,
pub total_capacity: Option,
pub available_capacity: Option,
- pub is_removable: bool,
- pub is_ejectable: bool,
- pub is_root_filesystem: bool,
+ pub is_removable: Option,
pub is_online: bool,
#[ts(type = "string")]
pub date_created: chrono::DateTime,
@@ -41,8 +39,6 @@ impl Into for LocationData {
total_capacity: self.total_capacity,
available_capacity: self.available_capacity,
is_removable: self.is_removable,
- is_ejectable: self.is_ejectable,
- is_root_filesystem: self.is_root_filesystem,
is_online: self.is_online,
date_created: self.date_created,
}
@@ -78,9 +74,7 @@ pub async fn get_location(
// get location by location_id from db and include location_paths
let location = match db
.location()
- .find_first(vec![
- Location::file_paths().some(vec![FilePath::id().equals(location_id.into())])
- ])
+ .find_unique(Location::id().equals(location_id))
.exec()
.await?
{
@@ -106,6 +100,21 @@ pub async fn new_location_and_scan(
Ok(location)
}
+pub async fn get_locations(ctx: &CoreContext) -> Result, SysError> {
+ let db = &ctx.database;
+ let config = client::get();
+
+ let locations = db.location().find_many(vec![]).exec().await?;
+
+ // turn locations into LocationResource
+ let locations: Vec = locations
+ .into_iter()
+ .map(|location| location.into())
+ .collect();
+
+ Ok(locations)
+}
+
pub async fn create_location(ctx: &CoreContext, path: &str) -> Result {
let db = &ctx.database;
let config = client::get();
@@ -129,40 +138,18 @@ pub async fn create_location(ctx: &CoreContext, path: &str) -> Result volumes,
- Err(e) => Err(LocationError::VolumeReadError(e.to_string()))?,
- };
- info!("Loaded mounted volumes: {:?}", volumes);
- // find mount with matching path
- let volume = volumes
- .into_iter()
- .find(|mount| path.starts_with(&mount.mount_point));
- let volume_data = match volume {
- Some(mount) => mount,
- None => Volume::default(),
- };
-
- vec![
- Location::name().set(volume_data.name.to_string()),
- Location::total_capacity().set(volume_data.total_capacity as i32),
- Location::available_capacity().set(volume_data.available_capacity as i32),
- Location::is_ejectable().set(false), // remove this
- Location::is_removable().set(volume_data.is_removable),
- Location::is_root_filesystem().set(false), // remove this
- Location::is_online().set(true),
- Location::local_path().set(path.to_string()),
- ]
- };
+ let p = Path::new(&path);
let location = db
.location()
.create_one(
- Location::uuid().set(uuid.to_string()),
- create_location_params,
+ Location::pub_id().set(uuid.to_string()),
+ vec![
+ Location::name().set(p.file_name().unwrap().to_string_lossy().to_string()),
+ Location::is_online().set(true),
+ Location::local_path().set(path.to_string()),
+ ],
)
.exec()
.await?;
diff --git a/core/src/util/commit.rs b/core/src/util/commit.rs
index 922f36681..858a03ce6 100644
--- a/core/src/util/commit.rs
+++ b/core/src/util/commit.rs
@@ -8,37 +8,37 @@ use crate::state;
// an SQL commit to be sent to connected clients
#[derive(Serialize, Deserialize)]
pub struct Commit {
- pub id: String,
- pub timestamp: DateTime,
- pub client_uuid: String,
- pub library_uuid: String,
- pub query: String,
+ pub id: String,
+ pub timestamp: DateTime,
+ pub client_uuid: String,
+ pub library_uuid: String,
+ pub query: String,
}
impl Commit {
- pub fn new(query: String) -> Self {
- let client = state::client::get();
- let id = Uuid::new_v4().to_string();
- let timestamp = Utc::now();
- Self {
- id,
- sql,
- client_uuid: client.client_id,
- library_uuid: client.current_library_id,
- timestamp,
- }
+ pub fn new(query: String) -> Self {
+ let client = state::client::get();
+ let id = Uuid::new_v4().to_string();
+ let timestamp = Utc::now();
+ Self {
+ id,
+ sql,
+ client_uuid: client.client_id,
+ library_uuid: client.current_library_id,
+ timestamp,
}
+ }
- pub fn from_query(query: T) -> Self {
- Self::new(query.serialize_query())
- }
+ pub fn from_query(query: T) -> Self {
+ Self::new(query.serialize_query())
+ }
}
// example
fn do_something() {
- Commit::new(db.client().create_one(
- Client::uuid().set(config.client_id.clone()),
- Client::name().set(hostname.clone()),
- vec![],
- ))
+ Commit::new(db.client().create_one(
+ Client::pub_id().set(config.client_id.clone()),
+ Client::name().set(hostname.clone()),
+ vec![],
+ ))
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 35f2a1ec5..ea64803e2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -16,6 +16,8 @@ importers:
'@headlessui/react': ^1.5.0
'@heroicons/react': ^1.0.6
'@radix-ui/react-dialog': ^0.1.7
+ '@radix-ui/react-dropdown-menu': ^0.1.6
+ '@radix-ui/react-icons': ^1.1.0
'@radix-ui/react-slider': ^0.1.4
'@sd/client': workspace:*
'@sd/core': workspace:*
@@ -70,6 +72,8 @@ importers:
'@headlessui/react': 1.5.0_react-dom@18.0.0+react@18.0.0
'@heroicons/react': 1.0.6_react@18.0.0
'@radix-ui/react-dialog': 0.1.7_761282c47ea27a9f40e1344337910648
+ '@radix-ui/react-dropdown-menu': 0.1.6_761282c47ea27a9f40e1344337910648
+ '@radix-ui/react-icons': 1.1.0_react@18.0.0
'@radix-ui/react-slider': 0.1.4_react@18.0.0
'@sd/client': link:../../packages/client
'@sd/core': link:../../core
@@ -586,12 +590,29 @@ packages:
'@babel/runtime': 7.17.9
dev: false
+ /@radix-ui/popper/0.1.0:
+ resolution: {integrity: sha512-uzYeElL3w7SeNMuQpXiFlBhTT+JyaNMCwDfjKkrzugEcYrf5n52PHqncNdQPUtR42hJh8V9FsqyEDbDxkeNjJQ==}
+ dependencies:
+ '@babel/runtime': 7.17.9
+ csstype: 3.0.11
+ dev: false
+
/@radix-ui/primitive/0.1.0:
resolution: {integrity: sha512-tqxZKybwN5Fa3VzZry4G6mXAAb9aAqKmPtnVbZpL0vsBwvOHTBwsjHVPXylocYLwEtBY9SCe665bYnNB515uoA==}
dependencies:
'@babel/runtime': 7.17.9
dev: false
+ /@radix-ui/react-arrow/0.1.4_react@18.0.0:
+ resolution: {integrity: sha512-BB6XzAb7Ml7+wwpFdYVtZpK1BlMgqyafSQNGzhIpSZ4uXvXOHPlR5GP8M449JkeQzgQjv9Mp1AsJxFC0KuOtuA==}
+ peerDependencies:
+ react: ^16.8 || ^17.0
+ dependencies:
+ '@babel/runtime': 7.17.9
+ '@radix-ui/react-primitive': 0.1.4_react@18.0.0
+ react: 18.0.0
+ dev: false
+
/@radix-ui/react-collection/0.1.4_react@18.0.0:
resolution: {integrity: sha512-3muGI15IdgaDFjOcO7xX8a35HQRBRF6LH9pS6UCeZeRmbslkVeHyJRQr2rzICBUoX7zgIA0kXyMDbpQnJGyJTA==}
peerDependencies:
@@ -665,6 +686,26 @@ packages:
react: 18.0.0
dev: false
+ /@radix-ui/react-dropdown-menu/0.1.6_761282c47ea27a9f40e1344337910648:
+ resolution: {integrity: sha512-RZhtzjWwJ4ZBN7D8ek4Zn+ilHzYuYta9yIxFnbC0pfqMnSi67IQNONo1tuuNqtFh9SRHacPKc65zo+kBBlxtdg==}
+ peerDependencies:
+ react: ^16.8 || ^17.0
+ react-dom: ^16.8 || ^17.0
+ dependencies:
+ '@babel/runtime': 7.17.9
+ '@radix-ui/primitive': 0.1.0
+ '@radix-ui/react-compose-refs': 0.1.0_react@18.0.0
+ '@radix-ui/react-context': 0.1.1_react@18.0.0
+ '@radix-ui/react-id': 0.1.5_react@18.0.0
+ '@radix-ui/react-menu': 0.1.6_761282c47ea27a9f40e1344337910648
+ '@radix-ui/react-primitive': 0.1.4_react@18.0.0
+ '@radix-ui/react-use-controllable-state': 0.1.0_react@18.0.0
+ react: 18.0.0
+ react-dom: 18.0.0_react@18.0.0
+ transitivePeerDependencies:
+ - '@types/react'
+ dev: false
+
/@radix-ui/react-focus-guards/0.1.0_react@18.0.0:
resolution: {integrity: sha512-kRx/swAjEfBpQ3ns7J3H4uxpXuWCqN7MpALiSDOXiyo2vkWv0L9sxvbpZeTulINuE3CGMzicVMuNc/VWXjFKOg==}
peerDependencies:
@@ -686,6 +727,14 @@ packages:
react: 18.0.0
dev: false
+ /@radix-ui/react-icons/1.1.0_react@18.0.0:
+ resolution: {integrity: sha512-nhctV9YKN8G4HfkS3p03ml+osTBDMGKImaAJTm666hymtaWEgIPiqL7F53ivDqIO4A+20ERwUiiKJ8h3XK7uAg==}
+ peerDependencies:
+ react: ^16.x || ^17.x
+ dependencies:
+ react: 18.0.0
+ dev: false
+
/@radix-ui/react-id/0.1.5_react@18.0.0:
resolution: {integrity: sha512-IPc4H/63bes0IZ1GJJozSEkSWcDyhNGtKFWUpJ+XtaLyQ1X3x7Mf6fWwWhDcpqlYEP+5WtAvfqcyEsyjP+ZhBQ==}
peerDependencies:
@@ -696,6 +745,53 @@ packages:
react: 18.0.0
dev: false
+ /@radix-ui/react-menu/0.1.6_761282c47ea27a9f40e1344337910648:
+ resolution: {integrity: sha512-ho3+bhpr3oAFkOBJ8VkUb1BcGoiZBB3OmcWPqa6i5RTUKrzNX/d6rauochu2xDlWjiRtpVuiAcsTVOeIC4FbYQ==}
+ peerDependencies:
+ react: ^16.8 || ^17.0
+ react-dom: ^16.8 || ^17.0
+ dependencies:
+ '@babel/runtime': 7.17.9
+ '@radix-ui/primitive': 0.1.0
+ '@radix-ui/react-collection': 0.1.4_react@18.0.0
+ '@radix-ui/react-compose-refs': 0.1.0_react@18.0.0
+ '@radix-ui/react-context': 0.1.1_react@18.0.0
+ '@radix-ui/react-dismissable-layer': 0.1.5_react@18.0.0
+ '@radix-ui/react-focus-guards': 0.1.0_react@18.0.0
+ '@radix-ui/react-focus-scope': 0.1.4_react@18.0.0
+ '@radix-ui/react-id': 0.1.5_react@18.0.0
+ '@radix-ui/react-popper': 0.1.4_react@18.0.0
+ '@radix-ui/react-portal': 0.1.4_react-dom@18.0.0+react@18.0.0
+ '@radix-ui/react-presence': 0.1.2_react@18.0.0
+ '@radix-ui/react-primitive': 0.1.4_react@18.0.0
+ '@radix-ui/react-roving-focus': 0.1.5_react@18.0.0
+ '@radix-ui/react-use-callback-ref': 0.1.0_react@18.0.0
+ '@radix-ui/react-use-direction': 0.1.0_react@18.0.0
+ aria-hidden: 1.1.3
+ react: 18.0.0
+ react-dom: 18.0.0_react@18.0.0
+ react-remove-scroll: 2.4.4_@types+react@18.0.0+react@18.0.0
+ transitivePeerDependencies:
+ - '@types/react'
+ dev: false
+
+ /@radix-ui/react-popper/0.1.4_react@18.0.0:
+ resolution: {integrity: sha512-18gDYof97t8UQa7zwklG1Dr8jIdj3u+rVOQLzPi9f5i1YQak/pVGkaqw8aY+iDUknKKuZniTk/7jbAJUYlKyOw==}
+ peerDependencies:
+ react: ^16.8 || ^17.0
+ dependencies:
+ '@babel/runtime': 7.17.9
+ '@radix-ui/popper': 0.1.0
+ '@radix-ui/react-arrow': 0.1.4_react@18.0.0
+ '@radix-ui/react-compose-refs': 0.1.0_react@18.0.0
+ '@radix-ui/react-context': 0.1.1_react@18.0.0
+ '@radix-ui/react-primitive': 0.1.4_react@18.0.0
+ '@radix-ui/react-use-rect': 0.1.1_react@18.0.0
+ '@radix-ui/react-use-size': 0.1.1_react@18.0.0
+ '@radix-ui/rect': 0.1.1
+ react: 18.0.0
+ dev: false
+
/@radix-ui/react-portal/0.1.4_react-dom@18.0.0+react@18.0.0:
resolution: {integrity: sha512-MO0wRy2eYRTZ/CyOri9NANCAtAtq89DEtg90gicaTlkCfdqCLEBsLb+/q66BZQTr3xX/Vq01nnVfc/TkCqoqvw==}
peerDependencies:
@@ -730,6 +826,23 @@ packages:
react: 18.0.0
dev: false
+ /@radix-ui/react-roving-focus/0.1.5_react@18.0.0:
+ resolution: {integrity: sha512-ClwKPS5JZE+PaHCoW7eu1onvE61pDv4kO8W4t5Ra3qMFQiTJLZMdpBQUhksN//DaVygoLirz4Samdr5Y1x1FSA==}
+ peerDependencies:
+ react: ^16.8 || ^17.0
+ dependencies:
+ '@babel/runtime': 7.17.9
+ '@radix-ui/primitive': 0.1.0
+ '@radix-ui/react-collection': 0.1.4_react@18.0.0
+ '@radix-ui/react-compose-refs': 0.1.0_react@18.0.0
+ '@radix-ui/react-context': 0.1.1_react@18.0.0
+ '@radix-ui/react-id': 0.1.5_react@18.0.0
+ '@radix-ui/react-primitive': 0.1.4_react@18.0.0
+ '@radix-ui/react-use-callback-ref': 0.1.0_react@18.0.0
+ '@radix-ui/react-use-controllable-state': 0.1.0_react@18.0.0
+ react: 18.0.0
+ dev: false
+
/@radix-ui/react-slider/0.1.4_react@18.0.0:
resolution: {integrity: sha512-0z3bCcdrAi+FIcoLXS6r0ESVWuuyMnUJoCsFm7tC7Rtv95x34YtaI8YfSyQmzuMVS4rTsNtCCTZ/s727uRaVkQ==}
peerDependencies:
@@ -826,6 +939,16 @@ packages:
react: 18.0.0
dev: false
+ /@radix-ui/react-use-rect/0.1.1_react@18.0.0:
+ resolution: {integrity: sha512-kHNNXAsP3/PeszEmM/nxBBS9Jbo93sO+xuMTcRfwzXsmxT5gDXQzAiKbZQ0EecCPtJIzqvr7dlaQi/aP1PKYqQ==}
+ peerDependencies:
+ react: ^16.8 || ^17.0
+ dependencies:
+ '@babel/runtime': 7.17.9
+ '@radix-ui/rect': 0.1.1
+ react: 18.0.0
+ dev: false
+
/@radix-ui/react-use-size/0.1.1_react@18.0.0:
resolution: {integrity: sha512-pTgWM5qKBu6C7kfKxrKPoBI2zZYZmp2cSXzpUiGM3qEBQlMLtYhaY2JXdXUCxz+XmD1YEjc8oRwvyfsD4AG4WA==}
peerDependencies:
@@ -835,6 +958,12 @@ packages:
react: 18.0.0
dev: false
+ /@radix-ui/rect/0.1.1:
+ resolution: {integrity: sha512-g3hnE/UcOg7REdewduRPAK88EPuLZtaq7sA9ouu8S+YEtnyFRI16jgv6GZYe3VMoQLL1T171ebmEPtDjyxWLzw==}
+ dependencies:
+ '@babel/runtime': 7.17.9
+ dev: false
+
/@rollup/pluginutils/4.2.0:
resolution: {integrity: sha512-2WUyJNRkyH5p487pGnn4tWAsxhEFKN/pT8CMgHshd5H+IXkOnKvKZwsz5ZWz+YCXkleZRAU5kwbfgF8CPfDRqA==}
engines: {node: '>= 8.0.0'}