xftp: delete agent rcv files on completion, error, item delete (#2040)

This commit is contained in:
spaced4ndy
2023-03-21 15:21:14 +04:00
committed by GitHub
parent cfc323862f
commit 60d6a47bdb
10 changed files with 140 additions and 63 deletions
@@ -0,0 +1,20 @@
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Migrations.M20230321_agent_file_deleted where
import Database.SQLite.Simple (Query)
import Database.SQLite.Simple.QQ (sql)
m20230321_agent_file_deleted :: Query
m20230321_agent_file_deleted =
[sql|
PRAGMA ignore_check_constraints=ON;
ALTER TABLE files ADD COLUMN agent_snd_file_deleted INTEGER DEFAULT 0 CHECK (agent_snd_file_deleted NOT NULL);
UPDATE files SET agent_snd_file_deleted = 0;
ALTER TABLE rcv_files ADD COLUMN agent_rcv_file_deleted INTEGER DEFAULT 0 CHECK (agent_rcv_file_deleted NOT NULL);
UPDATE rcv_files SET agent_rcv_file_deleted = 0;
PRAGMA ignore_check_constraints=OFF;
|]
+4 -2
View File
@@ -195,7 +195,8 @@ CREATE TABLE files(
ci_file_status TEXT,
file_inline TEXT,
agent_snd_file_id BLOB NULL,
private_snd_file_descr TEXT NULL
private_snd_file_descr TEXT NULL,
agent_snd_file_deleted INTEGER DEFAULT 0 CHECK(agent_snd_file_deleted NOT NULL)
);
CREATE TABLE snd_files(
file_id INTEGER NOT NULL REFERENCES files ON DELETE CASCADE,
@@ -222,7 +223,8 @@ CREATE TABLE rcv_files(
file_inline TEXT,
file_descr_id INTEGER NULL
REFERENCES xftp_file_descriptions ON DELETE SET NULL,
agent_rcv_file_id BLOB NULL
agent_rcv_file_id BLOB NULL,
agent_rcv_file_deleted INTEGER DEFAULT 0 CHECK(agent_rcv_file_deleted NOT NULL)
);
CREATE TABLE snd_file_chunks(
file_id INTEGER NOT NULL,