Files
payg-report/etc/db/billing_schema_vc.sql
2026-05-11 19:50:50 +03:00

279 lines
7.3 KiB
SQL

--
-- PostgreSQL database dump
--
-- Dumped from database version 16.0
-- Dumped by pg_dump version 16.4
-- Started on 2025-09-15 09:53:16
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- TOC entry 222 (class 1259 OID 1893983)
-- Name: capacity_resource; Type: TABLE; Schema: ngcloud_ru; Owner: vc_billing
--
CREATE TABLE ngcloud_ru.capacity_resource (
vdc_id uuid NOT NULL,
"timestamp" timestamp with time zone NOT NULL,
cpu_allocated integer NOT NULL,
cpu_limit integer NOT NULL,
cpu_reserved integer NOT NULL,
cpu_used integer NOT NULL,
cpu_speed integer NOT NULL,
mem_allocated integer NOT NULL,
mem_limit integer NOT NULL,
mem_reserved integer NOT NULL,
mem_used integer NOT NULL
);
ALTER TABLE ngcloud_ru.capacity_resource OWNER TO vc_billing;
--
-- TOC entry 223 (class 1259 OID 1893993)
-- Name: capacity_storage; Type: TABLE; Schema: ngcloud_ru; Owner: vc_billing
--
CREATE TABLE ngcloud_ru.capacity_storage (
vdc_id uuid NOT NULL,
storage_profile_types_id integer NOT NULL,
"timestamp" timestamp with time zone NOT NULL,
id uuid NOT NULL,
"limit" integer NOT NULL,
used integer NOT NULL
);
ALTER TABLE ngcloud_ru.capacity_storage OWNER TO vc_billing;
--
-- TOC entry 220 (class 1259 OID 1893965)
-- Name: storage_profile_types; Type: TABLE; Schema: ngcloud_ru; Owner: vc_billing
--
CREATE TABLE ngcloud_ru.storage_profile_types (
id integer NOT NULL,
name character varying(255) NOT NULL
);
ALTER TABLE ngcloud_ru.storage_profile_types OWNER TO vc_billing;
--
-- TOC entry 219 (class 1259 OID 1893964)
-- Name: storage_profile_types_id_seq; Type: SEQUENCE; Schema: ngcloud_ru; Owner: vc_billing
--
CREATE SEQUENCE ngcloud_ru.storage_profile_types_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE ngcloud_ru.storage_profile_types_id_seq OWNER TO vc_billing;
--
-- TOC entry 3413 (class 0 OID 0)
-- Dependencies: 219
-- Name: storage_profile_types_id_seq; Type: SEQUENCE OWNED BY; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER SEQUENCE ngcloud_ru.storage_profile_types_id_seq OWNED BY ngcloud_ru.storage_profile_types.id;
--
-- TOC entry 218 (class 1259 OID 1893959)
-- Name: tenant; Type: TABLE; Schema: ngcloud_ru; Owner: vc_billing
--
CREATE TABLE ngcloud_ru.tenant (
id uuid NOT NULL,
name character varying(255) NOT NULL,
wzcode bigint
);
ALTER TABLE ngcloud_ru.tenant OWNER TO vc_billing;
--
-- TOC entry 221 (class 1259 OID 1893973)
-- Name: vdc; Type: TABLE; Schema: ngcloud_ru; Owner: vc_billing
--
CREATE TABLE ngcloud_ru.vdc (
id uuid NOT NULL,
tenant_id uuid NOT NULL,
name character varying(255) NOT NULL
);
ALTER TABLE ngcloud_ru.vdc OWNER TO vc_billing;
--
-- TOC entry 3245 (class 2604 OID 1893968)
-- Name: storage_profile_types id; Type: DEFAULT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.storage_profile_types ALTER COLUMN id SET DEFAULT nextval('ngcloud_ru.storage_profile_types_id_seq'::regclass);
--
-- TOC entry 3255 (class 2606 OID 1893987)
-- Name: capacity_resource capacity_resource_pkey; Type: CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.capacity_resource
ADD CONSTRAINT capacity_resource_pkey PRIMARY KEY (vdc_id, "timestamp");
--
-- TOC entry 3257 (class 2606 OID 1893997)
-- Name: capacity_storage capacity_storage_pkey; Type: CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.capacity_storage
ADD CONSTRAINT capacity_storage_pkey PRIMARY KEY (vdc_id, id, "timestamp");
--
-- TOC entry 3249 (class 2606 OID 1893972)
-- Name: storage_profile_types storage_profile_types_name_key; Type: CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.storage_profile_types
ADD CONSTRAINT storage_profile_types_name_key UNIQUE (name);
--
-- TOC entry 3251 (class 2606 OID 1893970)
-- Name: storage_profile_types storage_profile_types_pkey; Type: CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.storage_profile_types
ADD CONSTRAINT storage_profile_types_pkey PRIMARY KEY (id);
--
-- TOC entry 3247 (class 2606 OID 1893963)
-- Name: tenant tenant_pkey; Type: CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.tenant
ADD CONSTRAINT tenant_pkey PRIMARY KEY (id);
--
-- TOC entry 3253 (class 2606 OID 1893977)
-- Name: vdc vdc_pkey; Type: CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.vdc
ADD CONSTRAINT vdc_pkey PRIMARY KEY (id);
--
-- TOC entry 3259 (class 2606 OID 1893988)
-- Name: capacity_resource capacity_resource_vdc_id_fkey; Type: FK CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.capacity_resource
ADD CONSTRAINT capacity_resource_vdc_id_fkey FOREIGN KEY (vdc_id) REFERENCES ngcloud_ru.vdc(id) ON DELETE CASCADE;
--
-- TOC entry 3260 (class 2606 OID 1894003)
-- Name: capacity_storage capacity_storage_storage_profile_types_id_fkey; Type: FK CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.capacity_storage
ADD CONSTRAINT capacity_storage_storage_profile_types_id_fkey FOREIGN KEY (storage_profile_types_id) REFERENCES ngcloud_ru.storage_profile_types(id);
--
-- TOC entry 3261 (class 2606 OID 1893998)
-- Name: capacity_storage capacity_storage_vdc_id_fkey; Type: FK CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.capacity_storage
ADD CONSTRAINT capacity_storage_vdc_id_fkey FOREIGN KEY (vdc_id) REFERENCES ngcloud_ru.vdc(id) ON DELETE CASCADE;
--
-- TOC entry 3258 (class 2606 OID 1893978)
-- Name: vdc vdc_tenant_id_fkey; Type: FK CONSTRAINT; Schema: ngcloud_ru; Owner: vc_billing
--
ALTER TABLE ONLY ngcloud_ru.vdc
ADD CONSTRAINT vdc_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES ngcloud_ru.tenant(id);
--
-- TOC entry 3410 (class 0 OID 0)
-- Dependencies: 222
-- Name: TABLE capacity_resource; Type: ACL; Schema: ngcloud_ru; Owner: vc_billing
--
GRANT SELECT ON TABLE ngcloud_ru.capacity_resource TO grafanabilling;
--
-- TOC entry 3411 (class 0 OID 0)
-- Dependencies: 223
-- Name: TABLE capacity_storage; Type: ACL; Schema: ngcloud_ru; Owner: vc_billing
--
GRANT SELECT ON TABLE ngcloud_ru.capacity_storage TO grafanabilling;
--
-- TOC entry 3412 (class 0 OID 0)
-- Dependencies: 220
-- Name: TABLE storage_profile_types; Type: ACL; Schema: ngcloud_ru; Owner: vc_billing
--
GRANT SELECT ON TABLE ngcloud_ru.storage_profile_types TO grafanabilling;
--
-- TOC entry 3414 (class 0 OID 0)
-- Dependencies: 218
-- Name: TABLE tenant; Type: ACL; Schema: ngcloud_ru; Owner: vc_billing
--
GRANT SELECT ON TABLE ngcloud_ru.tenant TO grafanabilling;
--
-- TOC entry 3415 (class 0 OID 0)
-- Dependencies: 221
-- Name: TABLE vdc; Type: ACL; Schema: ngcloud_ru; Owner: vc_billing
--
GRANT SELECT ON TABLE ngcloud_ru.vdc TO grafanabilling;
-- Completed on 2025-09-15 09:53:18
--
-- PostgreSQL database dump complete
--