-- Create graphs table
CREATE TABLE graphs (
    id SERIAL,
    name VARCHAR(255) NOT NULL,
    config JSONB DEFAULT '{"groupBy":"","aggregateFunc":"","timeUnit":""}',
    tenant_id INTEGER DEFAULT NULL,
    branch_id INTEGER DEFAULT NULL,
    createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    isDeleted BOOLEAN NOT NULL DEFAULT FALSE,
    PRIMARY KEY (id)
);
CREATE INDEX graphs_tenant_idx ON graphs (tenant_id);
CREATE INDEX graphs_branch_idx ON graphs (branch_id);
