-- ============================================================================
-- Copyright (C) 2026 Alles Watt lauft
--
-- Table for installation element file attachments
-- Files stored in: /documents/kundenkarte/anlagen/{socid}/{element_id}/
-- Separate from ECM system
-- ============================================================================

CREATE TABLE llx_kundenkarte_anlage_files
(
    rowid               integer AUTO_INCREMENT PRIMARY KEY,
    entity              integer DEFAULT 1 NOT NULL,

    fk_anlage           integer NOT NULL,

    filename            varchar(255) NOT NULL,
    filepath            varchar(512) NOT NULL,
    filesize            bigint DEFAULT 0,
    mimetype            varchar(128),

    file_type           varchar(32) DEFAULT 'document',

    label               varchar(255),
    description         text,

    is_cover            tinyint DEFAULT 0 NOT NULL,
    is_pinned           tinyint DEFAULT 0 NOT NULL,
    position            integer DEFAULT 0,

    share               varchar(128),

    date_creation       datetime,
    tms                 timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    fk_user_creat       integer,
    fk_user_modif       integer
) ENGINE=innodb;
