ALTER TABLE tickets ADD COLUMN IF NOT EXISTS category varchar(120) NULL AFTER channel;
ALTER TABLE tickets ADD COLUMN IF NOT EXISTS equipment_id int NULL AFTER customer_id;
ALTER TABLE tickets ADD COLUMN IF NOT EXISTS closed_at datetime NULL AFTER updated_at;
ALTER TABLE ticket_messages ADD COLUMN IF NOT EXISTS attachment varchar(255) NULL AFTER internal;
CREATE TABLE IF NOT EXISTS ticket_attachments (
  id int auto_increment primary key,
  ticket_id int not null,
  user_id int null,
  filename varchar(255),
  original_name varchar(255),
  mime varchar(120),
  size_bytes int default 0,
  created_at datetime default current_timestamp
);

