CREATE TABLE IF NOT EXISTS item_groups (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  is_pos_enabled BOOLEAN DEFAULT FALSE,
  uses_default_tax BOOLEAN DEFAULT TRUE,
  tax_rate NUMERIC(18,4),
  raw JSONB NOT NULL DEFAULT '{}'::jsonb,
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE IF NOT EXISTS warehouses (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  shelves JSONB NOT NULL DEFAULT '[]'::jsonb,
  raw JSONB NOT NULL DEFAULT '{}'::jsonb,
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_item_groups_name ON item_groups (name);
CREATE INDEX IF NOT EXISTS idx_warehouses_name ON warehouses (name);
