-- ============================================================================
-- Copyright (C) 2026 Alles Watt lauft
--
-- Table for defining fields per element type (EAV pattern for flexibility)
-- ============================================================================

CREATE TABLE llx_kundenkarte_anlage_type_field
(
    rowid               integer AUTO_INCREMENT PRIMARY KEY,
    entity              integer DEFAULT 0 NOT NULL,

    fk_anlage_type      integer NOT NULL,

    field_code          varchar(64) NOT NULL,
    field_label         varchar(255) NOT NULL,
    field_type          varchar(32) NOT NULL,
    field_options       text,

    field_size          integer DEFAULT 255,
    field_default       varchar(255),

    required            tinyint DEFAULT 0 NOT NULL,
    show_in_tree        tinyint DEFAULT 0 NOT NULL,
    tree_display_mode   varchar(20) DEFAULT 'badge',
    badge_color         varchar(7),
    show_in_hover       tinyint DEFAULT 1 NOT NULL,
    enable_autocomplete tinyint DEFAULT 0 NOT NULL,

    position            integer DEFAULT 0,
    active              tinyint DEFAULT 1 NOT NULL,

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