Skip to content

Commit e8ceba4

Browse files
committed
Database: Update entity/schema/mariadb.sql
Signed-off-by: Michael Mayer <[email protected]>
1 parent 6e41c46 commit e8ceba4

File tree

1 file changed

+57
-46
lines changed

1 file changed

+57
-46
lines changed

internal/entity/schema/mariadb.sql

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ CREATE TABLE `albums` (
3030
`deleted_at` datetime DEFAULT NULL,
3131
PRIMARY KEY (`id`),
3232
UNIQUE KEY `uix_albums_album_uid` (`album_uid`),
33-
KEY `idx_albums_album_path` (`album_path`(768)),
34-
KEY `idx_albums_album_title` (`album_title`),
3533
KEY `idx_albums_album_category` (`album_category`),
3634
KEY `idx_albums_album_state` (`album_state`),
35+
KEY `idx_albums_ymd` (`album_day`),
36+
KEY `idx_albums_published_at` (`published_at`),
37+
KEY `idx_albums_album_slug` (`album_slug`),
38+
KEY `idx_albums_album_title` (`album_title`),
3739
KEY `idx_albums_country_year_month` (`album_country`,`album_year`,`album_month`),
3840
KEY `idx_albums_thumb` (`thumb`),
3941
KEY `idx_albums_created_by` (`created_by`),
4042
KEY `idx_albums_deleted_at` (`deleted_at`),
41-
KEY `idx_albums_album_slug` (`album_slug`),
42-
KEY `idx_albums_ymd` (`album_day`),
43-
KEY `idx_albums_published_at` (`published_at`),
43+
KEY `idx_albums_album_path` (`album_path`(768)),
4444
KEY `idx_albums_album_filter` (`album_filter`(512))
4545
);
4646
CREATE TABLE `albums_users` (
@@ -49,8 +49,8 @@ CREATE TABLE `albums_users` (
4949
`team_uid` varbinary(42) DEFAULT NULL,
5050
`perm` int(10) unsigned DEFAULT NULL,
5151
PRIMARY KEY (`uid`,`user_uid`),
52-
KEY `idx_albums_users_user_uid` (`user_uid`),
53-
KEY `idx_albums_users_team_uid` (`team_uid`)
52+
KEY `idx_albums_users_team_uid` (`team_uid`),
53+
KEY `idx_albums_users_user_uid` (`user_uid`)
5454
);
5555
CREATE TABLE `audit_logins` (
5656
`client_ip` varchar(64) NOT NULL,
@@ -66,10 +66,10 @@ CREATE TABLE `audit_logins` (
6666
`created_at` datetime DEFAULT NULL,
6767
`updated_at` datetime DEFAULT NULL,
6868
PRIMARY KEY (`client_ip`,`login_name`,`login_realm`),
69-
KEY `idx_audit_logins_login_name` (`login_name`),
7069
KEY `idx_audit_logins_failed_at` (`failed_at`),
7170
KEY `idx_audit_logins_banned_at` (`banned_at`),
72-
KEY `idx_audit_logins_updated_at` (`updated_at`)
71+
KEY `idx_audit_logins_updated_at` (`updated_at`),
72+
KEY `idx_audit_logins_login_name` (`login_name`)
7373
);
7474
CREATE TABLE `audit_logs` (
7575
`id` int(10) unsigned NOT NULL,
@@ -79,11 +79,12 @@ CREATE TABLE `audit_logs` (
7979
`log_message` varbinary(2048) DEFAULT NULL,
8080
`log_repeated` bigint(20) DEFAULT NULL,
8181
PRIMARY KEY (`id`),
82-
KEY `idx_audit_logs_log_time` (`log_time`),
83-
KEY `idx_audit_logs_client_ip` (`client_ip`)
82+
KEY `idx_audit_logs_client_ip` (`client_ip`),
83+
KEY `idx_audit_logs_log_time` (`log_time`)
8484
);
8585
CREATE TABLE `auth_clients` (
8686
`client_uid` varbinary(42) NOT NULL,
87+
`node_uuid` varbinary(64) DEFAULT '',
8788
`user_uid` varbinary(42) DEFAULT '',
8889
`user_name` varchar(200) DEFAULT NULL,
8990
`client_name` varchar(200) DEFAULT NULL,
@@ -97,12 +98,16 @@ CREATE TABLE `auth_clients` (
9798
`auth_expires` bigint(20) DEFAULT NULL,
9899
`auth_tokens` bigint(20) DEFAULT NULL,
99100
`auth_enabled` tinyint(1) DEFAULT NULL,
101+
`refresh_token` varbinary(2048) DEFAULT '',
102+
`id_token` varbinary(2048) DEFAULT '',
103+
`data_json` varbinary(4096) DEFAULT NULL,
100104
`last_active` bigint(20) DEFAULT NULL,
101105
`created_at` datetime DEFAULT NULL,
102106
`updated_at` datetime DEFAULT NULL,
103107
PRIMARY KEY (`client_uid`),
104108
KEY `idx_auth_clients_user_uid` (`user_uid`),
105-
KEY `idx_auth_clients_user_name` (`user_name`)
109+
KEY `idx_auth_clients_user_name` (`user_name`),
110+
KEY `idx_auth_clients_node_uuid` (`node_uuid`)
106111
);
107112
CREATE TABLE `auth_sessions` (
108113
`id` varbinary(2048) NOT NULL,
@@ -133,12 +138,12 @@ CREATE TABLE `auth_sessions` (
133138
`created_at` datetime DEFAULT NULL,
134139
`updated_at` datetime DEFAULT NULL,
135140
PRIMARY KEY (`id`),
136-
KEY `idx_auth_sessions_client_ip` (`client_ip`),
137-
KEY `idx_auth_sessions_auth_id` (`auth_id`),
138141
KEY `idx_auth_sessions_sess_expires` (`sess_expires`),
139142
KEY `idx_auth_sessions_user_uid` (`user_uid`),
140143
KEY `idx_auth_sessions_user_name` (`user_name`),
141-
KEY `idx_auth_sessions_client_uid` (`client_uid`)
144+
KEY `idx_auth_sessions_client_uid` (`client_uid`),
145+
KEY `idx_auth_sessions_client_ip` (`client_ip`),
146+
KEY `idx_auth_sessions_auth_id` (`auth_id`)
142147
);
143148
CREATE TABLE `auth_users` (
144149
`id` int(11) NOT NULL,
@@ -179,14 +184,14 @@ CREATE TABLE `auth_users` (
179184
`deleted_at` datetime DEFAULT NULL,
180185
PRIMARY KEY (`id`),
181186
UNIQUE KEY `uix_auth_users_user_uid` (`user_uid`),
187+
KEY `idx_auth_users_user_uuid` (`user_uuid`),
182188
KEY `idx_auth_users_user_name` (`user_name`),
189+
KEY `idx_auth_users_expires_at` (`expires_at`),
183190
KEY `idx_auth_users_born_at` (`born_at`),
184191
KEY `idx_auth_users_thumb` (`thumb`),
185192
KEY `idx_auth_users_deleted_at` (`deleted_at`),
186-
KEY `idx_auth_users_user_uuid` (`user_uuid`),
187193
KEY `idx_auth_users_auth_id` (`auth_id`),
188194
KEY `idx_auth_users_user_email` (`user_email`),
189-
KEY `idx_auth_users_expires_at` (`expires_at`),
190195
KEY `idx_auth_users_invite_token` (`invite_token`)
191196
);
192197
CREATE TABLE `auth_users_details` (
@@ -225,10 +230,10 @@ CREATE TABLE `auth_users_details` (
225230
`created_at` datetime DEFAULT NULL,
226231
`updated_at` datetime DEFAULT NULL,
227232
PRIMARY KEY (`user_uid`),
228-
KEY `idx_auth_users_details_subj_uid` (`subj_uid`),
229-
KEY `idx_auth_users_details_place_id` (`place_id`),
230233
KEY `idx_auth_users_details_cell_id` (`cell_id`),
231-
KEY `idx_auth_users_details_org_email` (`org_email`)
234+
KEY `idx_auth_users_details_org_email` (`org_email`),
235+
KEY `idx_auth_users_details_subj_uid` (`subj_uid`),
236+
KEY `idx_auth_users_details_place_id` (`place_id`)
232237
);
233238
CREATE TABLE `auth_users_settings` (
234239
`user_uid` varbinary(42) NOT NULL,
@@ -356,6 +361,8 @@ CREATE TABLE `faces` (
356361
`sample_radius` double DEFAULT NULL,
357362
`collisions` int(11) DEFAULT NULL,
358363
`collision_radius` double DEFAULT NULL,
364+
`merge_retry` tinyint(3) DEFAULT 0,
365+
`merge_notes` varchar(255) DEFAULT '',
359366
`embedding_json` mediumblob DEFAULT NULL,
360367
`matched_at` datetime DEFAULT NULL,
361368
`created_at` datetime DEFAULT NULL,
@@ -415,19 +422,19 @@ CREATE TABLE `files` (
415422
`published_at` datetime DEFAULT NULL,
416423
`deleted_at` datetime DEFAULT NULL,
417424
PRIMARY KEY (`id`),
418-
UNIQUE KEY `uix_files_file_uid` (`file_uid`),
419425
UNIQUE KEY `idx_files_name_root` (`file_name`,`file_root`),
426+
UNIQUE KEY `uix_files_file_uid` (`file_uid`),
420427
UNIQUE KEY `idx_files_search_media` (`media_id`),
421428
UNIQUE KEY `idx_files_search_timeline` (`time_index`),
429+
KEY `idx_files_photo_id` (`photo_id`,`file_primary`),
422430
KEY `idx_files_photo_uid` (`photo_uid`),
423-
KEY `idx_files_photo_taken_at` (`photo_taken_at`),
424-
KEY `idx_files_instance_id` (`instance_id`),
425-
KEY `idx_files_file_hash` (`file_hash`),
426431
KEY `idx_files_file_error` (`file_error`),
432+
KEY `idx_files_published_at` (`published_at`),
427433
KEY `idx_files_deleted_at` (`deleted_at`),
428-
KEY `idx_files_photo_id` (`photo_id`,`file_primary`),
434+
KEY `idx_files_photo_taken_at` (`photo_taken_at`),
429435
KEY `idx_files_media_utc` (`media_utc`),
430-
KEY `idx_files_published_at` (`published_at`),
436+
KEY `idx_files_instance_id` (`instance_id`),
437+
KEY `idx_files_file_hash` (`file_hash`),
431438
KEY `idx_files_missing_root` (`file_missing`,`file_root`)
432439
);
433440
CREATE TABLE `files_share` (
@@ -479,10 +486,10 @@ CREATE TABLE `folders` (
479486
`deleted_at` datetime DEFAULT NULL,
480487
PRIMARY KEY (`folder_uid`),
481488
UNIQUE KEY `idx_folders_path_root` (`path`,`root`),
489+
KEY `idx_folders_deleted_at` (`deleted_at`),
482490
KEY `idx_folders_folder_category` (`folder_category`),
483491
KEY `idx_folders_country_year_month` (`folder_country`,`folder_year`,`folder_month`),
484-
KEY `idx_folders_published_at` (`published_at`),
485-
KEY `idx_folders_deleted_at` (`deleted_at`)
492+
KEY `idx_folders_published_at` (`published_at`)
486493
);
487494
CREATE TABLE `keywords` (
488495
`id` int(10) unsigned NOT NULL,
@@ -497,8 +504,9 @@ CREATE TABLE `labels` (
497504
`label_slug` varbinary(160) DEFAULT NULL,
498505
`custom_slug` varbinary(160) DEFAULT NULL,
499506
`label_name` varchar(160) DEFAULT NULL,
500-
`label_priority` int(11) DEFAULT NULL,
501-
`label_favorite` tinyint(1) DEFAULT NULL,
507+
`label_favorite` tinyint(1) DEFAULT 0,
508+
`label_priority` int(11) DEFAULT 0,
509+
`label_nsfw` tinyint(1) DEFAULT 0,
502510
`label_description` varchar(2048) DEFAULT NULL,
503511
`label_notes` varchar(1024) DEFAULT NULL,
504512
`photo_count` int(11) DEFAULT 1,
@@ -509,12 +517,12 @@ CREATE TABLE `labels` (
509517
`published_at` datetime DEFAULT NULL,
510518
`deleted_at` datetime DEFAULT NULL,
511519
PRIMARY KEY (`id`),
512-
UNIQUE KEY `uix_labels_label_slug` (`label_slug`),
513520
UNIQUE KEY `uix_labels_label_uid` (`label_uid`),
521+
UNIQUE KEY `uix_labels_label_slug` (`label_slug`),
522+
KEY `idx_labels_custom_slug` (`custom_slug`),
514523
KEY `idx_labels_thumb` (`thumb`),
515524
KEY `idx_labels_published_at` (`published_at`),
516-
KEY `idx_labels_deleted_at` (`deleted_at`),
517-
KEY `idx_labels_custom_slug` (`custom_slug`)
525+
KEY `idx_labels_deleted_at` (`deleted_at`)
518526
);
519527
CREATE TABLE `lenses` (
520528
`id` int(10) unsigned NOT NULL,
@@ -578,11 +586,11 @@ CREATE TABLE `markers` (
578586
`created_at` datetime DEFAULT NULL,
579587
`updated_at` datetime DEFAULT NULL,
580588
PRIMARY KEY (`marker_uid`),
589+
KEY `idx_markers_thumb` (`thumb`),
590+
KEY `idx_markers_matched_at` (`matched_at`),
581591
KEY `idx_markers_file_uid` (`file_uid`),
582592
KEY `idx_markers_subj_uid_src` (`subj_uid`,`subj_src`),
583-
KEY `idx_markers_face_id` (`face_id`),
584-
KEY `idx_markers_thumb` (`thumb`),
585-
KEY `idx_markers_matched_at` (`matched_at`)
593+
KEY `idx_markers_face_id` (`face_id`)
586594
);
587595
CREATE TABLE `migrations` (
588596
`id` varchar(16) NOT NULL,
@@ -663,25 +671,26 @@ CREATE TABLE `photos` (
663671
`updated_at` datetime DEFAULT NULL,
664672
`edited_at` datetime DEFAULT NULL,
665673
`published_at` datetime DEFAULT NULL,
674+
`indexed_at` datetime DEFAULT NULL,
666675
`checked_at` datetime DEFAULT NULL,
667676
`estimated_at` datetime DEFAULT NULL,
668677
`deleted_at` datetime DEFAULT NULL,
669678
PRIMARY KEY (`id`),
670679
UNIQUE KEY `uix_photos_photo_uid` (`photo_uid`),
680+
KEY `idx_photos_deleted_at` (`deleted_at`),
681+
KEY `idx_photos_path_name` (`photo_path`,`photo_name`),
682+
KEY `idx_photos_cell_id` (`cell_id`),
683+
KEY `idx_photos_photo_lat` (`photo_lat`),
684+
KEY `idx_photos_photo_lng` (`photo_lng`),
685+
KEY `idx_photos_country_year_month` (`photo_country`,`photo_year`,`photo_month`),
671686
KEY `idx_photos_ymd` (`photo_day`),
672687
KEY `idx_photos_camera_lens` (`camera_id`,`lens_id`),
673688
KEY `idx_photos_created_by` (`created_by`),
689+
KEY `idx_photos_uuid` (`uuid`),
674690
KEY `idx_photos_taken_uid` (`taken_at`,`photo_uid`),
675691
KEY `idx_photos_place_id` (`place_id`),
676-
KEY `idx_photos_cell_id` (`cell_id`),
677692
KEY `idx_photos_published_at` (`published_at`),
678-
KEY `idx_photos_checked_at` (`checked_at`),
679-
KEY `idx_photos_deleted_at` (`deleted_at`),
680-
KEY `idx_photos_uuid` (`uuid`),
681-
KEY `idx_photos_path_name` (`photo_path`,`photo_name`),
682-
KEY `idx_photos_photo_lat` (`photo_lat`),
683-
KEY `idx_photos_photo_lng` (`photo_lng`),
684-
KEY `idx_photos_country_year_month` (`photo_country`,`photo_year`,`photo_month`)
693+
KEY `idx_photos_checked_at` (`checked_at`)
685694
);
686695
CREATE TABLE `photos_albums` (
687696
`photo_uid` varbinary(42) NOT NULL,
@@ -705,6 +714,8 @@ CREATE TABLE `photos_labels` (
705714
`label_id` int(10) unsigned NOT NULL,
706715
`label_src` varbinary(8) DEFAULT NULL,
707716
`uncertainty` smallint(6) DEFAULT NULL,
717+
`topicality` smallint(6) DEFAULT 0,
718+
`nsfw` smallint(6) DEFAULT 0,
708719
PRIMARY KEY (`photo_id`,`label_id`),
709720
KEY `idx_photos_labels_label_id` (`label_id`)
710721
);
@@ -714,8 +725,8 @@ CREATE TABLE `photos_users` (
714725
`team_uid` varbinary(42) DEFAULT NULL,
715726
`perm` int(10) unsigned DEFAULT NULL,
716727
PRIMARY KEY (`uid`,`user_uid`),
717-
KEY `idx_photos_users_team_uid` (`team_uid`),
718-
KEY `idx_photos_users_user_uid` (`user_uid`)
728+
KEY `idx_photos_users_user_uid` (`user_uid`),
729+
KEY `idx_photos_users_team_uid` (`team_uid`)
719730
);
720731
CREATE TABLE `places` (
721732
`id` varbinary(42) NOT NULL,

0 commit comments

Comments
 (0)