init: new structure + fix lint errors
This commit is contained in:
@@ -0,0 +1,341 @@
|
||||
// Enums (expanded + used for Webhooks/JobEvents)
|
||||
|
||||
enum ProjectStatusEnum {
|
||||
DRAFT
|
||||
IN_PROGRESS
|
||||
REVIEW
|
||||
COMPLETED
|
||||
ARCHIVED
|
||||
CANCELED
|
||||
}
|
||||
|
||||
enum StorageBackendEnum {
|
||||
LOCAL
|
||||
S3
|
||||
}
|
||||
|
||||
enum MediaFileTypeEnum {
|
||||
VIDEO
|
||||
AUDIO
|
||||
IMAGE
|
||||
}
|
||||
|
||||
enum SourceTypeEnum {
|
||||
UPLOAD
|
||||
IMPORT
|
||||
RECORDING
|
||||
GENERATED
|
||||
}
|
||||
|
||||
enum ArtifactTypeEnum {
|
||||
VIDEO
|
||||
AUDIO
|
||||
THUMBNAIL
|
||||
PREVIEW
|
||||
WAVEFORM
|
||||
TRANSCRIPT_JSON
|
||||
METADATA
|
||||
}
|
||||
|
||||
enum TranscribeEngineEnum {
|
||||
LOCAL_WHISPER
|
||||
GOOGLE_CLOUD
|
||||
}
|
||||
|
||||
enum JobStatusEnum {
|
||||
QUEUED
|
||||
STARTED
|
||||
IN_PROGRESS
|
||||
SUCCEEDED
|
||||
FAILED
|
||||
CANCELED
|
||||
RETRYING
|
||||
}
|
||||
|
||||
enum WebhookEventEnum {
|
||||
PROJECT_CREATED
|
||||
PROJECT_UPDATED
|
||||
FILE_UPLOADED
|
||||
ARTIFACT_CREATED
|
||||
TRANSCRIPTION_COMPLETED
|
||||
JOB_STARTED
|
||||
JOB_PROGRESS
|
||||
JOB_SUCCEEDED
|
||||
JOB_FAILED
|
||||
}
|
||||
|
||||
enum JobEventTypeEnum {
|
||||
LOG
|
||||
STATUS_CHANGED
|
||||
PROGRESS
|
||||
WARNING
|
||||
ERROR
|
||||
}
|
||||
|
||||
// Tables
|
||||
|
||||
Table Users {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
deleted_at datetime
|
||||
|
||||
username varchar(150) [unique]
|
||||
email varchar [unique]
|
||||
|
||||
password_hash varchar(255)
|
||||
|
||||
first_name varchar(150)
|
||||
last_name varchar(150)
|
||||
|
||||
phone_number varchar(16)
|
||||
avatar varchar(2048)
|
||||
|
||||
email_verified boolean
|
||||
phone_verified boolean
|
||||
|
||||
// Replace is_staff and is_superuser with role system later
|
||||
is_staff boolean
|
||||
is_superuser boolean
|
||||
|
||||
date_joined datetime
|
||||
last_login datetime
|
||||
|
||||
Indexes {
|
||||
(email) [name: "idx_users_email"]
|
||||
(username) [name: "idx_users_username"]
|
||||
(is_active) [name: "idx_users_is_active"]
|
||||
(deleted_at) [name: "idx_users_deleted_at"]
|
||||
}
|
||||
}
|
||||
|
||||
Table Projects {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
deleted_at datetime
|
||||
|
||||
owner_id uuid
|
||||
|
||||
name varchar(150)
|
||||
description varchar(4096)
|
||||
language varchar(3)
|
||||
folder varchar
|
||||
status ProjectStatusEnum
|
||||
|
||||
Indexes {
|
||||
(owner_id) [name: "idx_projects_owner_id"]
|
||||
(status) [name: "idx_projects_status"]
|
||||
(is_active) [name: "idx_projects_is_active"]
|
||||
(deleted_at) [name: "idx_projects_deleted_at"]
|
||||
}
|
||||
}
|
||||
|
||||
Table Files {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
deleted_at datetime
|
||||
|
||||
project_id uuid
|
||||
owner_id uuid
|
||||
|
||||
original_file_name varchar
|
||||
path varchar
|
||||
|
||||
storage_backend StorageBackendEnum
|
||||
mime_type varchar
|
||||
size_bytes bigint
|
||||
checksum varchar(256)
|
||||
file_format varchar(10)
|
||||
|
||||
is_uploaded boolean
|
||||
|
||||
Indexes {
|
||||
(project_id) [name: "idx_files_project_id"]
|
||||
(owner_id) [name: "idx_files_owner_id"]
|
||||
(checksum) [name: "idx_files_checksum"]
|
||||
(is_uploaded) [name: "idx_files_is_uploaded"]
|
||||
(is_active) [name: "idx_files_is_active"]
|
||||
(deleted_at) [name: "idx_files_deleted_at"]
|
||||
}
|
||||
}
|
||||
|
||||
// Normalized: MediaFiles extends Files (no duplicate project_id/owner_id)
|
||||
Table MediaFiles {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
deleted_at datetime
|
||||
|
||||
file_id uuid [unique]
|
||||
|
||||
duration_sec float
|
||||
frame_rate float
|
||||
width integer
|
||||
height integer
|
||||
|
||||
probe_json jsonb
|
||||
notes varchar(4096)
|
||||
meta jsonb
|
||||
|
||||
file_type MediaFileTypeEnum
|
||||
source_type SourceTypeEnum
|
||||
|
||||
Indexes {
|
||||
(file_id) [name: "idx_mediafiles_file_id"]
|
||||
(file_type) [name: "idx_mediafiles_file_type"]
|
||||
(source_type) [name: "idx_mediafiles_source_type"]
|
||||
(is_active) [name: "idx_mediafiles_is_active"]
|
||||
(deleted_at) [name: "idx_mediafiles_deleted_at"]
|
||||
}
|
||||
}
|
||||
|
||||
// Normalized: Artifact points to output file; lineage via source_media_file_id
|
||||
Table Artifacts {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
deleted_at datetime
|
||||
|
||||
output_file_id uuid [unique]
|
||||
source_media_file_id uuid
|
||||
|
||||
artifact_type ArtifactTypeEnum
|
||||
|
||||
Indexes {
|
||||
(output_file_id) [name: "idx_artifacts_output_file_id"]
|
||||
(source_media_file_id) [name: "idx_artifacts_source_media_file_id"]
|
||||
(artifact_type) [name: "idx_artifacts_artifact_type"]
|
||||
(is_active) [name: "idx_artifacts_is_active"]
|
||||
(deleted_at) [name: "idx_artifacts_deleted_at"]
|
||||
}
|
||||
}
|
||||
|
||||
// Normalized: no duplicate project_id; derive via input_file_id / transcript_artifact_id
|
||||
Table Transcriptions {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
deleted_at datetime
|
||||
|
||||
input_file_id uuid
|
||||
transcript_artifact_id uuid
|
||||
|
||||
engine TranscribeEngineEnum
|
||||
language varchar(3)
|
||||
|
||||
document jsonb
|
||||
transcribe_options jsonb
|
||||
|
||||
Indexes {
|
||||
(input_file_id) [name: "idx_transcriptions_input_file_id"]
|
||||
(transcript_artifact_id) [unique, name: "ux_transcriptions_transcript_artifact_id"]
|
||||
(engine) [name: "idx_transcriptions_engine"]
|
||||
(is_active) [name: "idx_transcriptions_is_active"]
|
||||
(deleted_at) [name: "idx_transcriptions_deleted_at"]
|
||||
}
|
||||
}
|
||||
|
||||
Table Jobs {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
|
||||
broker_id varchar(255) [unique]
|
||||
|
||||
user_id uuid
|
||||
project_id uuid
|
||||
|
||||
input_data jsonb
|
||||
output_data jsonb
|
||||
|
||||
status JobStatusEnum
|
||||
progress_pct integer
|
||||
|
||||
error_message varchar(4096)
|
||||
current_message varchar(4096)
|
||||
|
||||
started_at datetime
|
||||
finished_at datetime
|
||||
|
||||
Indexes {
|
||||
(broker_id) [name: "idx_jobs_broker_id"]
|
||||
(user_id) [name: "idx_jobs_user_id"]
|
||||
(project_id) [name: "idx_jobs_project_id"]
|
||||
(status) [name: "idx_jobs_status"]
|
||||
(is_active) [name: "idx_jobs_is_active"]
|
||||
}
|
||||
}
|
||||
|
||||
Table JobEvents {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
|
||||
job_id uuid
|
||||
event_type JobEventTypeEnum
|
||||
payload jsonb
|
||||
|
||||
Indexes {
|
||||
(job_id) [name: "idx_jobevents_job_id"]
|
||||
(event_type) [name: "idx_jobevents_event_type"]
|
||||
(created_at) [name: "idx_jobevents_created_at"]
|
||||
(is_active) [name: "idx_jobevents_is_active"]
|
||||
}
|
||||
}
|
||||
|
||||
Table Webhooks {
|
||||
id uuid [pk]
|
||||
created_at datetime
|
||||
updated_at datetime
|
||||
is_active boolean
|
||||
deleted_at datetime
|
||||
|
||||
project_id uuid
|
||||
user_id uuid
|
||||
|
||||
event WebhookEventEnum
|
||||
url varchar(512)
|
||||
secret varchar(256)
|
||||
|
||||
Indexes {
|
||||
(project_id) [name: "idx_webhooks_project_id"]
|
||||
(user_id) [name: "idx_webhooks_user_id"]
|
||||
(event) [name: "idx_webhooks_event"]
|
||||
(project_id, event, url) [unique, name: "ux_webhooks_project_event_url"]
|
||||
(is_active) [name: "idx_webhooks_is_active"]
|
||||
(deleted_at) [name: "idx_webhooks_deleted_at"]
|
||||
}
|
||||
}
|
||||
|
||||
// Refs (fixed + aligned to actual FK columns)
|
||||
Ref: Projects.owner_id > Users.id
|
||||
|
||||
Ref: Files.project_id > Projects.id
|
||||
Ref: Files.owner_id > Users.id
|
||||
|
||||
Ref: MediaFiles.file_id > Files.id
|
||||
|
||||
Ref: Artifacts.output_file_id > Files.id
|
||||
Ref: Artifacts.source_media_file_id > MediaFiles.id
|
||||
|
||||
Ref: Transcriptions.input_file_id > Files.id
|
||||
Ref: Transcriptions.transcript_artifact_id > Artifacts.id
|
||||
|
||||
Ref: Jobs.project_id > Projects.id
|
||||
Ref: Jobs.user_id > Users.id
|
||||
|
||||
Ref: JobEvents.job_id > Jobs.id
|
||||
|
||||
Ref: Webhooks.project_id > Projects.id
|
||||
Ref: Webhooks.user_id > Users.id
|
||||
|
||||
Reference in New Issue
Block a user