-- Add element_types lookup table and replace field_type column

CREATE TABLE IF NOT EXISTS element_types (
  id SERIAL PRIMARY KEY,
  tenant_id INTEGER,
  branch_id INTEGER,
  name VARCHAR(100) NOT NULL,
  html_type VARCHAR(50),
  display_class VARCHAR(100),
  isDeleted BOOLEAN NOT NULL DEFAULT FALSE,
  updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

ALTER TABLE form_elements
  ADD COLUMN type_id INTEGER,
  DROP COLUMN field_type;
CREATE INDEX form_elements_type_idx ON form_elements(type_id);
