-- up
CREATE TABLE calendars (
  id             INTEGER PRIMARY KEY AUTOINCREMENT,
  name           TEXT NOT NULL,
  timezone       TEXT NOT NULL DEFAULT 'Asia/Dubai',
  parent_id      INTEGER REFERENCES calendars(id),
  hours_per_day  NUMERIC(4,2) NOT NULL DEFAULT 8.00,
  metadata       TEXT NOT NULL DEFAULT '{}',
  created_at     TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
  updated_at     TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now'))
);
CREATE INDEX idx_calendars_parent ON calendars (parent_id);

-- down
DROP TABLE calendars;
