diff --git a/migration/19.12/1912.sql b/migration/19.12/1912.sql index b42879eb70b12ad2ad3892790ca5fe2c37b8cde8..12f40465bc47bfca109c62c3e22e16a0be4dfd70 100644 --- a/migration/19.12/1912.sql +++ b/migration/19.12/1912.sql @@ -529,6 +529,21 @@ ALTER TABLE listinstance DROP COLUMN IF EXISTS visible; ALTER TABLE listinstance_history_details DROP COLUMN IF EXISTS added_by_entity; ALTER TABLE usergroup_content DROP COLUMN IF EXISTS primary_group; ALTER TABLE emails ALTER COLUMN document type jsonb; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS subject; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS description; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS type_id; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS author; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS source; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS folders_system_id; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS offset_doc; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS destination; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS priotity; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS initiator; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_multicontacts; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_multi_docservers; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_path; +ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_filename; + /* M2M */ DO $$ BEGIN diff --git a/sql/structure.sql b/sql/structure.sql index 0ff99bf1f3ca737edfa8380b08f4a0b71e7f628b..c107ffd1c4535580a49ffb77685ef21acb0556e4 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -247,31 +247,22 @@ CREATE TABLE res_attachments ( res_id bigint NOT NULL DEFAULT nextval('res_attachment_res_id_seq'::regclass), title character varying(255) DEFAULT NULL::character varying, - subject text, - description text, - type_id bigint , format character varying(50) NOT NULL, typist character varying(128) NOT NULL, creation_date timestamp without time zone NOT NULL, modification_date timestamp without time zone DEFAULT NOW(), - author character varying(255) DEFAULT NULL::character varying, identifier character varying(255) DEFAULT NULL::character varying, - source character varying(255) DEFAULT NULL::character varying, relation bigint, docserver_id character varying(32) NOT NULL, path character varying(255) DEFAULT NULL::character varying, filename character varying(255) DEFAULT NULL::character varying, - offset_doc character varying(255) DEFAULT NULL::character varying, fingerprint character varying(255) DEFAULT NULL::character varying, filesize bigint, status character varying(10) DEFAULT NULL::character varying, - destination character varying(50) DEFAULT NULL::character varying, validation_date timestamp without time zone, effective_date timestamp without time zone, work_batch bigint, origin character varying(50) DEFAULT NULL::character varying, - priority character varying(16), - initiator character varying(50) DEFAULT NULL::character varying, dest_user character varying(128) DEFAULT NULL::character varying, res_id_master bigint, origin_id INTEGER, @@ -279,10 +270,6 @@ CREATE TABLE res_attachments dest_contact_id bigint, dest_address_id bigint, updated_by character varying(128) DEFAULT NULL::character varying, - is_multicontacts character(1), - is_multi_docservers character(1) NOT NULL DEFAULT 'N'::bpchar, - tnl_path character varying(255) DEFAULT NULL::character varying, - tnl_filename character varying(255) DEFAULT NULL::character varying, in_signature_book boolean DEFAULT FALSE, in_send_attach boolean DEFAULT FALSE, signatory_user_serial_id int, diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index 659016a3235b24adf86c6fc6df553993a44e9b61..e02d96b4fd5f633a1710c69a2f26d2167c90f4ab 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -830,11 +830,13 @@ class AttachmentController if (!Validator::intVal()->notEmpty()->validate($body['originId'])) { return ['errors' => 'Body originId is not an integer']; } - $origin = AttachmentModel::getById(['id' => $body['originId'], 'select' => ['res_id_master']]); + $origin = AttachmentModel::getById(['id' => $body['originId'], 'select' => ['res_id_master', 'origin_id']]); if (empty($origin)) { return ['errors' => 'Body originId does not exist']; } elseif ($origin['res_id_master'] != $body['resIdMaster']) { return ['errors' => 'Body resIdMaster is different from origin']; + } elseif (!empty($origin['origin_id'])) { + return ['errors' => 'Body originId can not be a version, it must be the original version']; } }