before delete 3software

This commit is contained in:
2025-06-29 18:55:59 +03:00
parent ebd77a3e66
commit b51a472738
147 changed files with 257326 additions and 3151 deletions

Binary file not shown.

BIN
backend/data/db.sqlite-shm Normal file

Binary file not shown.

BIN
backend/data/db.sqlite-wal Normal file

Binary file not shown.

View File

@@ -23,6 +23,7 @@ create table if not exists projects (
description text check(description is null or length(description) < 4096),
logo text,
is_logo_bg integer default 0,
company_id integer references companies(id) on delete cascade,
is_archived integer default 0
) strict;
@@ -31,9 +32,13 @@ create table if not exists chats (
project_id integer references projects(id) on delete cascade,
name text,
telegram_id integer,
description text,
logo text,
access_hash integer,
is_channel integer check(is_channel in (0, 1)) default 0,
invite_link text,
bot_can_ban integer default 0,
owner_id integer references users(id) on delete set null,
user_count integer,
last_update_time integer
);
@@ -43,14 +48,12 @@ create table if not exists users (
id integer primary key autoincrement,
telegram_id integer,
access_hash integer,
firstname text,
lastname text,
username text,
firstname text check(firstname is null or length(firstname) < 256),
lastname text check(lastname is null or length(lastname) < 256),
username text check(username is null or length(username) < 256),
photo_id integer,
photo text,
language_code text,
phone text,
json_phone_projects text default '[]',
json_settings text default '{}'
) strict;
create unique index if not exists idx_users_telegram_id on users (telegram_id);
@@ -58,73 +61,89 @@ create unique index if not exists idx_users_telegram_id on users (telegram_id);
create table if not exists user_details (
user_id integer references users(id) on delete cascade,
project_id integer references projects(id) on delete cascade,
fullname text,
role text,
department text,
fullname text check(fullname is null or length(fullname) < 256),
email text check(email is null or length(email) < 256),
phone text check(phone is null or length(phone) < 256),
role text check(role is null or length(role) < 256),
department text check(department is null or length(department) < 256),
is_blocked integer check(is_blocked in (0, 1)) default 0,
primary key (user_id, project_id)
) strict;
create table if not exists tasks (
id integer primary key autoincrement,
project_id integer references projects(id) on delete cascade,
name text not null check(trim(name) <> '' and length(name) < 4096),
project_id integer references projects(id) on delete cascade,
name text not null check(trim(name) <> '' and length(name) < 256),
description text not null check(trim(description) <> '' and length(description) < 4096),
created_by integer references users(id) on delete set null,
assigned_to integer references users(id) on delete set null,
closed_by integer references users(id) on delete set null,
priority integer check(priority in (0, 1, 2, 3, 4, 5)) default 0,
status integer check(status >= 1 and status <= 10) default 1,
time_spent integer check(time_spent is null or time_spent > 0 and time_spent < 44640), -- one month
time_spent integer check(time_spent is null or time_spent > 0 and time_spent < 3 * 44640), -- one month
create_date integer,
plan_date integer,
close_date integer
close_date integer,
close_comment text check(close_comment is null or length(close_comment) < 1024),
json_close_files text,
chat_id integer references chats(id) on delete set null,
message_id integer
) strict;
create index if not exists idx_tasks_project_id on tasks (project_id);
create table if not exists meetings (
id integer primary key autoincrement,
project_id integer references projects(id) on delete cascade,
name text not null check(trim(name) <> '' and length(name) < 4096),
description text check(description is null or length(description) < 4096),
name text not null check(trim(name) <> '' and length(name) < 256),
description text check(description is null or length(description) < 1024),
place text check(place is null or length(place) < 4096),
created_by integer references users(id) on delete set null,
meet_date integer
meet_date integer,
duration integer,
chat_id integer references chats(id) on delete set null,
message_id integer,
is_cancel integer default 0
) strict;
create index if not exists idx_meetings_project_id on meetings (project_id);
create table if not exists documents (
create table if not exists files (
id integer primary key autoincrement,
project_id integer references projects(id) on delete cascade,
origin_chat_id integer references chats(id) on delete set null,
origin_message_id integer,
chat_id integer references chats(id) on delete set null,
message_id integer,
file_id integer,
access_hash integer,
filename text not null check(length(filename) < 256),
mime text check(mime is null or length(mime) < 128),
caption text check(caption is null or length(caption) < 4096),
size integer,
caption text check(caption is null or length(caption) < 2048),
published_by integer references users(id) on delete set null,
parent_type integer check(parent_type in (0, 1, 2)) default 0,
parent_id integer,
backup_state integer default 0
published integer,
parent_type integer check(parent_type in (0, 1, 2, 3)) default 0,
parent_id integer
) strict;
create index if not exists idx_files_project_id on files (project_id);
create table if not exists companies (
id integer primary key autoincrement,
project_id integer references projects(id) on delete cascade,
name text not null check(length(name) < 4096),
address text check(address is null or length(address) < 512),
email text check(email is null or length(email) < 128),
phone text check(phone is null or length(phone) < 128),
site text check(site is null or length(site) < 128),
description text check(description is null or length(description) < 4096),
logo text
) strict;
create index if not exists idx_companies_project_id on companies (project_id);
create table if not exists company_mappings (
project_id integer references projects(id) on delete cascade,
company_id integer references companies(id) on delete cascade,
show_as_id integer references companies(id) on delete cascade,
--show_as_id integer references companies(id) on delete cascade,
show_to_id integer references companies(id) on delete cascade
) strict;
create index if not exists idx_company_mappings_project_id on company_mappings (project_id);
create table if not exists task_users (
task_id integer references tasks(id) on delete cascade,
@@ -153,8 +172,7 @@ create table if not exists chat_users (
pragma foreign_keys = on;
create trigger if not exists trg_chats_update after update
on chats
create trigger if not exists trg_chats_update after update on chats
when NEW.project_id is null
begin
delete from chat_users where chat_id = NEW.id;

BIN
backend/data/log.sqlite Normal file

Binary file not shown.