-- Create form wizard tables

CREATE TABLE IF NOT EXISTS form_wizards (
  id SERIAL PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  description TEXT,
  tenant_id INTEGER,
  branch_id INTEGER,
  isDeleted BOOLEAN NOT NULL DEFAULT FALSE,
  updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS form_wizards_tenant_idx ON form_wizards(tenant_id);
CREATE INDEX IF NOT EXISTS form_wizards_branch_idx ON form_wizards(branch_id);

CREATE TABLE IF NOT EXISTS form_wizard_steps (
  id SERIAL PRIMARY KEY,
  wizard_id INTEGER NOT NULL,
  step_number INTEGER NOT NULL,
  form_id INTEGER NOT NULL,
  condition_field VARCHAR(100),
  condition_value VARCHAR(100),
  isDeleted BOOLEAN NOT NULL DEFAULT FALSE,
  updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS fws_wizard_idx ON form_wizard_steps(wizard_id);
CREATE INDEX IF NOT EXISTS fws_form_idx ON form_wizard_steps(form_id);
