From d2f7a3af94406540d0c7c2c7ae4b22b664969eca Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Sun, 22 May 2022 22:02:18 -0700 Subject: [PATCH] remove migration history (#173), fix incorect name --- Cargo.lock | 81 +------- core/Cargo.toml | 2 +- .../migrations/20220412114616_/migration.sql | 29 --- .../migrations/20220414190025_/migration.sql | 29 --- .../migrations/20220422102144_/migration.sql | 32 ---- .../migrations/20220424140258_/migration.sql | 37 ---- .../migrations/20220427022704_/migration.sql | 20 -- .../migrations/20220427031052_/migration.sql | 22 --- .../migrations/20220428005649_/migration.sql | 11 -- .../migrations/20220428010556_/migration.sql | 17 -- .../migrations/20220428011018_/migration.sql | 18 -- .../migrations/20220428011741_/migration.sql | 23 --- .../migrations/20220428024611_/migration.sql | 19 -- .../migrations/20220428025318_/migration.sql | 8 - .../migrations/20220508032035_/migration.sql | 177 ------------------ .../migrations/20220508080808_/migration.sql | 83 -------- .../migrations/20220512030314_/migration.sql | 26 --- .../migration.sql | 127 +++++++++---- .../migrations/migration_table/migration.sql | 10 - core/prisma/schema.prisma | 2 +- 20 files changed, 93 insertions(+), 680 deletions(-) delete mode 100644 core/prisma/migrations/20220412114616_/migration.sql delete mode 100644 core/prisma/migrations/20220414190025_/migration.sql delete mode 100644 core/prisma/migrations/20220422102144_/migration.sql delete mode 100644 core/prisma/migrations/20220424140258_/migration.sql delete mode 100644 core/prisma/migrations/20220427022704_/migration.sql delete mode 100644 core/prisma/migrations/20220427031052_/migration.sql delete mode 100644 core/prisma/migrations/20220428005649_/migration.sql delete mode 100644 core/prisma/migrations/20220428010556_/migration.sql delete mode 100644 core/prisma/migrations/20220428011018_/migration.sql delete mode 100644 core/prisma/migrations/20220428011741_/migration.sql delete mode 100644 core/prisma/migrations/20220428024611_/migration.sql delete mode 100644 core/prisma/migrations/20220428025318_/migration.sql delete mode 100644 core/prisma/migrations/20220508032035_/migration.sql delete mode 100644 core/prisma/migrations/20220508080808_/migration.sql delete mode 100644 core/prisma/migrations/20220512030314_/migration.sql rename core/prisma/migrations/{20220412101826_ => 20220523044216_init}/migration.sql (72%) delete mode 100644 core/prisma/migrations/migration_table/migration.sql diff --git a/Cargo.lock b/Cargo.lock index 626db3070..1176189bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,12 +363,6 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" -[[package]] -name = "ascii" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" - [[package]] name = "asn1_der" version = "0.7.5" @@ -1191,19 +1185,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "combine" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" -dependencies = [ - "ascii", - "byteorder", - "either", - "memchr", - "unreachable", -] - [[package]] name = "combine" version = "4.6.3" @@ -1812,17 +1793,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "dmmf" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" -dependencies = [ - "bigdecimal 0.2.2", - "datamodel", - "serde", - "serde_json", -] - [[package]] name = "dns-parser" version = "0.8.0" @@ -2729,16 +2699,6 @@ dependencies = [ "system-deps 6.0.2", ] -[[package]] -name = "graphql-parser" -version = "0.3.0" -source = "git+https://github.com/prisma/graphql-parser?rev=6a3f58bd879065588e710cb02b5bd30c1ce182c3#6a3f58bd879065588e710cb02b5bd30c1ce182c3" -dependencies = [ - "combine 3.8.1", - "indexmap", - "thiserror", -] - [[package]] name = "gtk" version = "0.15.4" @@ -3332,7 +3292,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24967112a1e4301ca5342ea339763613a37592b8a6ce6cf2e4494537c7a42faf" dependencies = [ "cesu8", - "combine 4.6.3", + "combine", "jni-sys", "log", "thiserror", @@ -5734,16 +5694,14 @@ dependencies = [ [[package]] name = "prisma-client-rust" -version = "0.4.0" -source = "git+https://github.com/Brendonovich/prisma-client-rust.git?tag=0.4.0#4c6c4bf93c8eb5f3a16efca161983a9537e5e53b" +version = "0.4.1" +source = "git+https://github.com/Brendonovich/prisma-client-rust.git?tag=0.4.1#72326a946fa9fad4872eeeb9fa826f7acd5a0bed" dependencies = [ "chrono", "datamodel", - "graphql-parser", "prisma-models", "query-connector", "query-core", - "request-handlers", "serde", "serde_json", "thiserror", @@ -5752,7 +5710,7 @@ dependencies = [ [[package]] name = "prisma-client-rust-cli" version = "0.4.0" -source = "git+https://github.com/Brendonovich/prisma-client-rust.git?tag=0.4.0#4c6c4bf93c8eb5f3a16efca161983a9537e5e53b" +source = "git+https://github.com/Brendonovich/prisma-client-rust?tag=0.4.0#4c6c4bf93c8eb5f3a16efca161983a9537e5e53b" dependencies = [ "convert_case 0.5.0", "directories", @@ -6255,28 +6213,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "request-handlers" -version = "0.1.0" -source = "git+https://github.com/Brendonovich/prisma-engines?rev=8b94a80a2d8f12a2916fe28e3218162aa71e8539#8b94a80a2d8f12a2916fe28e3218162aa71e8539" -dependencies = [ - "bigdecimal 0.2.2", - "connection-string", - "datamodel", - "dmmf", - "futures", - "graphql-parser", - "indexmap", - "itertools", - "query-core", - "serde", - "serde_json", - "thiserror", - "tracing", - "url", - "user-facing-errors", -] - [[package]] name = "reqwest" version = "0.11.10" @@ -8174,15 +8110,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - [[package]] name = "unsigned-varint" version = "0.7.1" diff --git a/core/Cargo.toml b/core/Cargo.toml index 113e5431c..40d81df18 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -27,7 +27,7 @@ int-enum = "0.4.0" # Project dependencies ts-rs = "6.1" -prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.4.0" } +prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust.git", tag = "0.4.1" } walkdir = "^2.3.2" libp2p = { version = "0.43.0", optional = true } lazy_static = "1.4.0" diff --git a/core/prisma/migrations/20220412114616_/migration.sql b/core/prisma/migrations/20220412114616_/migration.sql deleted file mode 100644 index 6d70faebf..000000000 --- a/core/prisma/migrations/20220412114616_/migration.sql +++ /dev/null @@ -1,29 +0,0 @@ -/* - 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/migrations/20220414190025_/migration.sql b/core/prisma/migrations/20220414190025_/migration.sql deleted file mode 100644 index 80563d586..000000000 --- a/core/prisma/migrations/20220414190025_/migration.sql +++ /dev/null @@ -1,29 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `capture_device` on the `media_data` table. All the data in the column will be lost. - - You are about to drop the column `duration` on the `media_data` table. All the data in the column will be lost. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_media_data" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "pixel_width" INTEGER, - "pixel_height" INTEGER, - "longitude" REAL, - "latitude" REAL, - "fps" INTEGER, - "capture_device_make" TEXT, - "capture_device_model" TEXT, - "capture_device_software" TEXT, - "duration_seconds" INTEGER, - "codecs" TEXT, - "streams_json" TEXT, - CONSTRAINT "media_data_id_fkey" FOREIGN KEY ("id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO "new_media_data" ("id", "latitude", "longitude", "pixel_height", "pixel_width") SELECT "id", "latitude", "longitude", "pixel_height", "pixel_width" FROM "media_data"; -DROP TABLE "media_data"; -ALTER TABLE "new_media_data" RENAME TO "media_data"; -PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; diff --git a/core/prisma/migrations/20220422102144_/migration.sql b/core/prisma/migrations/20220422102144_/migration.sql deleted file mode 100644 index fddd58288..000000000 --- a/core/prisma/migrations/20220422102144_/migration.sql +++ /dev/null @@ -1,32 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `streams_json` on the `media_data` table. All the data in the column will be lost. - - A unique constraint covering the columns `[cas_id]` on the table `files` will be added. If there are existing duplicate values, this will fail. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_media_data" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "pixel_width" INTEGER, - "pixel_height" INTEGER, - "longitude" REAL, - "latitude" REAL, - "fps" INTEGER, - "capture_device_make" TEXT, - "capture_device_model" TEXT, - "capture_device_software" TEXT, - "duration_seconds" INTEGER, - "codecs" TEXT, - "streams" INTEGER, - CONSTRAINT "media_data_id_fkey" FOREIGN KEY ("id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO "new_media_data" ("capture_device_make", "capture_device_model", "capture_device_software", "codecs", "duration_seconds", "fps", "id", "latitude", "longitude", "pixel_height", "pixel_width") SELECT "capture_device_make", "capture_device_model", "capture_device_software", "codecs", "duration_seconds", "fps", "id", "latitude", "longitude", "pixel_height", "pixel_width" FROM "media_data"; -DROP TABLE "media_data"; -ALTER TABLE "new_media_data" RENAME TO "media_data"; -PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; - --- CreateIndex -CREATE UNIQUE INDEX "files_cas_id_key" ON "files"("cas_id"); diff --git a/core/prisma/migrations/20220424140258_/migration.sql b/core/prisma/migrations/20220424140258_/migration.sql deleted file mode 100644 index 2bce0eccc..000000000 --- a/core/prisma/migrations/20220424140258_/migration.sql +++ /dev/null @@ -1,37 +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. - -*/ --- CreateTable -CREATE TABLE "FileConflict" ( - "original_file_id" INTEGER NOT NULL, - "detactched_file_id" INTEGER NOT NULL -); - --- 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_bytes_capacity" TEXT NOT NULL DEFAULT '0', - "total_unique_bytes" TEXT NOT NULL DEFAULT '0', - "total_bytes_free" TEXT NOT NULL DEFAULT '0', - "preview_media_bytes" TEXT NOT NULL DEFAULT '0' -); -INSERT INTO "new_library_statistics" ("date_captured", "id", "library_id", "total_bytes_used", "total_file_count", "total_unique_bytes") SELECT "date_captured", "id", "library_id", "total_bytes_used", "total_file_count", "total_unique_bytes" 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; - --- CreateIndex -CREATE UNIQUE INDEX "FileConflict_original_file_id_key" ON "FileConflict"("original_file_id"); - --- CreateIndex -CREATE UNIQUE INDEX "FileConflict_detactched_file_id_key" ON "FileConflict"("detactched_file_id"); diff --git a/core/prisma/migrations/20220427022704_/migration.sql b/core/prisma/migrations/20220427022704_/migration.sql deleted file mode 100644 index 03e3c766d..000000000 --- a/core/prisma/migrations/20220427022704_/migration.sql +++ /dev/null @@ -1,20 +0,0 @@ --- 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, - "library_db_size" TEXT NOT NULL DEFAULT '0', - "total_bytes_used" TEXT NOT NULL DEFAULT '0', - "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', - "total_unique_bytes" TEXT NOT NULL DEFAULT '0', - "total_bytes_free" TEXT NOT NULL DEFAULT '0', - "preview_media_bytes" TEXT NOT NULL DEFAULT '0' -); -INSERT INTO "new_library_statistics" ("date_captured", "id", "library_id", "preview_media_bytes", "total_bytes_capacity", "total_bytes_free", "total_bytes_used", "total_file_count", "total_unique_bytes") SELECT "date_captured", "id", "library_id", "preview_media_bytes", "total_bytes_capacity", "total_bytes_free", "total_bytes_used", "total_file_count", "total_unique_bytes" 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/20220427031052_/migration.sql b/core/prisma/migrations/20220427031052_/migration.sql deleted file mode 100644 index c0dfdca14..000000000 --- a/core/prisma/migrations/20220427031052_/migration.sql +++ /dev/null @@ -1,22 +0,0 @@ -/* - Warnings: - - - You are about to drop the `FileConflict` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "FileConflict"; -PRAGMA foreign_keys=on; - --- CreateTable -CREATE TABLE "file_conflicts" ( - "original_file_id" INTEGER NOT NULL, - "detactched_file_id" INTEGER NOT NULL -); - --- CreateIndex -CREATE UNIQUE INDEX "file_conflicts_original_file_id_key" ON "file_conflicts"("original_file_id"); - --- CreateIndex -CREATE UNIQUE INDEX "file_conflicts_detactched_file_id_key" ON "file_conflicts"("detactched_file_id"); diff --git a/core/prisma/migrations/20220428005649_/migration.sql b/core/prisma/migrations/20220428005649_/migration.sql deleted file mode 100644 index b3152a271..000000000 --- a/core/prisma/migrations/20220428005649_/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ --- CreateTable -CREATE TABLE "Volume" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "client_id" INTEGER NOT NULL, - "name" TEXT NOT NULL, - "total_bytes_capacity" TEXT NOT NULL, - "total_bytes_available" TEXT NOT NULL, - "mount_point" TEXT NOT NULL, - "disk_type" TEXT NOT NULL, - "filesystem" TEXT NOT NULL -); diff --git a/core/prisma/migrations/20220428010556_/migration.sql b/core/prisma/migrations/20220428010556_/migration.sql deleted file mode 100644 index ae011083c..000000000 --- a/core/prisma/migrations/20220428010556_/migration.sql +++ /dev/null @@ -1,17 +0,0 @@ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Volume" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "client_id" INTEGER NOT NULL, - "name" TEXT NOT NULL, - "mount_point" TEXT NOT NULL, - "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', - "total_bytes_available" TEXT NOT NULL DEFAULT '0', - "disk_type" TEXT, - "filesystem" TEXT -); -INSERT INTO "new_Volume" ("client_id", "disk_type", "filesystem", "id", "mount_point", "name", "total_bytes_available", "total_bytes_capacity") SELECT "client_id", "disk_type", "filesystem", "id", "mount_point", "name", "total_bytes_available", "total_bytes_capacity" FROM "Volume"; -DROP TABLE "Volume"; -ALTER TABLE "new_Volume" RENAME TO "Volume"; -PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; diff --git a/core/prisma/migrations/20220428011018_/migration.sql b/core/prisma/migrations/20220428011018_/migration.sql deleted file mode 100644 index eee6ae378..000000000 --- a/core/prisma/migrations/20220428011018_/migration.sql +++ /dev/null @@ -1,18 +0,0 @@ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Volume" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "client_id" INTEGER NOT NULL, - "name" TEXT NOT NULL, - "mount_point" TEXT NOT NULL, - "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', - "total_bytes_available" TEXT NOT NULL DEFAULT '0', - "disk_type" TEXT, - "filesystem" TEXT, - "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -INSERT INTO "new_Volume" ("client_id", "disk_type", "filesystem", "id", "mount_point", "name", "total_bytes_available", "total_bytes_capacity") SELECT "client_id", "disk_type", "filesystem", "id", "mount_point", "name", "total_bytes_available", "total_bytes_capacity" FROM "Volume"; -DROP TABLE "Volume"; -ALTER TABLE "new_Volume" RENAME TO "Volume"; -PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; diff --git a/core/prisma/migrations/20220428011741_/migration.sql b/core/prisma/migrations/20220428011741_/migration.sql deleted file mode 100644 index e14743e2f..000000000 --- a/core/prisma/migrations/20220428011741_/migration.sql +++ /dev/null @@ -1,23 +0,0 @@ -/* - Warnings: - - - You are about to drop the `Volume` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "Volume"; -PRAGMA foreign_keys=on; - --- CreateTable -CREATE TABLE "volumes" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "client_id" INTEGER NOT NULL, - "name" TEXT NOT NULL, - "mount_point" TEXT NOT NULL, - "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', - "total_bytes_available" TEXT NOT NULL DEFAULT '0', - "disk_type" TEXT, - "filesystem" TEXT, - "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); diff --git a/core/prisma/migrations/20220428024611_/migration.sql b/core/prisma/migrations/20220428024611_/migration.sql deleted file mode 100644 index 5638fecf8..000000000 --- a/core/prisma/migrations/20220428024611_/migration.sql +++ /dev/null @@ -1,19 +0,0 @@ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_volumes" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "client_id" INTEGER NOT NULL, - "name" TEXT NOT NULL, - "mount_point" TEXT NOT NULL, - "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', - "total_bytes_available" TEXT NOT NULL DEFAULT '0', - "disk_type" TEXT, - "filesystem" TEXT, - "is_system" BOOLEAN NOT NULL DEFAULT false, - "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -INSERT INTO "new_volumes" ("client_id", "date_modified", "disk_type", "filesystem", "id", "mount_point", "name", "total_bytes_available", "total_bytes_capacity") SELECT "client_id", "date_modified", "disk_type", "filesystem", "id", "mount_point", "name", "total_bytes_available", "total_bytes_capacity" FROM "volumes"; -DROP TABLE "volumes"; -ALTER TABLE "new_volumes" RENAME TO "volumes"; -PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; diff --git a/core/prisma/migrations/20220428025318_/migration.sql b/core/prisma/migrations/20220428025318_/migration.sql deleted file mode 100644 index 360f688f1..000000000 --- a/core/prisma/migrations/20220428025318_/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[client_id,mount_point,name]` on the table `volumes` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "volumes_client_id_mount_point_name_key" ON "volumes"("client_id", "mount_point", "name"); diff --git a/core/prisma/migrations/20220508032035_/migration.sql b/core/prisma/migrations/20220508032035_/migration.sql deleted file mode 100644 index c6d28c320..000000000 --- a/core/prisma/migrations/20220508032035_/migration.sql +++ /dev/null @@ -1,177 +0,0 @@ -/* - Warnings: - - - You are about to drop the `clients` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the column `client_id` on the `sync_events` table. All the data in the column will be lost. - - You are about to drop the column `client_id` on the `locations` table. All the data in the column will be lost. - - You are about to drop the column `client_id` on the `jobs` table. All the data in the column will be lost. - - You are about to drop the column `encryption` on the `tags` table. All the data in the column will be lost. - - You are about to drop the column `client_id` on the `volumes` table. All the data in the column will be lost. - - Added the required column `node_id` to the `sync_events` table without a default value. This is not possible if the table is not empty. - - Added the required column `node_id` to the `jobs` table without a default value. This is not possible if the table is not empty. - - Added the required column `node_id` to the `volumes` table without a default value. This is not possible if the table is not empty. - -*/ --- DropIndex -DROP INDEX "clients_pub_id_key"; - --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "clients"; -PRAGMA foreign_keys=on; - --- CreateTable -CREATE TABLE "nodes" ( - "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 "keys" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "checksum" TEXT NOT NULL, - "name" TEXT, - "date_created" DATETIME DEFAULT CURRENT_TIMESTAMP, - "algorithm" INTEGER DEFAULT 0 -); - --- 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, - "key_id" INTEGER, - "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, - CONSTRAINT "files_key_id_fkey" FOREIGN KEY ("key_id") REFERENCES "keys" ("id") ON DELETE SET NULL ON UPDATE CASCADE -); -INSERT INTO "new_files" ("cas_id", "comment", "date_created", "date_indexed", "date_modified", "encryption", "favorite", "has_thumbnail", "has_thumbstrip", "has_video_preview", "hidden", "id", "important", "integrity_checksum", "ipfs_id", "kind", "size_in_bytes") SELECT "cas_id", "comment", "date_created", "date_indexed", "date_modified", "encryption", "favorite", "has_thumbnail", "has_thumbstrip", "has_video_preview", "hidden", "id", "important", "integrity_checksum", "ipfs_id", "kind", "size_in_bytes" FROM "files"; -DROP TABLE "files"; -ALTER TABLE "new_files" RENAME TO "files"; -CREATE UNIQUE INDEX "files_cas_id_key" ON "files"("cas_id"); -CREATE UNIQUE INDEX "files_integrity_checksum_key" ON "files"("integrity_checksum"); -CREATE TABLE "new_sync_events" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "node_id" INTEGER NOT NULL, - "timestamp" TEXT NOT NULL, - "data" TEXT NOT NULL, - CONSTRAINT "sync_events_node_id_fkey" FOREIGN KEY ("node_id") REFERENCES "nodes" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_sync_events" ("data", "id", "timestamp") SELECT "data", "id", "timestamp" FROM "sync_events"; -DROP TABLE "sync_events"; -ALTER TABLE "new_sync_events" RENAME TO "sync_events"; -CREATE TABLE "new_locations" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "pub_id" TEXT NOT NULL, - "node_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", "date_created", "disk_type", "filesystem", "id", "is_online", "is_removable", "local_path", "name", "pub_id", "total_capacity") SELECT "available_capacity", "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"); -CREATE TABLE "new_jobs" ( - "id" TEXT NOT NULL PRIMARY KEY, - "node_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_node_id_fkey" FOREIGN KEY ("node_id") REFERENCES "nodes" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); -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_tags" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "pub_id" TEXT NOT NULL, - "name" TEXT, - "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", "id", "name", "pub_id", "redundancy_goal", "total_files") SELECT "date_created", "date_modified", "id", "name", "pub_id", "redundancy_goal", "total_files" FROM "tags"; -DROP TABLE "tags"; -ALTER TABLE "new_tags" RENAME TO "tags"; -CREATE UNIQUE INDEX "tags_pub_id_key" ON "tags"("pub_id"); -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, - "key_id" INTEGER, - "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, - CONSTRAINT "file_paths_key_id_fkey" FOREIGN KEY ("key_id") REFERENCES "keys" ("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", "temp_cas_id") SELECT "date_created", "date_indexed", "date_modified", "encryption", "extension", "file_id", "id", "is_dir", "location_id", "materialized_path", "name", "parent_id", "permissions", "temp_cas_id" 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_volumes" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "node_id" INTEGER NOT NULL, - "name" TEXT NOT NULL, - "mount_point" TEXT NOT NULL, - "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', - "total_bytes_available" TEXT NOT NULL DEFAULT '0', - "disk_type" TEXT, - "filesystem" TEXT, - "is_system" BOOLEAN NOT NULL DEFAULT false, - "date_modified" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -INSERT INTO "new_volumes" ("date_modified", "disk_type", "filesystem", "id", "is_system", "mount_point", "name", "total_bytes_available", "total_bytes_capacity") SELECT "date_modified", "disk_type", "filesystem", "id", "is_system", "mount_point", "name", "total_bytes_available", "total_bytes_capacity" FROM "volumes"; -DROP TABLE "volumes"; -ALTER TABLE "new_volumes" RENAME TO "volumes"; -CREATE UNIQUE INDEX "volumes_node_id_mount_point_name_key" ON "volumes"("node_id", "mount_point", "name"); -PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; - --- CreateIndex -CREATE UNIQUE INDEX "nodes_pub_id_key" ON "nodes"("pub_id"); - --- CreateIndex -CREATE UNIQUE INDEX "keys_checksum_key" ON "keys"("checksum"); diff --git a/core/prisma/migrations/20220508080808_/migration.sql b/core/prisma/migrations/20220508080808_/migration.sql deleted file mode 100644 index 6d4087cfd..000000000 --- a/core/prisma/migrations/20220508080808_/migration.sql +++ /dev/null @@ -1,83 +0,0 @@ -/* - Warnings: - - - You are about to drop the `spaces` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the column `encryption` on the `libraries` table. All the data in the column will be lost. - - You are about to drop the column `encryption` on the `files` table. All the data in the column will be lost. - - You are about to drop the column `encryption` on the `file_paths` table. All the data in the column will be lost. - - You are about to drop the column `permissions` on the `file_paths` table. All the data in the column will be lost. - - You are about to drop the column `temp_cas_id` on the `file_paths` table. All the data in the column will be lost. - -*/ --- DropIndex -DROP INDEX "spaces_pub_id_key"; - --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "spaces"; -PRAGMA foreign_keys=on; - --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_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, - "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "timezone" TEXT -); -INSERT INTO "new_libraries" ("date_created", "id", "is_primary", "name", "pub_id", "remote_id", "timezone") SELECT "date_created", "id", "is_primary", "name", "pub_id", "remote_id", "timezone" FROM "libraries"; -DROP TABLE "libraries"; -ALTER TABLE "new_libraries" RENAME TO "libraries"; -CREATE UNIQUE INDEX "libraries_pub_id_key" ON "libraries"("pub_id"); -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, - "key_id" INTEGER, - "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, - CONSTRAINT "files_key_id_fkey" FOREIGN KEY ("key_id") REFERENCES "keys" ("id") ON DELETE SET NULL ON UPDATE CASCADE -); -INSERT INTO "new_files" ("cas_id", "comment", "date_created", "date_indexed", "date_modified", "favorite", "has_thumbnail", "has_thumbstrip", "has_video_preview", "hidden", "id", "important", "integrity_checksum", "ipfs_id", "key_id", "kind", "size_in_bytes") SELECT "cas_id", "comment", "date_created", "date_indexed", "date_modified", "favorite", "has_thumbnail", "has_thumbstrip", "has_video_preview", "hidden", "id", "important", "integrity_checksum", "ipfs_id", "key_id", "kind", "size_in_bytes" FROM "files"; -DROP TABLE "files"; -ALTER TABLE "new_files" RENAME TO "files"; -CREATE UNIQUE INDEX "files_cas_id_key" ON "files"("cas_id"); -CREATE UNIQUE INDEX "files_integrity_checksum_key" ON "files"("integrity_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, - "key_id" INTEGER, - "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, - CONSTRAINT "file_paths_key_id_fkey" FOREIGN KEY ("key_id") REFERENCES "keys" ("id") ON DELETE SET NULL ON UPDATE CASCADE -); -INSERT INTO "new_file_paths" ("date_created", "date_indexed", "date_modified", "extension", "file_id", "id", "is_dir", "key_id", "location_id", "materialized_path", "name", "parent_id") SELECT "date_created", "date_indexed", "date_modified", "extension", "file_id", "id", "is_dir", "key_id", "location_id", "materialized_path", "name", "parent_id" 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/20220512030314_/migration.sql b/core/prisma/migrations/20220512030314_/migration.sql deleted file mode 100644 index 258e9d41e..000000000 --- a/core/prisma/migrations/20220512030314_/migration.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* - Warnings: - - - Added the required column `name` to the `jobs` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_jobs" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT NOT NULL, - "node_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_node_id_fkey" FOREIGN KEY ("node_id") REFERENCES "nodes" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO "new_jobs" ("action", "completed_task_count", "date_created", "date_modified", "id", "node_id", "seconds_elapsed", "status", "task_count") SELECT "action", "completed_task_count", "date_created", "date_modified", "id", "node_id", "seconds_elapsed", "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/20220412101826_/migration.sql b/core/prisma/migrations/20220523044216_init/migration.sql similarity index 72% rename from core/prisma/migrations/20220412101826_/migration.sql rename to core/prisma/migrations/20220523044216_init/migration.sql index 7fb2b69e0..89ac9d123 100644 --- a/core/prisma/migrations/20220412101826_/migration.sql +++ b/core/prisma/migrations/20220523044216_init/migration.sql @@ -1,10 +1,22 @@ +-- CreateTable +CREATE TABLE "_migrations" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "name" TEXT NOT NULL, + "checksum" TEXT NOT NULL, + "steps_applied" INTEGER NOT NULL DEFAULT 0, + "applied_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP +); + -- CreateTable CREATE TABLE "sync_events" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "client_id" INTEGER NOT NULL, + "node_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 + "record_id" TEXT NOT NULL, + "kind" INTEGER NOT NULL, + "column" TEXT, + "value" TEXT NOT NULL, + CONSTRAINT "sync_events_node_id_fkey" FOREIGN KEY ("node_id") REFERENCES "nodes" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -- CreateTable @@ -12,9 +24,7 @@ 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 ); @@ -25,38 +35,52 @@ CREATE TABLE "library_statistics" ( "date_captured" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "library_id" INTEGER NOT NULL, "total_file_count" INTEGER NOT NULL DEFAULT 0, + "library_db_size" TEXT 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' + "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', + "total_unique_bytes" TEXT NOT NULL DEFAULT '0', + "total_bytes_free" TEXT NOT NULL DEFAULT '0', + "preview_media_bytes" TEXT NOT NULL DEFAULT '0' ); -- CreateTable -CREATE TABLE "clients" ( +CREATE TABLE "nodes" ( "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 "volumes" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "node_id" INTEGER NOT NULL, + "name" TEXT NOT NULL, + "mount_point" TEXT NOT NULL, + "total_bytes_capacity" TEXT NOT NULL DEFAULT '0', + "total_bytes_available" TEXT NOT NULL DEFAULT '0', + "disk_type" TEXT, + "filesystem" TEXT, + "is_system" BOOLEAN NOT NULL DEFAULT false, + "date_modified" 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, + "node_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_removable" BOOLEAN, "is_online" BOOLEAN NOT NULL DEFAULT true, "date_created" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ); @@ -68,7 +92,7 @@ CREATE TABLE "files" ( "integrity_checksum" TEXT, "kind" INTEGER NOT NULL DEFAULT 0, "size_in_bytes" TEXT NOT NULL, - "encryption" INTEGER NOT NULL DEFAULT 0, + "key_id" INTEGER, "hidden" BOOLEAN NOT NULL DEFAULT false, "favorite" BOOLEAN NOT NULL DEFAULT false, "important" BOOLEAN NOT NULL DEFAULT false, @@ -79,7 +103,8 @@ CREATE TABLE "files" ( "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 + "date_indexed" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT "files_key_id_fkey" FOREIGN KEY ("key_id") REFERENCES "keys" ("id") ON DELETE SET NULL ON UPDATE CASCADE ); -- CreateTable @@ -92,15 +117,29 @@ CREATE TABLE "file_paths" ( "extension" TEXT, "file_id" INTEGER, "parent_id" INTEGER, - "encryption" INTEGER NOT NULL DEFAULT 0, - "permissions" TEXT, - "temp_cas_id" TEXT, + "key_id" INTEGER, "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 + CONSTRAINT "file_paths_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "file_paths" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "file_paths_key_id_fkey" FOREIGN KEY ("key_id") REFERENCES "keys" ("id") ON DELETE SET NULL ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "file_conflicts" ( + "original_file_id" INTEGER NOT NULL, + "detactched_file_id" INTEGER NOT NULL +); + +-- CreateTable +CREATE TABLE "keys" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "checksum" TEXT NOT NULL, + "name" TEXT, + "date_created" DATETIME DEFAULT CURRENT_TIMESTAMP, + "algorithm" INTEGER DEFAULT 0 ); -- CreateTable @@ -110,8 +149,13 @@ CREATE TABLE "media_data" ( "pixel_height" INTEGER, "longitude" REAL, "latitude" REAL, - "capture_device" TEXT, - "duration" INTEGER, + "fps" INTEGER, + "capture_device_make" TEXT, + "capture_device_model" TEXT, + "capture_device_software" TEXT, + "duration_seconds" INTEGER, + "codecs" TEXT, + "streams" INTEGER, CONSTRAINT "media_data_id_fkey" FOREIGN KEY ("id") REFERENCES "files" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); @@ -120,7 +164,6 @@ 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, @@ -161,7 +204,8 @@ CREATE TABLE "label_on_files" ( -- CreateTable CREATE TABLE "jobs" ( "id" TEXT NOT NULL PRIMARY KEY, - "client_id" INTEGER NOT NULL, + "name" TEXT NOT NULL, + "node_id" INTEGER NOT NULL, "action" INTEGER NOT NULL, "status" INTEGER NOT NULL DEFAULT 0, "task_count" INTEGER NOT NULL DEFAULT 1, @@ -169,19 +213,7 @@ CREATE TABLE "jobs" ( "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 + CONSTRAINT "jobs_node_id_fkey" FOREIGN KEY ("node_id") REFERENCES "nodes" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -- CreateTable @@ -216,6 +248,9 @@ CREATE TABLE "comments" ( CONSTRAINT "comments_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "files" ("id") ON DELETE SET NULL ON UPDATE CASCADE ); +-- CreateIndex +CREATE UNIQUE INDEX "_migrations_checksum_key" ON "_migrations"("checksum"); + -- CreateIndex CREATE UNIQUE INDEX "libraries_pub_id_key" ON "libraries"("pub_id"); @@ -223,26 +258,38 @@ CREATE UNIQUE INDEX "libraries_pub_id_key" ON "libraries"("pub_id"); 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"); +CREATE UNIQUE INDEX "nodes_pub_id_key" ON "nodes"("pub_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "volumes_node_id_mount_point_name_key" ON "volumes"("node_id", "mount_point", "name"); -- CreateIndex CREATE UNIQUE INDEX "locations_pub_id_key" ON "locations"("pub_id"); +-- CreateIndex +CREATE UNIQUE INDEX "files_cas_id_key" ON "files"("cas_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 "file_conflicts_original_file_id_key" ON "file_conflicts"("original_file_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "file_conflicts_detactched_file_id_key" ON "file_conflicts"("detactched_file_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "keys_checksum_key" ON "keys"("checksum"); + -- 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"); diff --git a/core/prisma/migrations/migration_table/migration.sql b/core/prisma/migrations/migration_table/migration.sql deleted file mode 100644 index b24c95e1e..000000000 --- a/core/prisma/migrations/migration_table/migration.sql +++ /dev/null @@ -1,10 +0,0 @@ --- CreateTable -CREATE TABLE "_migrations" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "name" TEXT NOT NULL, - "checksum" TEXT NOT NULL, - "steps_applied" INTEGER NOT NULL DEFAULT 0, - "applied_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); --- CreateIndex -CREATE UNIQUE INDEX "_migrations_checksum_key" ON "_migrations"("checksum"); \ No newline at end of file diff --git a/core/prisma/schema.prisma b/core/prisma/schema.prisma index ce07fec16..2abacc2c8 100644 --- a/core/prisma/schema.prisma +++ b/core/prisma/schema.prisma @@ -25,7 +25,7 @@ model SyncEvent { // individual record pub id OR compound many-to-many pub ids record_id String // the type of operation, I.E: CREATE, UPDATE, DELETE as an enum - type Int + kind Int // the column name for atomic update operations column String? // the new value for create/update operations, msgpack encoded