mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
Merge branch 'main' into feat/mobile-ocr
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Kysely, sql } from 'kysely';
|
||||
import { ErrorMessages } from 'src/constants';
|
||||
import { DatabaseExtension } from 'src/enum';
|
||||
import { getVectorExtension } from 'src/repositories/database.repository';
|
||||
import { LoggingRepository } from 'src/repositories/logging.repository';
|
||||
import { vectorIndexQuery } from 'src/utils/database';
|
||||
@@ -107,9 +106,6 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$;`.execute(db);
|
||||
if (vectorExtension === DatabaseExtension.Vectors) {
|
||||
await sql`SET search_path TO "$user", public, vectors`.execute(db);
|
||||
}
|
||||
await sql`CREATE TYPE "assets_status_enum" AS ENUM ('active','trashed','deleted');`.execute(db);
|
||||
await sql`CREATE TYPE "sourcetype" AS ENUM ('machine-learning','exif','manual');`.execute(db);
|
||||
await sql`CREATE TABLE "users" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "email" character varying NOT NULL, "password" character varying NOT NULL DEFAULT '', "createdAt" timestamp with time zone NOT NULL DEFAULT now(), "profileImagePath" character varying NOT NULL DEFAULT '', "isAdmin" boolean NOT NULL DEFAULT false, "shouldChangePassword" boolean NOT NULL DEFAULT true, "deletedAt" timestamp with time zone, "oauthId" character varying NOT NULL DEFAULT '', "updatedAt" timestamp with time zone NOT NULL DEFAULT now(), "storageLabel" character varying, "name" character varying NOT NULL DEFAULT '', "quotaSizeInBytes" bigint, "quotaUsageInBytes" bigint NOT NULL DEFAULT 0, "status" character varying NOT NULL DEFAULT 'active', "profileChangedAt" timestamp with time zone NOT NULL DEFAULT now(), "updateId" uuid NOT NULL DEFAULT immich_uuid_v7());`.execute(
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await sql`
|
||||
ALTER TABLE asset
|
||||
ALTER COLUMN duration TYPE integer
|
||||
USING (
|
||||
CASE
|
||||
WHEN duration ~ '^\\d{2}:\\d{2}:\\d{2}\\.\\d{3}$'
|
||||
THEN substr(duration, 1, 2)::int * 3600000
|
||||
+ substr(duration, 4, 2)::int * 60000
|
||||
+ substr(duration, 7, 2)::int * 1000
|
||||
+ substr(duration, 10, 3)::int
|
||||
END
|
||||
);`.execute(db);
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await sql`
|
||||
ALTER TABLE asset
|
||||
ALTER COLUMN duration TYPE varchar
|
||||
USING (
|
||||
CASE
|
||||
WHEN duration IS NULL THEN NULL
|
||||
ELSE lpad((duration / 3600000)::text, 2, '0')
|
||||
|| ':' || lpad(((duration / 60000) % 60)::text, 2, '0')
|
||||
|| ':' || lpad(((duration / 1000) % 60)::text, 2, '0')
|
||||
|| '.' || lpad((duration % 1000)::text, 3, '0')
|
||||
END
|
||||
);`.execute(db);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await sql`CREATE TYPE "video_stream_variant_codec_enum" AS ENUM ('av1','hevc','h264');`.execute(db);
|
||||
await sql`CREATE TABLE "video_stream_session" (
|
||||
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
"assetId" uuid NOT NULL,
|
||||
"expiresAt" timestamp with time zone NOT NULL,
|
||||
"createdAt" timestamp with time zone NOT NULL DEFAULT now(),
|
||||
CONSTRAINT "video_stream_session_assetId_fkey" FOREIGN KEY ("assetId") REFERENCES "asset" ("id") ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT "video_stream_session_pkey" PRIMARY KEY ("id")
|
||||
);`.execute(db);
|
||||
await sql`CREATE INDEX "video_stream_session_assetId_idx" ON "video_stream_session" ("assetId");`.execute(db);
|
||||
await sql`CREATE INDEX "video_stream_session_expiresAt_idx" ON "video_stream_session" ("expiresAt");`.execute(db);
|
||||
await sql`CREATE TABLE "video_stream_variant" (
|
||||
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
"sessionId" uuid NOT NULL,
|
||||
"createdAt" timestamp with time zone NOT NULL DEFAULT now(),
|
||||
"bitrate" integer NOT NULL,
|
||||
"codec" video_stream_variant_codec_enum NOT NULL,
|
||||
"resolution" smallint NOT NULL,
|
||||
CONSTRAINT "video_stream_variant_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "video_stream_session" ("id") ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT "video_stream_variant_pkey" PRIMARY KEY ("id")
|
||||
);`.execute(db);
|
||||
await sql`CREATE UNIQUE INDEX "video_stream_variant_sessionId_bitrate_resolution_codec_idx" ON "video_stream_variant" ("sessionId", "bitrate", "resolution", "codec");`.execute(db);
|
||||
await sql`CREATE TABLE "video_stream_segment" (
|
||||
"variantId" uuid NOT NULL,
|
||||
"index" integer NOT NULL,
|
||||
"durationUs" integer NOT NULL,
|
||||
CONSTRAINT "video_stream_segment_variantId_fkey" FOREIGN KEY ("variantId") REFERENCES "video_stream_variant" ("id") ON UPDATE NO ACTION ON DELETE CASCADE,
|
||||
CONSTRAINT "video_stream_segment_pkey" PRIMARY KEY ("variantId", "index")
|
||||
);`.execute(db);
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await sql`DROP TABLE "video_stream_segment";`.execute(db);
|
||||
await sql`DROP TABLE "video_stream_variant";`.execute(db);
|
||||
await sql`DROP TABLE "video_stream_session";`.execute(db);
|
||||
await sql`DROP TYPE "asset_checksum_algorithm_enum";`.execute(db);
|
||||
}
|
||||
Reference in New Issue
Block a user