Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(backend): align Unicode aliases, collations and cache keys (#309)

Johan Legrandfca2766c7c10
diff --git a/backend/migrations/0006_path_collate_accents.sql b/backend/migrations/0006_path_collate_accents.sql
new file mode 100644
index 00000000..bcb717b3
--- /dev/null
+++ b/backend/migrations/0006_path_collate_accents.sql
@@ -0,0 +1,100 @@
+-- Convert both the table defaults and all existing character columns.
+ALTER TABLE `spaces` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci;
+--> statement-breakpoint
+ALTER TABLE `spaces_roots` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci;
+--> statement-breakpoint
+ALTER TABLE `shares` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci;
+--> statement-breakpoint
+ALTER TABLE `files` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci;
+--> statement-breakpoint
+ALTER TABLE `files_recents` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci;
+--> statement-breakpoint
+-- Cache values are JSON and must keep their binary collation.
+-- MariaDB uses its long UNIQUE hash index for full-key uniqueness; the prefix index supports lookups.
+ALTER TABLE `cache`
+ DROP PRIMARY KEY,
+ MODIFY COLUMN `key` varchar(8192) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci NOT NULL,
+ ADD UNIQUE KEY `cache_key_unique` (`key`),
+ ADD KEY `cache_key_prefix_idx` (`key`(768));
+--> statement-breakpoint
+-- Trash tables are created at runtime and are not part of the Drizzle snapshot.
+BEGIN NOT ATOMIC
+ DECLARE migration_done BOOLEAN DEFAULT FALSE;
+ DECLARE trash_table_name VARCHAR(64);
+ DECLARE trash_schema_name VARCHAR(64);
+ DECLARE trash_tables CURSOR FOR
+ SELECT columns_info.TABLE_NAME
+ FROM information_schema.COLUMNS AS columns_info
+ INNER JOIN information_schema.TABLES AS tables_info
+ ON tables_info.TABLE_SCHEMA = columns_info.TABLE_SCHEMA
+ AND tables_info.TABLE_NAME = columns_info.TABLE_NAME
+ WHERE columns_info.TABLE_SCHEMA = DATABASE()
+ AND tables_info.TABLE_TYPE = 'BASE TABLE'
+ AND BINARY LEFT(columns_info.TABLE_NAME, 12) = 'files_trash_'
+ AND columns_info.COLUMN_NAME = 'path'
+ AND (
+ tables_info.TABLE_COLLATION <> 'utf8mb4_uca1400_nopad_as_ci'
+ OR EXISTS (
+ SELECT 1
+ FROM information_schema.COLUMNS AS trash_columns
+ WHERE trash_columns.TABLE_SCHEMA = columns_info.TABLE_SCHEMA
+ AND trash_columns.TABLE_NAME = columns_info.TABLE_NAME
+ AND trash_columns.COLLATION_NAME <> 'utf8mb4_uca1400_nopad_as_ci'
+ )
+ )
+ ORDER BY columns_info.TABLE_NAME;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET migration_done = TRUE;
+
+ SET trash_schema_name = DATABASE();
+ OPEN trash_tables;
+ migrate_trash_tables: LOOP
+ FETCH trash_tables INTO trash_table_name;
+ IF migration_done THEN
+ LEAVE migrate_trash_tables;
+ END IF;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'ALTER TABLE `', REPLACE(trash_schema_name, '`', '``'), '`.`',
+ REPLACE(trash_table_name, '`', '``'),
+ '` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci'
+ );
+ END LOOP;
+ CLOSE trash_tables;
+END;
+--> statement-breakpoint
+-- Preserve the content collation and FULLTEXT search behavior of runtime indexes.
+BEGIN NOT ATOMIC
+ DECLARE migration_done BOOLEAN DEFAULT FALSE;
+ DECLARE content_table_name VARCHAR(64);
+ DECLARE content_schema_name VARCHAR(64);
+ DECLARE content_tables CURSOR FOR
+ SELECT DISTINCT columns_info.TABLE_NAME
+ FROM information_schema.COLUMNS AS columns_info
+ INNER JOIN information_schema.TABLES AS tables_info
+ ON tables_info.TABLE_SCHEMA = columns_info.TABLE_SCHEMA
+ AND tables_info.TABLE_NAME = columns_info.TABLE_NAME
+ WHERE columns_info.TABLE_SCHEMA = DATABASE()
+ AND tables_info.TABLE_TYPE = 'BASE TABLE'
+ AND BINARY LEFT(columns_info.TABLE_NAME, 14) = 'files_content_'
+ AND columns_info.COLUMN_NAME IN ('path', 'name')
+ AND columns_info.COLLATION_NAME <> 'utf8mb4_uca1400_nopad_as_ci'
+ ORDER BY columns_info.TABLE_NAME;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET migration_done = TRUE;
+
+ SET content_schema_name = DATABASE();
+ OPEN content_tables;
+ migrate_content_tables: LOOP
+ FETCH content_tables INTO content_table_name;
+ IF migration_done THEN
+ LEAVE migrate_content_tables;
+ END IF;
+
+ EXECUTE IMMEDIATE CONCAT(
+ 'ALTER TABLE `', REPLACE(content_schema_name, '`', '``'), '`.`',
+ REPLACE(content_table_name, '`', '``'),
+ '` MODIFY COLUMN `path` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci NOT NULL,',
+ ' MODIFY COLUMN `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci NOT NULL'
+ );
+ END LOOP;
+ CLOSE content_tables;
+END;
diff --git a/backend/migrations/meta/0006_snapshot.json b/backend/migrations/meta/0006_snapshot.json
new file mode 100644
index 00000000..ce7c2d67
--- /dev/null
+++ b/backend/migrations/meta/0006_snapshot.json
@@ -0,0 +1,2582 @@
+{
+ "version": "5",
+ "dialect": "mysql",
+ "id": "9e978c7e-6a03-48ed-8286-afa9e22a034f",
+ "prevId": "5c455ee5-18c5-484a-b7e4-32eef83589e9",
+ "tables": {
+ "cache": {
+ "name": "cache",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "varchar(8192) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expiration": {
+ "name": "expiration",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": -1
+ }
+ },
+ "indexes": {
+ "cache_key_unique": {
+ "name": "cache_key_unique",
+ "columns": [
+ "key"
+ ],
+ "isUnique": true
+ },
+ "cache_key_prefix_idx": {
+ "name": "cache_key_prefix_idx",
+ "columns": [
+ "`key`(768)"
+ ],
+ "isUnique": false
+ },
+ "expiration_idx": {
+ "name": "expiration_idx",
+ "columns": [
+ "expiration"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users": {
+ "name": "users",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "email": {
+ "name": "email",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "login": {
+ "name": "login",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "externalId": {
+ "name": "externalId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastName": {
+ "name": "lastName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "passwordAttempts": {
+ "name": "passwordAttempts",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "isActive": {
+ "name": "isActive",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "secrets": {
+ "name": "secrets",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "preferences": {
+ "name": "preferences",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "language": {
+ "name": "language",
+ "type": "varchar(10)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "notification": {
+ "name": "notification",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "onlineStatus": {
+ "name": "onlineStatus",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "currentIp": {
+ "name": "currentIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastIp": {
+ "name": "lastIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "currentAccess": {
+ "name": "currentAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastAccess": {
+ "name": "lastAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "email_idx": {
+ "name": "email_idx",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ },
+ "login_idx": {
+ "name": "login_idx",
+ "columns": [
+ "login"
+ ],
+ "isUnique": true
+ },
+ "external_id_idx": {
+ "name": "external_id_idx",
+ "columns": [
+ "externalId"
+ ],
+ "isUnique": true
+ },
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ "role"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "users_id": {
+ "name": "users_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "groups": {
+ "name": "groups",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "name_idx": {
+ "name": "name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": true
+ },
+ "parent_idx": {
+ "name": "parent_idx",
+ "columns": [
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "type_idx": {
+ "name": "type_idx",
+ "columns": [
+ "type"
+ ],
+ "isUnique": false
+ },
+ "visibility_idx": {
+ "name": "visibility_idx",
+ "columns": [
+ "visibility"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "groups_parentId_groups_id_fk": {
+ "name": "groups_parentId_groups_id_fk",
+ "tableFrom": "groups",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "parentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "groups_id": {
+ "name": "groups_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users_groups": {
+ "name": "users_groups",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "users_groups_userId_users_id_fk": {
+ "name": "users_groups_userId_users_id_fk",
+ "tableFrom": "users_groups",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "users_groups_groupId_groups_id_fk": {
+ "name": "users_groups_groupId_groups_id_fk",
+ "tableFrom": "users_groups",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_groups_userId_groupId_pk": {
+ "name": "users_groups_userId_groupId_pk",
+ "columns": [
+ "userId",
+ "groupId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users_guests": {
+ "name": "users_guests",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "guestId": {
+ "name": "guestId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "guest_id": {
+ "name": "guest_id",
+ "columns": [
+ "guestId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "users_guests_userId_users_id_fk": {
+ "name": "users_guests_userId_users_id_fk",
+ "tableFrom": "users_guests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "users_guests_guestId_users_id_fk": {
+ "name": "users_guests_guestId_users_id_fk",
+ "tableFrom": "users_guests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "guestId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_guests_userId_guestId_pk": {
+ "name": "users_guests_userId_guestId_pk",
+ "columns": [
+ "userId",
+ "guestId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {
+ "user_guest_check": {
+ "name": "user_guest_check",
+ "value": "`users_guests`.`userId` <> `users_guests`.`guestId`"
+ }
+ }
+ },
+ "spaces": {
+ "name": "spaces",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "disabledAt": {
+ "name": "disabledAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "spaces_id": {
+ "name": "spaces_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "spaces_members": {
+ "name": "spaces_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "linkId": {
+ "name": "linkId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ },
+ "link_idx": {
+ "name": "link_idx",
+ "columns": [
+ "linkId"
+ ],
+ "isUnique": false
+ },
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ "role"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "spaces_members_spaceId_spaces_id_fk": {
+ "name": "spaces_members_spaceId_spaces_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_userId_users_id_fk": {
+ "name": "spaces_members_userId_users_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_groupId_groups_id_fk": {
+ "name": "spaces_members_groupId_groups_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_linkId_links_id_fk": {
+ "name": "spaces_members_linkId_links_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "links",
+ "columnsFrom": [
+ "linkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "spaces_members_id": {
+ "name": "spaces_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "space_user_uniq": {
+ "name": "space_user_uniq",
+ "columns": [
+ "spaceId",
+ "userId"
+ ]
+ },
+ "space_group_uniq": {
+ "name": "space_group_uniq",
+ "columns": [
+ "spaceId",
+ "groupId"
+ ]
+ },
+ "space_link_uniq": {
+ "name": "space_link_uniq",
+ "columns": [
+ "spaceId",
+ "linkId"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "spaces_roots": {
+ "name": "spaces_roots",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "externalPath": {
+ "name": "externalPath",
+ "type": "varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "spaces_roots_spaceId_spaces_id_fk": {
+ "name": "spaces_roots_spaceId_spaces_id_fk",
+ "tableFrom": "spaces_roots",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_roots_fileId_files_id_fk": {
+ "name": "spaces_roots_fileId_files_id_fk",
+ "tableFrom": "spaces_roots",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "spaces_roots_id": {
+ "name": "spaces_roots_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "space_root_alias_uniq": {
+ "name": "space_root_alias_uniq",
+ "columns": [
+ "id",
+ "alias"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "shares": {
+ "name": "shares",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceRootId": {
+ "name": "spaceRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "externalPath": {
+ "name": "externalPath",
+ "type": "varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "disabledAt": {
+ "name": "disabledAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": true
+ },
+ "parent_idx": {
+ "name": "parent_idx",
+ "columns": [
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_root_idx": {
+ "name": "space_root_idx",
+ "columns": [
+ "spaceRootId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ },
+ "type_idx": {
+ "name": "type_idx",
+ "columns": [
+ "type"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "shares_ownerId_users_id_fk": {
+ "name": "shares_ownerId_users_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_parentId_shares_id_fk": {
+ "name": "shares_parentId_shares_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "parentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_spaceId_spaces_id_fk": {
+ "name": "shares_spaceId_spaces_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_spaceRootId_spaces_roots_id_fk": {
+ "name": "shares_spaceRootId_spaces_roots_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_fileId_files_id_fk": {
+ "name": "shares_fileId_files_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shares_id": {
+ "name": "shares_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "shares_members": {
+ "name": "shares_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "linkId": {
+ "name": "linkId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ },
+ "link_idx": {
+ "name": "link_idx",
+ "columns": [
+ "linkId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "shares_members_shareId_shares_id_fk": {
+ "name": "shares_members_shareId_shares_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_userId_users_id_fk": {
+ "name": "shares_members_userId_users_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_groupId_groups_id_fk": {
+ "name": "shares_members_groupId_groups_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_linkId_links_id_fk": {
+ "name": "shares_members_linkId_links_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "links",
+ "columnsFrom": [
+ "linkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shares_members_id": {
+ "name": "shares_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "share_user_uniq": {
+ "name": "share_user_uniq",
+ "columns": [
+ "shareId",
+ "userId"
+ ]
+ },
+ "share_group_uniq": {
+ "name": "share_group_uniq",
+ "columns": [
+ "shareId",
+ "groupId"
+ ]
+ },
+ "share_link_uniq": {
+ "name": "share_link_uniq",
+ "columns": [
+ "shareId",
+ "linkId"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "files": {
+ "name": "files",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceExternalRootId": {
+ "name": "spaceExternalRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareExternalId": {
+ "name": "shareExternalId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "isDir": {
+ "name": "isDir",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "inTrash": {
+ "name": "inTrash",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "mime": {
+ "name": "mime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "size": {
+ "name": "size",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "mtime": {
+ "name": "mtime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "ctime": {
+ "name": "ctime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_external_root_idx": {
+ "name": "space_external_root_idx",
+ "columns": [
+ "spaceExternalRootId"
+ ],
+ "isUnique": false
+ },
+ "share_external_idx": {
+ "name": "share_external_idx",
+ "columns": [
+ "shareExternalId"
+ ],
+ "isUnique": false
+ },
+ "name_idx": {
+ "name": "name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": false
+ },
+ "path_idx": {
+ "name": "path_idx",
+ "columns": [
+ "path"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_ownerId_users_id_fk": {
+ "name": "files_ownerId_users_id_fk",
+ "tableFrom": "files",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_spaceId_spaces_id_fk": {
+ "name": "files_spaceId_spaces_id_fk",
+ "tableFrom": "files",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_spaceExternalRootId_spaces_roots_id_fk": {
+ "name": "files_spaceExternalRootId_spaces_roots_id_fk",
+ "tableFrom": "files",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceExternalRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_shareExternalId_shares_id_fk": {
+ "name": "files_shareExternalId_shares_id_fk",
+ "tableFrom": "files",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareExternalId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "files_id": {
+ "name": "files_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "files_favorites": {
+ "name": "files_favorites",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ },
+ "user_created_idx": {
+ "name": "user_created_idx",
+ "columns": [
+ "userId",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_favorites_userId_users_id_fk": {
+ "name": "files_favorites_userId_users_id_fk",
+ "tableFrom": "files_favorites",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_favorites_fileId_files_id_fk": {
+ "name": "files_favorites_fileId_files_id_fk",
+ "tableFrom": "files_favorites",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "files_favorites_userId_fileId_pk": {
+ "name": "files_favorites_userId_fileId_pk",
+ "columns": [
+ "userId",
+ "fileId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "files_recents": {
+ "name": "files_recents",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_nopad_as_ci",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "mime": {
+ "name": "mime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mtime": {
+ "name": "mtime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "mtime_idx": {
+ "name": "mtime_idx",
+ "columns": [
+ "mtime"
+ ],
+ "isUnique": false
+ },
+ "path_idx": {
+ "name": "path_idx",
+ "columns": [
+ "path"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_recents_ownerId_users_id_fk": {
+ "name": "files_recents_ownerId_users_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_recents_spaceId_spaces_id_fk": {
+ "name": "files_recents_spaceId_spaces_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_recents_shareId_shares_id_fk": {
+ "name": "files_recents_shareId_shares_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "links": {
+ "name": "links",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "uuid": {
+ "name": "uuid",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "requireAuth": {
+ "name": "requireAuth",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "nbAccess": {
+ "name": "nbAccess",
+ "type": "int unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "limitAccess": {
+ "name": "limitAccess",
+ "type": "int unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "expiresAt": {
+ "name": "expiresAt",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "uuid_idx": {
+ "name": "uuid_idx",
+ "columns": [
+ "uuid"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "links_userId_users_id_fk": {
+ "name": "links_userId_users_id_fk",
+ "tableFrom": "links",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "links_id": {
+ "name": "links_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "comments": {
+ "name": "comments",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "comments_userId_users_id_fk": {
+ "name": "comments_userId_users_id_fk",
+ "tableFrom": "comments",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "comments_fileId_files_id_fk": {
+ "name": "comments_fileId_files_id_fk",
+ "tableFrom": "comments",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "comments_id": {
+ "name": "comments_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "notifications": {
+ "name": "notifications",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "fromUserId": {
+ "name": "fromUserId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "toUserId": {
+ "name": "toUserId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "wasRead": {
+ "name": "wasRead",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "from_user_idx": {
+ "name": "from_user_idx",
+ "columns": [
+ "fromUserId"
+ ],
+ "isUnique": false
+ },
+ "to_user_idx": {
+ "name": "to_user_idx",
+ "columns": [
+ "toUserId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "notifications_fromUserId_users_id_fk": {
+ "name": "notifications_fromUserId_users_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "users",
+ "columnsFrom": [
+ "fromUserId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notifications_toUserId_users_id_fk": {
+ "name": "notifications_toUserId_users_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "users",
+ "columnsFrom": [
+ "toUserId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "notifications_id": {
+ "name": "notifications_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "sync_clients": {
+ "name": "sync_clients",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tokenExpiration": {
+ "name": "tokenExpiration",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "info": {
+ "name": "info",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "currentIp": {
+ "name": "currentIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastIp": {
+ "name": "lastIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "currentAccess": {
+ "name": "currentAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastAccess": {
+ "name": "lastAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "token_idx": {
+ "name": "token_idx",
+ "columns": [
+ "token"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sync_clients_ownerId_users_id_fk": {
+ "name": "sync_clients_ownerId_users_id_fk",
+ "tableFrom": "sync_clients",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "sync_clients_id": {
+ "name": "sync_clients_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "sync_paths": {
+ "name": "sync_paths",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "clientId": {
+ "name": "clientId",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceRootId": {
+ "name": "spaceRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "client_idx": {
+ "name": "client_idx",
+ "columns": [
+ "clientId"
+ ],
+ "isUnique": false
+ },
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_root_idx": {
+ "name": "space_root_idx",
+ "columns": [
+ "spaceRootId"
+ ],
+ "isUnique": false
+ },
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sync_paths_clientId_sync_clients_id_fk": {
+ "name": "sync_paths_clientId_sync_clients_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "sync_clients",
+ "columnsFrom": [
+ "clientId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_ownerId_users_id_fk": {
+ "name": "sync_paths_ownerId_users_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_spaceId_spaces_id_fk": {
+ "name": "sync_paths_spaceId_spaces_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_spaceRootId_spaces_roots_id_fk": {
+ "name": "sync_paths_spaceRootId_spaces_roots_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_shareId_shares_id_fk": {
+ "name": "sync_paths_shareId_shares_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_fileId_files_id_fk": {
+ "name": "sync_paths_fileId_files_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "sync_paths_id": {
+ "name": "sync_paths_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ }
+ },
+ "views": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "tables": {},
+ "indexes": {
+ "cache_key_prefix_idx": {
+ "columns": {
+ "`key`(768)": {
+ "isExpression": true
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/backend/migrations/meta/_journal.json b/backend/migrations/meta/_journal.json
index 4b02ff23..19999eb9 100644
--- a/backend/migrations/meta/_journal.json
+++ b/backend/migrations/meta/_journal.json
@@ -43,6 +43,13 @@
"when": 1790603209539,
"tag": "0005_spotty_firebird",
"breakpoints": true
+ },
+ {
+ "idx": 6,
+ "version": "5",
+ "when": 1792446477530,
+ "tag": "0006_path_collate_accents",
+ "breakpoints": true
}
]
-}
\ No newline at end of file
+}
diff --git a/backend/src/applications/comments/services/comments-queries.service.spec.ts b/backend/src/applications/comments/services/comments-queries.service.spec.ts
new file mode 100644
index 00000000..450f6a2f
--- /dev/null
+++ b/backend/src/applications/comments/services/comments-queries.service.spec.ts
@@ -0,0 +1,26 @@
+import { drizzle } from 'drizzle-orm/mysql2'
+import type { DBSchema } from '../../../infrastructure/database/interfaces/database.interface.js'
+import type { SharesQueries } from '../../shares/services/shares-queries.service.js'
+import type { SpacesQueries } from '../../spaces/services/spaces-queries.service.js'
+import { CommentsQueries } from './comments-queries.service.js'
+
+describe(CommentsQueries.name, () => {
+ const service = new CommentsQueries(drizzle.mock() as unknown as DBSchema, {} as SpacesQueries, {} as SharesQueries)
+
+ it('builds space recents including NULLIF without query-level collation overrides', () => {
+ const { sql: statement } = service.getRecentsFromSpaces(7, [11], 20).toSQL()
+
+ expect(statement).toContain("NULLIF(CONCAT_WS('/', IF (`files`.`spaceExternalRootId` = `spaces_roots`.`id`, `spaces_roots`.`alias`, NULL)")
+ expect(statement).not.toContain('COLLATE')
+ expect(statement).toContain('`spaces`.`alias`')
+ expect(statement).toContain('`spaces_roots`.`name`')
+ })
+
+ it('builds share recents without query-level collation overrides', () => {
+ const { sql: statement } = service.getRecentsFromShares(7, [13], 20).toSQL()
+
+ expect(statement).not.toContain('COLLATE')
+ expect(statement).toContain('`shares`.`alias`')
+ expect(statement).toContain('`shares`.`name`')
+ })
+})
diff --git a/backend/src/applications/files/adapters/files-content-store-mysql.service.spec.ts b/backend/src/applications/files/adapters/files-content-store-mysql.service.spec.ts
index 31532583..6dd4c2bc 100644
--- a/backend/src/applications/files/adapters/files-content-store-mysql.service.spec.ts
+++ b/backend/src/applications/files/adapters/files-content-store-mysql.service.spec.ts
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing'
import { MySqlDialect } from 'drizzle-orm/mysql-core'
-import { DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants.js'
+import { DB_CHARSET, DB_PATH_COLLATION, DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants.js'
import { FilesContentStoreMySQL } from './files-content-store-mysql.service.js'
import { Mock } from 'vitest'
@@ -92,6 +92,22 @@ describe(FilesContentStoreMySQL.name, () => {
expect(db.execute).toHaveBeenCalledTimes(2)
})
+ it('should collate file metadata without changing content search', async () => {
+ db.execute.mockResolvedValueOnce([{}])
+ db.execute.mockResolvedValueOnce([[{ Field: 'seen_run_id' }]])
+
+ await filesIndexerMySQL.createIndex('files_content_u_1')
+
+ const query = dialect.sqlToQuery(db.execute.mock.calls[0][0])
+ const statement = query.sql.replace(/\s+/g, ' ').trim()
+ expect(statement).toContain(`path varchar(4096) CHARACTER SET ${DB_CHARSET} COLLATE ${DB_PATH_COLLATION} NOT NULL`)
+ expect(statement).toContain(`name varchar(255) CHARACTER SET ${DB_CHARSET} COLLATE ${DB_PATH_COLLATION} NOT NULL`)
+ expect(statement).toContain('content LONGTEXT,')
+ expect(statement).toContain('FULLTEXT (content)')
+ expect(statement).toContain(`) CHARACTER SET ${DB_CHARSET} COLLATE utf8mb4_general_ci;`)
+ expect(query.params).toEqual([])
+ })
+
it('should add run id column when it is missing', async () => {
db.execute.mockResolvedValueOnce([{}])
db.execute.mockResolvedValueOnce([[]])
diff --git a/backend/src/applications/files/schemas/files-content.schema.ts b/backend/src/applications/files/schemas/files-content.schema.ts
index 276c8546..e1001048 100644
--- a/backend/src/applications/files/schemas/files-content.schema.ts
+++ b/backend/src/applications/files/schemas/files-content.schema.ts
@@ -1,15 +1,16 @@
import { SQL, sql } from 'drizzle-orm'
+import { DB_CHARSET, DB_PATH_COLLATION } from '../../../infrastructure/database/constants.js'
export const FILES_CONTENT_TABLE_PREFIX = 'files_content_' as const
-// The utf8mb4_uca1400_ai_ci COLLATE is better for precision but slower
+// Keep content search on general_ci while matching file metadata collations.
export function createTableFilesContent(tableName: string): SQL {
return sql`
CREATE TABLE IF NOT EXISTS ${sql.identifier(tableName)}
(
id bigint unsigned NOT NULL,
- path varchar(4096) NOT NULL,
- name varchar(255) NOT NULL,
+ path varchar(4096) CHARACTER SET ${sql.raw(DB_CHARSET)} COLLATE ${sql.raw(DB_PATH_COLLATION)} NOT NULL,
+ name varchar(255) CHARACTER SET ${sql.raw(DB_CHARSET)} COLLATE ${sql.raw(DB_PATH_COLLATION)} NOT NULL,
mime varchar(255),
size bigint unsigned NOT NULL,
mtime bigint unsigned NOT NULL,
@@ -18,6 +19,6 @@ export function createTableFilesContent(tableName: string): SQL {
PRIMARY KEY (id),
INDEX seen_run_id (seen_run_id),
FULLTEXT (content)
- ) CHARACTER SET utf8mb4
+ ) CHARACTER SET ${sql.raw(DB_CHARSET)}
COLLATE utf8mb4_general_ci;`
}
diff --git a/backend/src/applications/files/schemas/files-recents.schema.ts b/backend/src/applications/files/schemas/files-recents.schema.ts
index afc3d48d..6c115eee 100644
--- a/backend/src/applications/files/schemas/files-recents.schema.ts
+++ b/backend/src/applications/files/schemas/files-recents.schema.ts
@@ -1,4 +1,5 @@
import { bigint, index, mysqlTable, varchar } from 'drizzle-orm/mysql-core'
+import { pathVarchar } from '../../../infrastructure/database/columns.js'
import { shares } from '../../shares/schemas/shares.schema.js'
import { spaces } from '../../spaces/schemas/spaces.schema.js'
import { users } from '../../users/schemas/users.schema.js'
@@ -10,8 +11,8 @@ export const filesRecents = mysqlTable(
ownerId: bigint('ownerId', { mode: 'number', unsigned: true }).references(() => users.id, { onDelete: 'cascade' }),
spaceId: bigint('spaceId', { mode: 'number', unsigned: true }).references(() => spaces.id, { onDelete: 'cascade' }),
shareId: bigint('shareId', { mode: 'number', unsigned: true }).references(() => shares.id, { onDelete: 'cascade' }),
- path: varchar('path', { length: 4096 }).notNull(),
- name: varchar('name', { length: 255 }).notNull(),
+ path: pathVarchar('path', { length: 4096 }).notNull(),
+ name: pathVarchar('name', { length: 255 }).notNull(),
mime: varchar('mime', { length: 255 }),
mtime: bigint('mtime', { mode: 'number', unsigned: true }).notNull()
},
diff --git a/backend/src/applications/files/schemas/files-trash.schema.ts b/backend/src/applications/files/schemas/files-trash.schema.ts
index d7b6c209..6c711dab 100644
--- a/backend/src/applications/files/schemas/files-trash.schema.ts
+++ b/backend/src/applications/files/schemas/files-trash.schema.ts
@@ -1,14 +1,14 @@
import { SQL, sql } from 'drizzle-orm'
+import { DB_CHARSET, DB_PATH_COLLATION } from '../../../infrastructure/database/constants.js'
export const FILES_TRASH_TABLE_PREFIX = 'files_trash_' as const
-// The utf8mb4_uca1400_ai_ci COLLATE is better for precision but slower
export function createTableFilesTrash(tableName: string): SQL {
return sql`
CREATE TABLE IF NOT EXISTS ${sql.identifier(tableName)}
(
id bigint unsigned NOT NULL,
- path varchar(4096) NOT NULL,
+ path varchar(4096) NOT NULL,
isDir boolean NOT NULL,
deletedAt date NOT NULL DEFAULT CURRENT_DATE,
seen_run_id varchar(64),
@@ -16,6 +16,6 @@ export function createTableFilesTrash(tableName: string): SQL {
INDEX is_dir_deleted_at (isDir, deletedAt),
INDEX path_prefix (path(768)),
INDEX seen_run_id (seen_run_id)
- ) CHARACTER SET utf8mb4
- COLLATE utf8mb4_general_ci;`
+ ) CHARACTER SET ${sql.raw(DB_CHARSET)}
+ COLLATE ${sql.raw(DB_PATH_COLLATION)};`
}
diff --git a/backend/src/applications/files/schemas/files.schema.ts b/backend/src/applications/files/schemas/files.schema.ts
index 3186ceda..5fa8dbd6 100644
--- a/backend/src/applications/files/schemas/files.schema.ts
+++ b/backend/src/applications/files/schemas/files.schema.ts
@@ -1,5 +1,6 @@
import { SQL, sql, type SQLWrapper } from 'drizzle-orm'
import { AnyMySqlColumn, bigint, boolean, index, mysqlTable, varchar } from 'drizzle-orm/mysql-core'
+import { pathVarchar } from '../../../infrastructure/database/columns.js'
import { shares } from '../../shares/schemas/shares.schema.js'
import { spacesRoots } from '../../spaces/schemas/spaces-roots.schema.js'
import { spaces } from '../../spaces/schemas/spaces.schema.js'
@@ -23,8 +24,8 @@ export const files = mysqlTable(
unsigned: true
}).references((): AnyMySqlColumn => spacesRoots.id, { onDelete: 'cascade' }),
shareExternalId: bigint('shareExternalId', { mode: 'number', unsigned: true }).references(() => shares.id, { onDelete: 'cascade' }),
- path: varchar('path', { length: 4096 }).notNull(),
- name: varchar('name', { length: 255 }).notNull(),
+ path: pathVarchar('path', { length: 4096 }).notNull(),
+ name: pathVarchar('name', { length: 255 }).notNull(),
isDir: boolean('isDir').notNull(),
inTrash: boolean('inTrash').default(false).notNull(),
mime: varchar('mime', { length: 255 }),
diff --git a/backend/src/applications/files/services/files-favorites-queries.service.spec.ts b/backend/src/applications/files/services/files-favorites-queries.service.spec.ts
new file mode 100644
index 00000000..385eae60
--- /dev/null
+++ b/backend/src/applications/files/services/files-favorites-queries.service.spec.ts
@@ -0,0 +1,36 @@
+import { sql, type SQLWrapper } from 'drizzle-orm'
+import { MySqlDialect } from 'drizzle-orm/mysql-core'
+import { drizzle } from 'drizzle-orm/mysql2'
+import type { DBSchema } from '../../../infrastructure/database/interfaces/database.interface.js'
+import { FilesFavoritesQueries } from './files-favorites-queries.service.js'
+
+describe(FilesFavoritesQueries.name, () => {
+ const dialect = new MySqlDialect()
+ const service = new FilesFavoritesQueries(drizzle.mock() as unknown as DBSchema)
+
+ it('builds the space UNION ALL using schema collations without query-level overrides', () => {
+ const query = service.getFavoriteLocationsFromSpaces(7, [11]) as unknown as SQLWrapper
+ const statement = dialect.sqlToQuery(sql`${query}`).sql
+
+ expect(statement.match(/union all/gi)).toHaveLength(1)
+ expect(statement).not.toContain('COLLATE')
+ for (const operand of [
+ '`spaces`.`alias`',
+ '`favoriteDirectSpaceRoot`.`alias`',
+ '`favoriteAnchoredSpaceRoot`.`alias`',
+ '`favoriteAnchoredSpaceRoot`.`name`'
+ ]) {
+ expect(statement).toContain(operand)
+ }
+ })
+
+ it('builds every share UNION ALL branch without query-level collation overrides', () => {
+ const query = service.getFavoriteLocationsFromShares(7, [13]) as unknown as SQLWrapper
+ const statement = dialect.sqlToQuery(sql`${query}`).sql
+
+ expect(statement.match(/union all/gi)).toHaveLength(3)
+ expect(statement).not.toContain('COLLATE')
+ expect(statement).toContain('`shares`.`alias`')
+ expect(statement).toContain('`shares`.`name`')
+ })
+})
diff --git a/backend/src/applications/files/services/files-trash-retention.service.spec.ts b/backend/src/applications/files/services/files-trash-retention.service.spec.ts
index 99c9d667..2b541897 100644
--- a/backend/src/applications/files/services/files-trash-retention.service.spec.ts
+++ b/backend/src/applications/files/services/files-trash-retention.service.spec.ts
@@ -4,7 +4,7 @@ import fs from 'node:fs/promises'
import os from 'node:os'
import path from 'node:path'
import { escapePath } from '../../../common/functions.js'
-import { DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants.js'
+import { DB_CHARSET, DB_PATH_COLLATION, DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants.js'
import { FILE_REPOSITORY } from '../constants/operations.js'
import { FileTrash } from '../schemas/file-trash.interface.js'
import { createTableFilesTrash } from '../schemas/files-trash.schema.js'
@@ -84,6 +84,18 @@ describe(FilesTrashRetention.name, () => {
expect(schema).toContain('INDEX seen_run_id (seen_run_id)')
})
+ it('should use the shared NO PAD collation as the default for the whole trash table', () => {
+ const schema = dialect.sqlToQuery(createTableFilesTrash('files_trash_user_1')).sql
+
+ expect(schema).toContain('path varchar(4096) NOT NULL')
+ expect(schema).not.toContain('path varchar(4096) CHARACTER SET')
+ expect(schema).toContain('INDEX path_prefix (path(768))')
+ expect(schema).toContain(`CHARACTER SET ${DB_CHARSET}`)
+ expect(schema).toContain(`COLLATE ${DB_PATH_COLLATION};`)
+ expect(schema).not.toContain('utf8mb4_general_ci')
+ expect(schema.split(DB_PATH_COLLATION)).toHaveLength(2)
+ })
+
it('should escape trash table names as identifiers', () => {
const tableName = 'files_trash_user_1`; DROP TABLE users; --'
diff --git a/backend/src/applications/shares/schemas/shares.schema.ts b/backend/src/applications/shares/schemas/shares.schema.ts
index 2f03281a..a13403bc 100644
--- a/backend/src/applications/shares/schemas/shares.schema.ts
+++ b/backend/src/applications/shares/schemas/shares.schema.ts
@@ -1,5 +1,6 @@
import { sql } from 'drizzle-orm'
import { AnyMySqlColumn, bigint, boolean, datetime, index, mysqlTable, tinyint, uniqueIndex, varchar } from 'drizzle-orm/mysql-core'
+import { pathVarchar } from '../../../infrastructure/database/columns.js'
import { files } from '../../files/schemas/files.schema.js'
import { spacesRoots } from '../../spaces/schemas/spaces-roots.schema.js'
import { spaces } from '../../spaces/schemas/spaces.schema.js'
@@ -50,10 +51,10 @@ export const shares = mysqlTable(
spaceId: bigint('spaceId', { mode: 'number', unsigned: true }).references(() => spaces.id, { onDelete: 'cascade' }),
spaceRootId: bigint('spaceRootId', { mode: 'number', unsigned: true }).references((): AnyMySqlColumn => spacesRoots.id, { onDelete: 'cascade' }),
fileId: bigint('fileId', { mode: 'number', unsigned: true }).references((): AnyMySqlColumn => files.id, { onDelete: 'cascade' }),
- externalPath: varchar('externalPath', { length: 4096 }),
+ externalPath: pathVarchar('externalPath', { length: 4096 }),
type: tinyint('type', { unsigned: true }).default(0).notNull(),
- alias: varchar('alias', { length: 255 }).notNull(),
- name: varchar('name', { length: 255 }).notNull(),
+ alias: pathVarchar('alias', { length: 255 }).notNull(),
+ name: pathVarchar('name', { length: 255 }).notNull(),
enabled: boolean('enabled').default(true).notNull(),
description: varchar('description', { length: 255 }),
storageUsage: bigint('storageUsage', { mode: 'number', unsigned: true }).default(0).notNull(),
diff --git a/backend/src/applications/shares/services/shares-manager.service.spec.ts b/backend/src/applications/shares/services/shares-manager.service.spec.ts
index bf8e7108..af26c3bf 100644
--- a/backend/src/applications/shares/services/shares-manager.service.spec.ts
+++ b/backend/src/applications/shares/services/shares-manager.service.spec.ts
@@ -94,7 +94,7 @@ describe(SharesManager.name, () => {
updateMembers: vi.fn(),
shareExistsForOwner: vi.fn(),
childExistsForShareOwner: vi.fn(),
- uniqueShareAlias: vi.fn(),
+ shareExistsForAlias: vi.fn(),
clearCacheIdentities: vi.fn().mockResolvedValue(true),
clearCachePermissions: vi.fn().mockResolvedValue(true)
}
@@ -169,7 +169,7 @@ describe(SharesManager.name, () => {
describe('createShare', () => {
it('forbids creating a share from a space without the share outside permission', async () => {
- sharesQueriesMock.uniqueShareAlias.mockResolvedValueOnce('shared-file')
+ sharesQueriesMock.shareExistsForAlias.mockResolvedValueOnce(undefined)
spacesQueriesMock.permissions.mockResolvedValueOnce({ id: 7, alias: 'space-1' })
vi.mocked(permissionsUtils.havePermission).mockReturnValueOnce(false)
@@ -617,11 +617,31 @@ describe(SharesManager.name, () => {
const currentShareId = 42
const uniqueShareAlias = (name: string): Promise<string> => (service as any).uniqueShareAlias(name, currentShareId)
- it('should exclude the current share when checking its alias', async () => {
- sharesQueriesMock.uniqueShareAlias.mockResolvedValueOnce('leba-est-chez-moi')
+ it('normalizes aliases and resolves collisions while excluding the current share', async () => {
+ sharesQueriesMock.shareExistsForAlias.mockResolvedValueOnce({ id: 30 }).mockResolvedValueOnce(undefined)
- await expect(uniqueShareAlias('Lébà est chez moi')).resolves.toBe('leba-est-chez-moi')
- expect(sharesQueriesMock.uniqueShareAlias).toHaveBeenCalledWith('Lébà est chez moi', currentShareId)
+ await expect(uniqueShareAlias('DócS-2')).resolves.toBe('docs-1')
+ expect(sharesQueriesMock.shareExistsForAlias.mock.calls).toEqual([
+ ['docs', currentShareId],
+ ['docs-1', currentShareId]
+ ])
+ })
+
+ it('bounds long aliases before checking availability and adding a collision suffix', async () => {
+ sharesQueriesMock.shareExistsForAlias.mockResolvedValueOnce({ id: 30 }).mockResolvedValueOnce(undefined)
+
+ await expect(uniqueShareAlias('a'.repeat(256))).resolves.toBe(`${'a'.repeat(253)}-1`)
+ expect(sharesQueriesMock.shareExistsForAlias.mock.calls).toEqual([
+ ['a'.repeat(255), currentShareId],
+ [`${'a'.repeat(253)}-1`, currentShareId]
+ ])
+ })
+
+ it('rejects an invalid alias without checking database availability', async () => {
+ await expect(uniqueShareAlias('---')).rejects.toEqual(
+ new HttpException('Name must contain at least one letter or number', HttpStatus.BAD_REQUEST)
+ )
+ expect(sharesQueriesMock.shareExistsForAlias).not.toHaveBeenCalled()
})
})
})
diff --git a/backend/src/applications/shares/services/shares-manager.service.ts b/backend/src/applications/shares/services/shares-manager.service.ts
index 9e80dc7e..66d77766 100644
--- a/backend/src/applications/shares/services/shares-manager.service.ts
+++ b/backend/src/applications/shares/services/shares-manager.service.ts
@@ -11,7 +11,7 @@ import {
hashPassword
} from '../../../common/functions.js'
import type { Entries } from '../../../common/interfaces.js'
-import { intersectPermissions, InvalidSlugError } from '../../../common/shared.js'
+import { createSlug, intersectPermissions, InvalidSlugError } from '../../../common/shared.js'
import type { FileProps } from '../../files/interfaces/file-props.interface.js'
import { FileError } from '../../files/models/file-error.js'
import { checkExternalPath, getProps, isPathExists, removeFiles } from '../../files/utils/files.js'
@@ -29,6 +29,7 @@ import type { SpaceMemberDto } from '../../spaces/dto/create-or-update-space.dto
import { SpaceEnv } from '../../spaces/models/space-env.model.js'
import type { SpaceProps } from '../../spaces/models/space-props.model.js'
import { SpacesQueries } from '../../spaces/services/spaces-queries.service.js'
+import { createUniqueAlias } from '../../spaces/utils/alias.js'
import { havePermission, haveSpacePermission, removePermissions } from '../../spaces/utils/permissions.js'
import { MEMBER_TYPE } from '../../users/constants/member.js'
import { GUEST_PERMISSION, USER_NOTIFICATION, USER_ROLE } from '../../users/constants/user.js'
@@ -784,7 +785,9 @@ export class SharesManager {
private async uniqueShareAlias(name: string, excludedShareId?: number): Promise<string> {
try {
- return await this.sharesQueries.uniqueShareAlias(name, excludedShareId)
+ return await createUniqueAlias(createSlug(name), (alias: string) => this.sharesQueries.shareExistsForAlias(alias, excludedShareId), {
+ replaceCount: true
+ })
} catch (e) {
if (e instanceof InvalidSlugError) {
throw new HttpException(e.message, HttpStatus.BAD_REQUEST)
diff --git a/backend/src/applications/shares/services/shares-queries.service.ts b/backend/src/applications/shares/services/shares-queries.service.ts
index 738f91b6..528ad1ef 100644
--- a/backend/src/applications/shares/services/shares-queries.service.ts
+++ b/backend/src/applications/shares/services/shares-queries.service.ts
@@ -5,7 +5,7 @@ import { alias, MySqlSelectDynamic, type SelectedFields, union } from 'drizzle-o
import { MySql2PreparedQuery, MySqlQueryResult } from 'drizzle-orm/mysql2'
import { ACTION } from '../../../common/constants.js'
import { type ConvertedDiffUpdate, uniquePermissions } from '../../../common/functions.js'
-import { createSlug, popFromObject } from '../../../common/shared.js'
+import { popFromObject } from '../../../common/shared.js'
import { CacheDecorator } from '../../../infrastructure/cache/cache.decorator.js'
import { Cache } from '../../../infrastructure/cache/cache.service.js'
import { DB_TOKEN_PROVIDER } from '../../../infrastructure/database/constants.js'
@@ -28,7 +28,6 @@ import type { SpaceBrowseDetails } from '../../spaces/interfaces/space-files.int
import { SpaceEnv } from '../../spaces/models/space-env.model.js'
import { spacesRoots } from '../../spaces/schemas/spaces-roots.schema.js'
import { spaceGroupConcatPermissions, spaces } from '../../spaces/schemas/spaces.schema.js'
-import { createUniqueAlias } from '../../spaces/utils/alias.js'
import { syncClients } from '../../sync/schemas/sync-clients.schema.js'
import { syncPaths } from '../../sync/schemas/sync-paths.schema.js'
import { GROUP_TYPE } from '../../users/constants/group.js'
@@ -69,10 +68,6 @@ export class SharesQueries {
public readonly cache: Cache
) {}
- async uniqueShareAlias(name: string, excludedShareId?: number): Promise<string> {
- return createUniqueAlias(createSlug(name, true), (alias: string) => this.shareExistsForAlias(alias, excludedShareId))
- }
-
shareExistsForOwner(userId: number, shareId: number) {
return this.db.query.shares.findFirst({ columns: { id: true }, where: and(eq(shares.id, shareId), eq(shares.ownerId, userId)) })
}
@@ -984,7 +979,7 @@ export class SharesQueries {
}
}
- private shareExistsForAlias(alias: string, excludedShareId?: number) {
+ shareExistsForAlias(alias: string, excludedShareId?: number) {
return this.db.query.shares.findFirst({
columns: { id: true },
where: excludedShareId === undefined ? eq(shares.alias, alias) : and(eq(shares.alias, alias), ne(shares.id, excludedShareId))
diff --git a/backend/src/applications/spaces/schemas/spaces-roots.schema.ts b/backend/src/applications/spaces/schemas/spaces-roots.schema.ts
index 268fd357..51a70b23 100644
--- a/backend/src/applications/spaces/schemas/spaces-roots.schema.ts
+++ b/backend/src/applications/spaces/schemas/spaces-roots.schema.ts
@@ -1,5 +1,6 @@
import { sql } from 'drizzle-orm'
import { bigint, datetime, index, mysqlTable, unique, varchar } from 'drizzle-orm/mysql-core'
+import { pathVarchar } from '../../../infrastructure/database/columns.js'
import { files } from '../../files/schemas/files.schema.js'
import { spaces } from './spaces.schema.js'
@@ -20,9 +21,9 @@ export const spacesRoots = mysqlTable(
.references(() => spaces.id, { onDelete: 'cascade' })
.notNull(),
fileId: bigint('fileId', { mode: 'number', unsigned: true }).references(() => files.id, { onDelete: 'cascade' }),
- alias: varchar('alias', { length: 255 }).notNull(),
- name: varchar('name', { length: 255 }).notNull(),
- externalPath: varchar('externalPath', { length: 4096 }),
+ alias: pathVarchar('alias', { length: 255 }).notNull(),
+ name: pathVarchar('name', { length: 255 }).notNull(),
+ externalPath: pathVarchar('externalPath', { length: 4096 }),
permissions: varchar('permissions', { length: 32 }).default(''),
createdAt: datetime('createdAt', { mode: 'date' })
.default(sql`CURRENT_TIMESTAMP`)
diff --git a/backend/src/applications/spaces/schemas/spaces.schema.ts b/backend/src/applications/spaces/schemas/spaces.schema.ts
index ffcde493..ab1f1c0c 100644
--- a/backend/src/applications/spaces/schemas/spaces.schema.ts
+++ b/backend/src/applications/spaces/schemas/spaces.schema.ts
@@ -1,5 +1,6 @@
import { SQL, sql } from 'drizzle-orm'
import { bigint, boolean, datetime, mysqlTable, uniqueIndex, varchar } from 'drizzle-orm/mysql-core'
+import { pathVarchar } from '../../../infrastructure/database/columns.js'
import { SPACE_PERMS_SEP } from '../constants/spaces.js'
/*
@@ -15,8 +16,8 @@ export const spaces = mysqlTable(
'spaces',
{
id: bigint('id', { mode: 'number', unsigned: true }).autoincrement().primaryKey(),
- alias: varchar('alias', { length: 255 }).notNull(),
- name: varchar('name', { length: 255 }).notNull(),
+ alias: pathVarchar('alias', { length: 255 }).notNull(),
+ name: pathVarchar('name', { length: 255 }).notNull(),
description: varchar('description', { length: 255 }),
enabled: boolean('enabled').default(true).notNull(),
storageUsage: bigint('storageUsage', { mode: 'number', unsigned: true }).default(0).notNull(),
diff --git a/backend/src/applications/spaces/services/spaces-manager.service.spec.ts b/backend/src/applications/spaces/services/spaces-manager.service.spec.ts
index fce48777..2490e2af 100644
--- a/backend/src/applications/spaces/services/spaces-manager.service.spec.ts
+++ b/backend/src/applications/spaces/services/spaces-manager.service.spec.ts
@@ -242,16 +242,89 @@ describe(SpacesManager.name, () => {
const currentRootId = 24
const name = 'Lébà est chez moi'
const alias = 'leba-est-chez-moi'
- const uniqueSpaceAlias = (value: string): Promise<string> => (spacesManager as any).uniqueSpaceAlias(value, true, currentSpaceId)
+ const uniqueSpaceAlias = (value: string): Promise<string> => (spacesManager as any).uniqueSpaceAlias(value, currentSpaceId)
- it('should preserve the current space alias when the renamed name produces the same slug', async () => {
+ afterEach(() => {
+ vi.restoreAllMocks()
+ })
+
+ it('should normalize the renamed space name and numeric suffix before checking availability', async () => {
const spaceExistsSpy = vi.spyOn(spacesQueries, 'spaceExistsForAlias').mockResolvedValueOnce(undefined)
- await expect(uniqueSpaceAlias(name)).resolves.toBe(alias)
+ await expect(uniqueSpaceAlias(`${name}-2`)).resolves.toBe(alias)
expect(spaceExistsSpy).toHaveBeenCalledWith(alias, currentSpaceId)
spaceExistsSpy.mockRestore()
})
+ it('should accept a space alias of exactly 255 UTF-8 bytes', async () => {
+ vi.spyOn(spacesQueries, 'spaceExistsForAlias').mockResolvedValueOnce(undefined)
+ const name = '漢'.repeat(85)
+
+ await expect(uniqueSpaceAlias(name)).resolves.toBe(name)
+ })
+
+ it.each([
+ ['漢'.repeat(86), '漢'.repeat(85)],
+ ['가'.repeat(86), '\u1100\u1161'.repeat(42)],
+ ['a'.repeat(256), 'a'.repeat(255)]
+ ])('should truncate an oversized space alias without splitting graphemes', async (name, expectedAlias) => {
+ const spaceExistsSpy = vi.spyOn(spacesQueries, 'spaceExistsForAlias').mockResolvedValueOnce(undefined)
+
+ await expect(uniqueSpaceAlias(name)).resolves.toBe(expectedAlias)
+ expect(spaceExistsSpy).toHaveBeenCalledExactlyOnceWith(expectedAlias, currentSpaceId)
+ })
+
+ it('should resolve collisions using truncated aliases with suffixes inside the byte limit', async () => {
+ const spaceExistsSpy = vi
+ .spyOn(spacesQueries, 'spaceExistsForAlias')
+ .mockResolvedValueOnce({ id: 1 })
+ .mockResolvedValueOnce({ id: 2 })
+ .mockResolvedValueOnce(undefined)
+ const name = '漢'.repeat(85)
+
+ await expect(uniqueSpaceAlias(name)).resolves.toBe(`${'漢'.repeat(84)}-2`)
+ expect(spaceExistsSpy.mock.calls).toEqual([
+ [name, currentSpaceId],
+ [`${'漢'.repeat(84)}-1`, currentSpaceId],
+ [`${'漢'.repeat(84)}-2`, currentSpaceId]
+ ])
+ })
+
+ it('should reserve additional suffix bytes when collisions reach two digits', async () => {
+ const spaceExistsSpy = vi.spyOn(spacesQueries, 'spaceExistsForAlias').mockResolvedValue(undefined)
+ for (let count = 0; count < 10; count += 1) {
+ spaceExistsSpy.mockResolvedValueOnce({ id: 1 })
+ }
+
+ await expect(uniqueSpaceAlias('a'.repeat(255))).resolves.toBe(`${'a'.repeat(252)}-10`)
+ expect(spaceExistsSpy).toHaveBeenCalledTimes(11)
+ expect(spaceExistsSpy).toHaveBeenNthCalledWith(10, `${'a'.repeat(253)}-9`, currentSpaceId)
+ expect(spaceExistsSpy).toHaveBeenNthCalledWith(11, `${'a'.repeat(252)}-10`, currentSpaceId)
+ for (const [alias] of spaceExistsSpy.mock.calls) {
+ expect(Buffer.byteLength(alias, 'utf8')).toBeLessThanOrEqual(255)
+ }
+ })
+
+ it('should resolve collisions when a single grapheme exceeds the byte limit', async () => {
+ const spaceExistsSpy = vi.spyOn(spacesQueries, 'spaceExistsForAlias').mockResolvedValueOnce({ id: 1 }).mockResolvedValueOnce(undefined)
+
+ await expect(uniqueSpaceAlias('\u1100'.repeat(86))).resolves.toBe('space-1')
+ expect(spaceExistsSpy.mock.calls).toEqual([
+ ['space', currentSpaceId],
+ ['space-1', currentSpaceId]
+ ])
+ })
+
+ it('should ignore symbols when allocating the space alias byte budget', async () => {
+ const spaceExistsSpy = vi.spyOn(spacesQueries, 'spaceExistsForAlias').mockResolvedValueOnce({ id: 1 }).mockResolvedValueOnce(undefined)
+
+ await expect(uniqueSpaceAlias(`${'📷'.repeat(64)}a`)).resolves.toBe('a-1')
+ expect(spaceExistsSpy.mock.calls).toEqual([
+ ['a', currentSpaceId],
+ ['a-1', currentSpaceId]
+ ])
+ })
+
it('should exclude the current root when checking its alias', async () => {
const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValueOnce(undefined)
@@ -259,5 +332,89 @@ describe(SpacesManager.name, () => {
expect(rootExistsSpy).toHaveBeenCalledWith(1, alias, currentRootId)
rootExistsSpy.mockRestore()
})
+
+ it('should remove accents while normalizing case, numeric suffix and extension, excluding the current root', async () => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, 'Rapport E\u0301TE\u0301-2.PDF', [], true, currentRootId, true)).resolves.toBe(
+ 'rapport-ete.pdf'
+ )
+ expect(rootExistsSpy).toHaveBeenCalledExactlyOnceWith(currentSpaceId, 'rapport-ete.pdf', currentRootId)
+ })
+
+ it('should bound a normalized root alias to 255 characters', async () => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+ const expectedAlias = 'a'.repeat(255)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, 'a'.repeat(256), [], true, currentRootId, true)).resolves.toBe(expectedAlias)
+ expect(rootExistsSpy).toHaveBeenCalledExactlyOnceWith(currentSpaceId, expectedAlias, currentRootId)
+ })
+
+ it.each([
+ ['rapport.---', 'rapport'],
+ ['---.pdf', 'pdf']
+ ])('should normalize the whole root alias %s when its name or extension cannot form a slug', async (requestedAlias, normalizedAlias) => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, requestedAlias, [], true, undefined, true)).resolves.toBe(normalizedAlias)
+ expect(rootExistsSpy).toHaveBeenCalledExactlyOnceWith(currentSpaceId, normalizedAlias, undefined)
+ })
+
+ it('should remove accents before resolving database collisions with a suffix before the extension', async () => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValueOnce({ id: 1 }).mockResolvedValueOnce(undefined)
+ const aliasesAndNames = ['Rapport été.PDF', 'rapport-été.pdf']
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, 'Rapport été-2.PDF', aliasesAndNames, true, currentRootId, true)).resolves.toBe(
+ 'rapport-ete-1.pdf'
+ )
+ expect(rootExistsSpy.mock.calls).toEqual([
+ [currentSpaceId, 'rapport-ete.pdf', currentRootId],
+ [currentSpaceId, 'rapport-ete-1.pdf', currentRootId]
+ ])
+ expect(aliasesAndNames).toEqual(['Rapport été.PDF', 'rapport-été.pdf'])
+ })
+
+ it.each([
+ ['가.pdf', '\u1100\u1161.PDF', '\u1100\u1161-1.pdf'],
+ ['\u1100\u1161.pdf', '가.PDF', '\u1100\u1161-1.pdf']
+ ])('should avoid equivalent file names after normalizing %s', async (requestedAlias, fileName, expectedAlias) => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, requestedAlias, [fileName], true, currentRootId, true)).resolves.toBe(expectedAlias)
+ expect(rootExistsSpy).toHaveBeenCalledExactlyOnceWith(currentSpaceId, expectedAlias, currentRootId)
+ })
+
+ it.each([
+ ['café.pdf', 'CAFE\u0301.PDF', 'cafe-1.pdf'],
+ ['cafe\u0301.pdf', 'CAFÉ.PDF', 'cafe-1.pdf']
+ ])('should resolve canonically equivalent file-name collisions when browsing %s', async (requestedAlias, fileName, expectedAlias) => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, requestedAlias, [fileName], true, currentRootId)).resolves.toBe(expectedAlias)
+ expect(rootExistsSpy).toHaveBeenCalledExactlyOnceWith(currentSpaceId, expectedAlias, currentRootId)
+ })
+
+ it('should reject root aliases without any letters or numbers before querying the database', async () => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, '---', [], true, undefined, true)).rejects.toEqual(
+ new HttpException('Name must contain at least one letter or number', HttpStatus.BAD_REQUEST)
+ )
+ expect(rootExistsSpy).not.toHaveBeenCalled()
+ })
+
+ it.each(['Rapport été-2.PDF', 'cafe\u0301.pdf'])('should preserve the available Unicode alias %s when browsing', async (alias) => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, alias, [], true)).resolves.toBeNull()
+ expect(rootExistsSpy).toHaveBeenCalledExactlyOnceWith(currentSpaceId, alias, undefined)
+ })
+
+ it('should keep compatibility-equivalent file names distinct when browsing a legacy alias', async () => {
+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValue(undefined)
+
+ await expect(spacesManager.uniqueRootAlias(currentSpaceId, 'ffi.pdf', ['ffi.pdf'], true)).resolves.toBeNull()
+ expect(rootExistsSpy).toHaveBeenCalledExactlyOnceWith(currentSpaceId, 'ffi.pdf', undefined)
+ })
})
})
diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.ts
index 6606fc0f..349df958 100644
--- a/backend/src/applications/spaces/services/spaces-manager.service.ts
+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts
@@ -6,7 +6,7 @@ import { ACTION } from '../../../common/constants.js'
import { toErrorMessage } from '../../../common/errors.js'
import { convertDiffUpdate, diffCollection, differencePermissions } from '../../../common/functions.js'
import type { Entries } from '../../../common/interfaces.js'
-import { createSlug, InvalidSlugError, regExpNumberSuffix } from '../../../common/shared.js'
+import { createSlug, InvalidSlugError, regExpLetterOrNumber, regExpNumberSuffix } from '../../../common/shared.js'
import { DEFAULT_DIRECTORY_BUFFER_SIZE } from '../../files/constants/files.js'
import { FileError } from '../../files/models/file-error.js'
import { dirListFileNames, getProps, isInternalTemporaryEntry, isPathExists, moveFiles, removeFiles } from '../../files/utils/files.js'
@@ -240,7 +240,7 @@ export class SpacesManager {
// create space
const space: SpaceProps = new SpaceProps({
name: createOrUpdateSpaceDto.name,
- alias: await this.uniqueSpaceAlias(createOrUpdateSpaceDto.name, true),
+ alias: await this.uniqueSpaceAlias(createOrUpdateSpaceDto.name),
description: createOrUpdateSpaceDto.description,
enabled: createOrUpdateSpaceDto.enabled ?? undefined,
storageQuota: createOrUpdateSpaceDto.storageQuota,
@@ -282,7 +282,7 @@ export class SpacesManager {
;(spaceDiffProps as Record<string, unknown>)[prop] = createOrUpdateSpaceDto[prop]
if (prop === 'name') {
renamedSpaceAlias = space.alias
- spaceDiffProps.alias = await this.uniqueSpaceAlias(spaceDiffProps.name!, true, space.id)
+ spaceDiffProps.alias = await this.uniqueSpaceAlias(spaceDiffProps.name!, space.id)
if (space.alias !== spaceDiffProps.alias) {
// must move the space to match the new alias
const spaceLocationWasRenamed: boolean = await this.renameSpaceLocation(space.alias, spaceDiffProps.alias)
@@ -405,27 +405,48 @@ export class SpacesManager {
alias: string,
aliasesAndNames: string[],
replaceCount = false,
- excludedRootId?: number
+ excludedRootId?: number,
+ normalize = false
): Promise<string | null> {
- /* for some webdav clients the root alias is displayed instead of the file name.
- * This is why a root alias must be unique for files too */
- const aliasExists = (candidate: string): boolean => {
- const normalizedCandidate = candidate.toLowerCase()
- return aliasesAndNames.some((aliasOrName: string) => normalizedCandidate === aliasOrName.toLowerCase())
- }
- if (aliasExists(alias) || (await this.spacesQueries.spaceRootExistsForAlias(spaceId, alias, excludedRootId))) {
- const aliasExtension = path.extname(alias)
- const aliasWithoutExtension = path.basename(alias, aliasExtension)
- const originalAlias = this.createAliasSlug(aliasWithoutExtension, replaceCount)
- let count = 1
- let newAlias = `${originalAlias}-${count}${aliasExtension}`
- while (aliasExists(newAlias) || (await this.spacesQueries.spaceRootExistsForAlias(spaceId, newAlias, excludedRootId))) {
- count += 1
- newAlias = `${originalAlias}-${count}${aliasExtension}`
- }
- return newAlias
+ // Resolves a stored space-root alias without renaming filesystem entries.
+ // Some WebDAV clients display aliases instead of names, so aliases must also avoid visible file names.
+ //
+ // aliasesAndNames: aliases and visible file names to avoid; omit the current root's own alias/name when editing.
+ // replaceCount: strip the numeric suffix before trying the base alias, then -1, -2, etc.
+ // normalize: normalize on creation/explicit renaming; otherwise preserve available aliases when browsing.
+ const normalizedNames = new Set(aliasesAndNames.map((name) => name.toLowerCase().normalize('NFC')))
+ const aliasExists = async (candidate: string): Promise<boolean> =>
+ normalizedNames.has(candidate.toLowerCase().normalize('NFC')) ||
+ !!(await this.spacesQueries.spaceRootExistsForAlias(spaceId, candidate, excludedRootId))
+ // Browsing only resolves collisions; it must not normalize existing aliases.
+ if (!normalize && !(await aliasExists(alias))) {
+ return null
}
- return null
+
+ const aliasExtension = path.extname(alias)
+ let aliasWithoutExtension: string
+ let extension = aliasExtension
+ try {
+ aliasWithoutExtension = this.createAliasSlug(path.basename(alias, aliasExtension))
+ if (normalize && aliasExtension) {
+ extension = `.${this.createAliasSlug(aliasExtension.slice(1))}`
+ }
+ } catch (error) {
+ if (!normalize || !(error instanceof HttpException) || error.getStatus() !== HttpStatus.BAD_REQUEST) {
+ throw error
+ }
+ // A symbol-only component must not reject an otherwise valid alias.
+ aliasWithoutExtension = this.createAliasSlug(alias)
+ extension = ''
+ }
+ const normalizedAlias = `${aliasWithoutExtension}${extension}`
+ const uniqueAlias = await createUniqueAlias(
+ aliasWithoutExtension,
+ // Browsing must not reuse the normalized alias that already caused a collision.
+ async (candidate) => (!normalize && candidate === normalizedAlias) || aliasExists(candidate),
+ { extension, replaceCount }
+ )
+ return uniqueAlias === alias ? null : uniqueAlias
}
async deleteExpiredSpaces() {
@@ -616,7 +637,7 @@ export class SpacesManager {
aliasesAndNames.splice(currentValueIndex, 1)
}
}
- props.alias.new = (await this.uniqueRootAlias(space.id, props.alias.new, aliasesAndNames, true, root.id)) || props.alias.new
+ props.alias.new = (await this.uniqueRootAlias(space.id, props.alias.new, aliasesAndNames, true, root.id, true)) || props.alias.new
// remove from space cache permissions
this.spacesQueries
.clearCachePermissions(space.alias, [props.alias.old, props.alias.new])
@@ -718,7 +739,7 @@ export class SpacesManager {
if (!r.externalPath) {
r.file = { ...(await getProps(rPath, r.file.path)), id: r.file.id }
}
- r.alias = (await this.uniqueRootAlias(space.id, r.alias, aliases.concat(names), true)) || r.alias
+ r.alias = (await this.uniqueRootAlias(space.id, r.alias, aliases.concat(names), true, undefined, true)) || r.alias
// update aliases list for next roots
aliases.push(r.alias)
r.name = this.uniqueRootName(r.name, names) || r.name
@@ -787,15 +808,30 @@ export class SpacesManager {
}
}
- private async uniqueSpaceAlias(name: string, replaceCount = false, excludedSpaceId?: number): Promise<string> {
- return createUniqueAlias(this.createAliasSlug(name, replaceCount), (alias: string) =>
- this.spacesQueries.spaceExistsForAlias(alias, excludedSpaceId)
- )
+ private async uniqueSpaceAlias(name: string, excludedSpaceId?: number): Promise<string> {
+ const base = this.createAliasSlug(name).replace(regExpNumberSuffix, '')
+ const graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(base)
+ for (let count = 0; ; count += 1) {
+ const suffix = count ? `-${count}` : ''
+ let bytes = Buffer.byteLength(suffix, 'utf8')
+ let prefix = ''
+ // Space aliases are directory names: reserve the suffix within a 255-byte UTF-8 component.
+ for (const { segment } of graphemes) {
+ const segmentBytes = Buffer.byteLength(segment, 'utf8')
+ if (bytes + segmentBytes > 255) break
+ prefix += segment
+ bytes += segmentBytes
+ }
+ // Truncation can leave no letters or numbers; keep a usable base in that case.
+ prefix = prefix.replace(/-+$/g, '')
+ const alias = `${regExpLetterOrNumber.test(prefix) ? prefix : 'space'}${suffix}`
+ if (alias !== SPACE_ALIAS.PERSONAL && !(await this.spacesQueries.spaceExistsForAlias(alias, excludedSpaceId))) return alias
+ }
}
- private createAliasSlug(name: string, replaceCount = false): string {
+ private createAliasSlug(name: string): string {
try {
- return createSlug(name, replaceCount)
+ return createSlug(name)
} catch (e) {
if (e instanceof InvalidSlugError) {
throw new HttpException(e.message, HttpStatus.BAD_REQUEST)
diff --git a/backend/src/applications/spaces/utils/alias.spec.ts b/backend/src/applications/spaces/utils/alias.spec.ts
new file mode 100644
index 00000000..49442b44
--- /dev/null
+++ b/backend/src/applications/spaces/utils/alias.spec.ts
@@ -0,0 +1,85 @@
+import { createUniqueAlias } from './alias.js'
+
+describe('createUniqueAlias', () => {
+ it('resolves aliases from a common base without retaining the numeric suffix', async () => {
+ const aliasExists = vi.fn(async (alias: string) => ['docs', 'docs-1', 'docs-2'].includes(alias))
+
+ await expect(createUniqueAlias('docs-2', aliasExists, { replaceCount: true })).resolves.toBe('docs-3')
+ expect(aliasExists.mock.calls).toEqual([['docs'], ['docs-1'], ['docs-2'], ['docs-3']])
+ })
+
+ it.each([
+ [false, 'rapport.pdf', [['rapport.pdf']]],
+ [true, 'rapport-1.pdf', [['rapport.pdf'], ['rapport-1.pdf']]]
+ ])('resolves a complete root alias with collision=%s', async (collision, expected, calls) => {
+ const aliasExists = vi.fn(async (alias: string) => collision && alias === 'rapport.pdf')
+
+ await expect(createUniqueAlias('rapport-2', aliasExists, { extension: '.pdf', replaceCount: true })).resolves.toBe(expected)
+ expect(aliasExists.mock.calls).toEqual(calls)
+ })
+
+ it.each(['é'.repeat(255), '𐐨'.repeat(255)])('preserves an alias of exactly 255 Unicode code points', async (alias) => {
+ const aliasExists = vi.fn(async () => false)
+
+ await expect(createUniqueAlias(alias, aliasExists)).resolves.toBe(alias)
+ expect(aliasExists).toHaveBeenCalledExactlyOnceWith(alias)
+ })
+
+ it('truncates whole graphemes and reserves the collision suffix within 255 code points', async () => {
+ const aliasExists = vi.fn().mockResolvedValueOnce(true).mockResolvedValueOnce(false)
+ const base = 'कि'.repeat(128)
+
+ await expect(createUniqueAlias(base, aliasExists)).resolves.toBe(`${'कि'.repeat(126)}-1`)
+ expect(aliasExists.mock.calls).toEqual([['कि'.repeat(127)], [`${'कि'.repeat(126)}-1`]])
+ })
+
+ it('reserves additional suffix characters at two digits while keeping the extension', async () => {
+ const aliasExists = vi.fn(async (alias: string) => !alias.endsWith('-10.pdf'))
+
+ await expect(createUniqueAlias('a'.repeat(255), aliasExists, { extension: '.pdf' })).resolves.toBe(`${'a'.repeat(248)}-10.pdf`)
+ expect(aliasExists).toHaveBeenCalledTimes(11)
+ expect(aliasExists).toHaveBeenNthCalledWith(1, `${'a'.repeat(251)}.pdf`)
+ expect(aliasExists).toHaveBeenNthCalledWith(10, `${'a'.repeat(249)}-9.pdf`)
+ expect(aliasExists).toHaveBeenNthCalledWith(11, `${'a'.repeat(248)}-10.pdf`)
+ for (const [alias] of aliasExists.mock.calls) {
+ expect(Array.from(alias).length).toBeLessThanOrEqual(255)
+ }
+ })
+
+ it('bounds an oversized extension while retaining a base and a collision suffix', async () => {
+ const aliasExists = vi.fn().mockResolvedValueOnce(true).mockResolvedValueOnce(false)
+
+ await expect(createUniqueAlias('rapport', aliasExists, { extension: `.${'x'.repeat(300)}` })).resolves.toBe(`r-1.${'x'.repeat(251)}`)
+ expect(aliasExists.mock.calls).toEqual([[`r.${'x'.repeat(253)}`], [`r-1.${'x'.repeat(251)}`]])
+ })
+
+ it('drops an extension when its first word grapheme cannot fit without being split', async () => {
+ const aliasExists = vi.fn(async () => false)
+
+ await expect(createUniqueAlias('rapport', aliasExists, { extension: `.a${'\u0301'.repeat(254)}` })).resolves.toBe('rapport')
+ expect(aliasExists).toHaveBeenCalledExactlyOnceWith('rapport')
+ })
+
+ it('uses a bounded fallback when a single base grapheme exceeds the character limit', async () => {
+ const aliasExists = vi.fn().mockResolvedValueOnce(true).mockResolvedValueOnce(false)
+
+ await expect(createUniqueAlias(`a${'\u0301'.repeat(255)}`, aliasExists)).resolves.toBe('alias-1')
+ expect(aliasExists.mock.calls).toEqual([['alias'], ['alias-1']])
+ })
+
+ it('keeps a usable base when truncation removes the only letter', async () => {
+ const aliasExists = vi.fn().mockResolvedValueOnce(true).mockResolvedValueOnce(false)
+
+ await expect(createUniqueAlias(`${'📷'.repeat(255)}a`, aliasExists)).resolves.toBe('alias-1')
+ expect(aliasExists.mock.calls).toEqual([['alias'], ['alias-1']])
+ })
+
+ it('reserves room for the fallback base when an extension leaves only symbols in the prefix', async () => {
+ const aliasExists = vi.fn().mockResolvedValueOnce(true).mockResolvedValueOnce(false)
+
+ await expect(createUniqueAlias(`${'📷'.repeat(5)}a`, aliasExists, { extension: `.${'x'.repeat(300)}` })).resolves.toBe(
+ `alias-1.${'x'.repeat(247)}`
+ )
+ expect(aliasExists.mock.calls).toEqual([[`alias.${'x'.repeat(249)}`], [`alias-1.${'x'.repeat(247)}`]])
+ })
+})
diff --git a/backend/src/applications/spaces/utils/alias.ts b/backend/src/applications/spaces/utils/alias.ts
index 17fbd218..68c36f7c 100644
--- a/backend/src/applications/spaces/utils/alias.ts
+++ b/backend/src/applications/spaces/utils/alias.ts
@@ -1,14 +1,48 @@
+import { regExpLetterOrNumber, regExpNumberSuffix } from '../../../common/shared.js'
import { SPACE_ALIAS } from '../constants/spaces.js'
-const RESERVED_ALIASES = new Set<string>([SPACE_ALIAS.PERSONAL])
+export interface UniqueAliasOptions {
+ extension?: string
+ /** Remove the existing numeric suffix before checking the base alias, then try -1, -2, etc. */
+ replaceCount?: boolean
+}
+
+const MAX_ALIAS_LENGTH = 255
+const FALLBACK_ALIAS = 'alias'
+const aliasSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' })
-export async function createUniqueAlias(alias: string, aliasExists: (alias: string) => Promise<unknown>): Promise<string> {
- const originalAlias = alias
- let count = 0
+function truncateAliasPart(value: string, maxLength: number): string {
+ let prefix = ''
+ let length = 0
+ for (const { segment } of aliasSegmenter.segment(value)) {
+ length += Array.from(segment).length
+ if (length > maxLength) break
+ prefix += segment
+ }
+ return prefix
+}
- while (RESERVED_ALIASES.has(alias) || (await aliasExists(alias))) {
- count += 1
- alias = `${originalAlias}-${count}`
+export async function createUniqueAlias(
+ alias: string,
+ aliasExists: (alias: string) => Promise<unknown>,
+ { extension = '', replaceCount = false }: UniqueAliasOptions = {}
+): Promise<string> {
+ const originalAlias = replaceCount ? alias.replace(regExpNumberSuffix, '') : alias
+ const firstGrapheme = aliasSegmenter.segment(originalAlias).containing(0)?.segment ?? ''
+ const firstGraphemeLength = Array.from(firstGrapheme).length
+ for (let count = 0; ; count += 1) {
+ const suffix = count ? `-${count}` : ''
+ // VARCHAR(255) counts Unicode code points, not UTF-8 bytes or UTF-16 code units.
+ const remainingLength = MAX_ALIAS_LENGTH - suffix.length
+ const minimumBaseLength = firstGraphemeLength > 0 && firstGraphemeLength <= remainingLength ? firstGraphemeLength : FALLBACK_ALIAS.length
+ // Keep a usable base even when the extension or its first grapheme exceeds the budget.
+ let candidateExtension = truncateAliasPart(extension, remainingLength - minimumBaseLength).replace(/^\.$/, '')
+ let prefix = truncateAliasPart(originalAlias, remainingLength - Array.from(candidateExtension).length)
+ if (!regExpLetterOrNumber.test(prefix)) {
+ prefix = FALLBACK_ALIAS
+ candidateExtension = truncateAliasPart(extension, remainingLength - FALLBACK_ALIAS.length).replace(/^\.$/, '')
+ }
+ const candidate = `${prefix}${suffix}${candidateExtension}`
+ if (candidate !== SPACE_ALIAS.PERSONAL && !(await aliasExists(candidate))) return candidate
}
- return alias
}
diff --git a/backend/src/common/shared.spec.ts b/backend/src/common/shared.spec.ts
index e57a09f7..4bcc280f 100644
--- a/backend/src/common/shared.spec.ts
+++ b/backend/src/common/shared.spec.ts
@@ -1,4 +1,4 @@
-import { createCacheKeySlug, createSlug, InvalidSlugError, stripMatchingQuotes } from './shared.js'
+import { createCacheKeySlug, createLightSlug, createSlug, InvalidSlugError, stripMatchingQuotes } from './shared.js'
describe(createSlug.name, () => {
it.each([
@@ -7,23 +7,160 @@ describe(createSlug.name, () => {
['Hello.world', 'hello-world'],
['Hello/world', 'hello-world'],
['Hello\\world', 'hello-world'],
- ['Équipe 東京', 'equipe-東京']
+ ['Équipe 東京', 'equipe-東京'],
+ ['foo\ufe0f', 'foo'],
+ ['foo\ufe0fbar', 'foo-bar'],
+ ['ffi'.repeat(86), 'ffi'.repeat(86)],
+ ['FOO 123', 'foo-123'],
+ ['İ I ı', 'i-i-ı'],
+ ['\u0301東京 / \u093f hello', '東京-hello'],
+ ['कि', 'क'],
+ ['قُرْآن', 'ق-ر-ا-ن'],
+ ['Équipe (Paris)', 'equipe-paris'],
+ ['Équipe (Paris) + 東京', 'equipe-paris-東京'],
+ ['Rapport n°42', 'rapport-n-42'],
+ ['Photos 📷', 'photos'],
+ [' Team__Root--- Folder ', 'team-root-folder']
])('should convert %s to %s', (value, expectedValue) => {
expect(createSlug(value)).toBe(expectedValue)
+ expect(createSlug(expectedValue)).toBe(expectedValue)
+ })
+
+ it.each([
+ ['cafe\u0301', 'café', 'cafe'],
+ ['か\u3099', 'が', 'か'],
+ ['\u1100\u1161', '가', '\u1100\u1161']
+ ])('should normalize %s and %s to the same alias', (decomposed, composed, expectedValue) => {
+ expect(createSlug(decomposed)).toBe(expectedValue)
+ expect(createSlug(composed)).toBe(expectedValue)
+ })
+
+ it.each([
+ ['\u200chello\u200d', 'hello'],
+ ['hello\u200cworld', 'hello-world'],
+ ['1\u200d2', '1-2'],
+ ['क्\u200d\u200dष', 'क-ष'],
+ ['\ufe0f東京', '東京']
+ ])('should treat join controls and variation selectors as separators in %s', (value, expectedValue) => {
+ expect(createSlug(value)).toBe(expectedValue)
+ })
+
+ it.each([
+ '.',
+ '/',
+ '\\',
+ ':',
+ '*',
+ '?',
+ '"',
+ '<',
+ '>',
+ '|',
+ '#',
+ '%',
+ ';',
+ '(',
+ ')',
+ '+',
+ '\u0000',
+ '\u001f',
+ '\u007f',
+ '\u009f',
+ '\u202e',
+ '\ud800',
+ '\udfff'
+ ])('should separate Unicode words around %j', (character) => {
+ expect(createSlug(`Équipe${character}Paris`)).toBe('equipe-paris')
})
it('should remove a numeric suffix when requested', () => {
expect(createSlug('workspace-2', true)).toBe('workspace')
})
- it.each(['', '.', '..', '---', '___'])('should reject an empty slug generated from %s', (value) => {
- expect(() => createSlug(value)).toThrow(InvalidSlugError)
+ it.each(['', '.', '..', '---', '___', '📷', '\u0301', '\u093f', '\u180b', '\u{e0100}', '\u200c\u200d'])(
+ 'should reject a slug without any letters or numbers generated from %s',
+ (value) => {
+ expect(() => createSlug(value)).toThrow(InvalidSlugError)
+ }
+ )
+})
+
+describe(createLightSlug.name, () => {
+ it('should keep removing accents for authentication and application-password names', () => {
+ expect(createLightSlug(' ÉQUIPE CAFÉ ')).toBe('equipe cafe')
})
})
describe(createCacheKeySlug.name, () => {
it('should preserve cache pattern metacharacters', () => {
- expect(createCacheKeySlug(['SpacesQueries', 'spaces', 1, '*'])).toBe('spacesqueries-spaces-1-*')
+ expect(createCacheKeySlug(['SpacesQueries', 'spaces', 1, '*'])).toBe('spacesqueries:spaces:1:*')
+ })
+
+ it('should keep accented permission aliases distinct from unaccented aliases', () => {
+ const accentedKey = createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'equipe', 'café'])
+ const unaccentedKey = createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'equipe', 'cafe'])
+
+ expect(accentedKey).toBe('spacesqueries:permissions:1:equipe:café')
+ expect(unaccentedKey).toBe('spacesqueries:permissions:1:equipe:cafe')
+ expect(accentedKey).not.toBe(unaccentedKey)
+ })
+
+ it('should normalize NFC and NFD aliases to the same cache key', () => {
+ expect(createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'équipe', 'cafe\u0301'])).toBe(
+ createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'e\u0301quipe', 'café'])
+ )
+ })
+
+ it('should remain case insensitive while preserving accents', () => {
+ expect(createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'ÉQUIPE', 'CAFÉ'])).toBe(
+ createCacheKeySlug(['spacesqueries', 'permissions', 1, 'équipe', 'café'])
+ )
+ })
+
+ it('should preserve accented aliases and wildcards in permission invalidation patterns', () => {
+ expect(createCacheKeySlug(['SpacesQueries', 'permissions', '*', 'ÉQUIPE', 'cafe\u0301'])).toBe('spacesqueries:permissions:*:équipe:café')
+ expect(createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'équipe', '*'])).toBe('spacesqueries:permissions:1:équipe:*')
+ })
+
+ it('should keep argument boundaries distinct from hyphens in aliases', () => {
+ const firstKey = createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'foo-bar', 'baz'])
+ const secondKey = createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'foo', 'bar-baz'])
+
+ expect(firstKey).toBe('spacesqueries:permissions:1:foo-bar:baz')
+ expect(secondKey).toBe('spacesqueries:permissions:1:foo:bar-baz')
+ expect(firstKey).not.toBe(secondKey)
+ })
+
+ it.each([null, undefined])('should distinguish a %s argument from literal null aliases', (rootAlias) => {
+ const key = createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'equipe', rootAlias])
+
+ expect(key).toBe('spacesqueries:permissions:1:equipe:~null')
+ expect(key).not.toBe(createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'equipe', 'null']))
+ expect(key).not.toBe(createCacheKeySlug(['SpacesQueries', 'permissions', 1, 'equipe', '~null']))
+ })
+
+ it.each([
+ { firstArgs: ['foo:bar', 'baz'], secondArgs: ['foo', 'bar:baz'], expectedKey: 'foo%3Abar:baz' },
+ { firstArgs: ['foo:bar'], secondArgs: ['foo%3Abar'], expectedKey: 'foo%3Abar' },
+ { firstArgs: ['*'], secondArgs: ['%2A'], expectedKey: '*' },
+ { firstArgs: ['~null'], secondArgs: ['%7Enull'], expectedKey: '%7Enull' }
+ ])('should keep reserved characters distinct in $firstArgs and $secondArgs', ({ firstArgs, secondArgs, expectedKey }) => {
+ expect(createCacheKeySlug(firstArgs)).toBe(expectedKey)
+ expect(createCacheKeySlug(firstArgs)).not.toBe(createCacheKeySlug(secondArgs))
+ })
+
+ it('should escape literal asterisks while preserving whole-argument wildcards', () => {
+ expect(createCacheKeySlug(['SpacesQueries', 'permissions', '*', 'foo*bar', '*'])).toBe('spacesqueries:permissions:*:foo%2Abar:*')
+ })
+
+ it('should escape quotes and backticks instead of adding them to keys', () => {
+ expect(createCacheKeySlug(['"foo"', "'bar'", '\x60baz\x60'])).toBe('%22foo%22:%27bar%27:%60baz%60')
+ })
+
+ it('should preserve significant spaces, underscores and hyphens inside arguments', () => {
+ expect(createCacheKeySlug([' Team_Root-- Folder '])).toBe(' team_root-- folder ')
+ expect(createCacheKeySlug(['team_root'])).not.toBe(createCacheKeySlug(['team-root']))
+ expect(createCacheKeySlug(['team root'])).not.toBe(createCacheKeySlug(['team-root']))
})
})
diff --git a/backend/src/common/shared.ts b/backend/src/common/shared.ts
index df54b396..4f74aab9 100644
--- a/backend/src/common/shared.ts
+++ b/backend/src/common/shared.ts
@@ -15,6 +15,7 @@ export const APP_URL = {
export const regExpInvalidFileName = /^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$|[<>:"/\\|?*\x00-\x1f\x80-\x9f]/
export const regExpPreventPathTraversal = /^(\.\.(\/|\\|$))+/
export const regExpNumberSuffix = /-\d+$/
+export const regExpLetterOrNumber = /[\p{L}\p{N}]/u
export const forbiddenChars = '\\ / : * ? " < > |'
export class InvalidSlugError extends Error {
@@ -39,6 +40,8 @@ export function currentDate(value?: string): Date {
}
export function createSlug(input: string, replaceCount = false): string {
+ // Collapse runs of characters other than Unicode letters or numbers into one hyphen, then trim edge hyphens.
+ // When replaceCount is true, also remove an existing trailing numeric suffix (e.g. -2).
let slug = createLightSlug(input)
.replace(/[^\p{L}\p{N}]+/gu, '-')
.replace(/^-|-$/g, '')
@@ -53,10 +56,18 @@ export function createSlug(input: string, replaceCount = false): string {
}
export function createCacheKeySlug(args: unknown[]) {
- // Cache patterns intentionally preserve metacharacters such as `*`.
- return createLightSlug(args.map((arg) => (arg == null ? 'null' : String(arg))).join(' '))
- .replace(/[\s_-]+/g, '-')
- .replace(/^-+|-+$/g, '')
+ // Keep accents distinct while sharing keys across case and canonical Unicode forms.
+ // Escape reserved characters before joining arguments; only a whole `*` argument is a wildcard.
+ return args
+ .map((arg) => {
+ if (arg == null) return '~null'
+ if (arg === '*') return '*'
+ return String(arg)
+ .toLowerCase()
+ .normalize('NFC')
+ .replace(/[%:~*"'\x60]/g, (character) => '%' + character.charCodeAt(0).toString(16).toUpperCase())
+ })
+ .join(':')
}
export function createLightSlug(input: string) {
diff --git a/backend/src/infrastructure/cache/cache.e2e-spec.ts b/backend/src/infrastructure/cache/cache.e2e-spec.ts
index fae12fc1..14ac3c2c 100644
--- a/backend/src/infrastructure/cache/cache.e2e-spec.ts
+++ b/backend/src/infrastructure/cache/cache.e2e-spec.ts
@@ -123,7 +123,7 @@ describe(Cache.name, () => {
})
it('should create a slug key from parameters', () => {
- expect(cache.genSlugKey('foo', 'BAR', 12341)).toBe('foo-bar-12341')
+ expect(cache.genSlugKey('foo', 'BAR', 12341)).toBe('foo:bar:12341')
})
it('should consume, block and reset a rate limit', async () => {
diff --git a/backend/src/infrastructure/cache/schemas/mysql-cache.schema.ts b/backend/src/infrastructure/cache/schemas/mysql-cache.schema.ts
index ea9892ca..b2021a1f 100644
--- a/backend/src/infrastructure/cache/schemas/mysql-cache.schema.ts
+++ b/backend/src/infrastructure/cache/schemas/mysql-cache.schema.ts
@@ -1,12 +1,17 @@
-import { index, int, mysqlTable, varchar } from 'drizzle-orm/mysql-core'
-import { jsonColumn } from '../../database/columns.js'
+import { sql } from 'drizzle-orm'
+import { index, int, mysqlTable, uniqueIndex } from 'drizzle-orm/mysql-core'
+import { jsonColumn, pathVarchar } from '../../database/columns.js'
export const cache = mysqlTable(
'cache',
{
- key: varchar('key', { length: 768 }).primaryKey(),
+ key: pathVarchar('key', { length: 8192 }).notNull(),
value: jsonColumn<any>()('value'),
expiration: int('expiration').default(-1).notNull()
},
- (table) => [index('expiration_idx').on(table.expiration)]
+ (table) => [
+ uniqueIndex('cache_key_unique').on(table.key),
+ index('cache_key_prefix_idx').on(sql`${table.key}(768)`),
+ index('expiration_idx').on(table.expiration)
+ ]
)
diff --git a/backend/src/infrastructure/database/columns.spec.ts b/backend/src/infrastructure/database/columns.spec.ts
new file mode 100644
index 00000000..6f44719a
--- /dev/null
+++ b/backend/src/infrastructure/database/columns.spec.ts
@@ -0,0 +1,76 @@
+import { sql } from 'drizzle-orm'
+import { getTableConfig, MySqlDialect, mysqlTable } from 'drizzle-orm/mysql-core'
+import { filesRecents } from '../../applications/files/schemas/files-recents.schema.js'
+import { files } from '../../applications/files/schemas/files.schema.js'
+import { shares } from '../../applications/shares/schemas/shares.schema.js'
+import { spacesRoots } from '../../applications/spaces/schemas/spaces-roots.schema.js'
+import { spaces } from '../../applications/spaces/schemas/spaces.schema.js'
+import { cache } from '../cache/schemas/mysql-cache.schema.js'
+import { pathVarchar } from './columns.js'
+import { DB_CHARSET, DB_PATH_COLLATION } from './constants.js'
+
+describe('pathVarchar', () => {
+ const columns = mysqlTable('path_columns', {
+ path: pathVarchar('path', { length: 4096 }).notNull(),
+ name: pathVarchar('name', { length: 255 }).notNull(),
+ externalPath: pathVarchar('externalPath', { length: 4096 })
+ })
+
+ it('should include the character set and collation in the SQL type used by migrations', () => {
+ expect(columns.path.getSQLType()).toBe(`varchar(4096) CHARACTER SET ${DB_CHARSET} COLLATE ${DB_PATH_COLLATION}`)
+ expect(columns.name.getSQLType()).toBe(`varchar(255) CHARACTER SET ${DB_CHARSET} COLLATE ${DB_PATH_COLLATION}`)
+ expect(columns.externalPath.getSQLType()).toBe(`varchar(4096) CHARACTER SET ${DB_CHARSET} COLLATE ${DB_PATH_COLLATION}`)
+ })
+
+ it('should preserve explicit column nullability', () => {
+ expect(columns.path.notNull).toBe(true)
+ expect(columns.name.notNull).toBe(true)
+ expect(columns.externalPath.notNull).toBe(false)
+ })
+
+ it.each(['cafe', 'caf\u00e9', 'cafe\u0301', 'Photos', 'photos', 'dossier ', '100%_done='])('should preserve %j without normalization', (value) => {
+ expect(columns.path.mapToDriverValue(value)).toBe(value)
+ expect(columns.path.mapFromDriverValue(value)).toBe(value)
+ })
+})
+
+describe('metadata schema collations', () => {
+ it.each([
+ { name: 'cache.key', column: cache.key, length: 8192 },
+ { name: 'files.path', column: files.path, length: 4096 },
+ { name: 'files.name', column: files.name, length: 255 },
+ { name: 'files_recents.path', column: filesRecents.path, length: 4096 },
+ { name: 'files_recents.name', column: filesRecents.name, length: 255 },
+ { name: 'spaces.alias', column: spaces.alias, length: 255 },
+ { name: 'spaces.name', column: spaces.name, length: 255 },
+ { name: 'spaces_roots.alias', column: spacesRoots.alias, length: 255 },
+ { name: 'spaces_roots.name', column: spacesRoots.name, length: 255 },
+ { name: 'spaces_roots.externalPath', column: spacesRoots.externalPath, length: 4096 },
+ { name: 'shares.alias', column: shares.alias, length: 255 },
+ { name: 'shares.name', column: shares.name, length: 255 },
+ { name: 'shares.externalPath', column: shares.externalPath, length: 4096 }
+ ])('declares the shared collation on $name', ({ column, length }) => {
+ expect(column.getSQLType()).toBe(`varchar(${length}) CHARACTER SET ${DB_CHARSET} COLLATE ${DB_PATH_COLLATION}`)
+ })
+
+ it('keeps long cache keys non-null without a primary key and preserves JSON values', () => {
+ expect(cache.key.primary).toBe(false)
+ expect(cache.key.notNull).toBe(true)
+ expect(cache.value.getSQLType()).toBe('json')
+ })
+
+ it('enforces full cache-key uniqueness and uses a non-unique prefix index', () => {
+ const { indexes } = getTableConfig(cache)
+ const uniqueKey = indexes.find((entry) => entry.config.name === 'cache_key_unique')
+ const prefixKey = indexes.find((entry) => entry.config.name === 'cache_key_prefix_idx')
+
+ expect(uniqueKey?.config.unique).toBe(true)
+ expect(uniqueKey?.config.columns).toEqual([cache.key])
+ expect(prefixKey?.config.unique).toBe(false)
+ expect(prefixKey?.config.columns).toHaveLength(1)
+ expect(new MySqlDialect().sqlToQuery(sql`${prefixKey?.config.columns[0]}`, 'indexes')).toMatchObject({
+ sql: '`key`(768)',
+ params: []
+ })
+ })
+})
diff --git a/backend/src/infrastructure/database/columns.ts b/backend/src/infrastructure/database/columns.ts
index ae2fc1ae..d93128e3 100644
--- a/backend/src/infrastructure/database/columns.ts
+++ b/backend/src/infrastructure/database/columns.ts
@@ -1,4 +1,16 @@
import { customType } from 'drizzle-orm/mysql-core'
+import { DB_CHARSET, DB_PATH_COLLATION } from './constants.js'
+
+export const pathVarchar = customType<{
+ data: string
+ driverData: string
+ config: { length: number }
+ configRequired: true
+}>({
+ dataType({ length }) {
+ return `varchar(${length}) CHARACTER SET ${DB_CHARSET} COLLATE ${DB_PATH_COLLATION}`
+ }
+})
export const jsonColumn = <T>() =>
customType<{ data: T; driverData: string | null }>({
diff --git a/backend/src/infrastructure/database/constants.ts b/backend/src/infrastructure/database/constants.ts
index 1c670f38..82458e33 100644
--- a/backend/src/infrastructure/database/constants.ts
+++ b/backend/src/infrastructure/database/constants.ts
@@ -5,6 +5,8 @@ import { fileURLToPath } from 'node:url'
const moduleDir = path.dirname(fileURLToPath(import.meta.url))
export const DB_CHARSET = 'utf8mb4'
+// Changing this collation after deployment also requires a new database migration.
+export const DB_PATH_COLLATION = 'utf8mb4_uca1400_nopad_as_ci'
export const DB_TOKEN_PROVIDER = 'DB'
export const DB_SESSION_INIT_QUERIES = [
// Use UTC for SQL date/time functions and TIMESTAMP values.
@@ -25,5 +27,5 @@ export function getSchemaPath(): string {
}
}
- throw new Error('No schema.ts or schema.js file found !')
+ throw new Error('No schema.[ts|js] file found !')
}
diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml
index fe29120d..72d0d664 100644
--- a/docker/docker-compose.yaml
+++ b/docker/docker-compose.yaml
@@ -39,7 +39,11 @@ services:
image: mariadb:11
container_name: mariadb
restart: always
- command: --innodb_ft_cache_size=16000000 --max-allowed-packet=1G
+ command:
+ - --innodb_ft_cache_size=16000000
+ - --max-allowed-packet=1G
+ - --character-set-server=utf8mb4
+ - --collation-server=utf8mb4_uca1400_ai_ci
environment:
MYSQL_ROOT_PASSWORD: MySQLRootPassword
MYSQL_DATABASE: sync_in